Ok, I got it figured out from this page: http://docs.basex.org/wiki/Database_%26_Collection. So, in my return concat, I need to use the "base-uri" of $song to get the actual file path. So, my query will look something like: for $song in collection("OpenSongSearch") where $song/song/lyrics[ . contains text "baloche"] or $song/song/title[ . contains text "baloche"] or $song/song/author[ . contains text "baloche"] order by $song/song/title return concat(base-uri($song),string('|'), $song/song/title,string('|'),$song/song/author,string('|'),replace(replace($ song/song/lyrics,'\n','^line^'),'\[\w+\]',''),string(' ')) Yep, that works! Sorry to bug you all with a question that's documented! Are there other options than base-uri? For instance, base-uri has the file name. Is there a function like that with just the path but not the file name? If not, I can certainly work with base-uri. (I couldn't find any, but thought I'd ask) Thanks!