Hello, a question about the function file:list. The documenation says: "The returned paths are relative to the provided path." My understanding is that if the path is a/b/c and this dir contains a file fool.xml, the returned path would be "fool.xml", rather thatn "a/b/c/fool.xml". What confuses me is that I observe two different behaviours in two different BaseX versions, once with and once without path: version 7.2 with path, version 7.2.2 without path. (The OS also differs in the environments, but I suppose this is irrelevant.) My question: is the output without path (more generally: with a path relative to the stated dir) the correct one and will be produced in all future versions? Thank you. Kind regards, Hans-Juergen
Dear Hans-Jürgen,
a question about the function file:list. The documenation says: "The returned paths are relative to the provided path." My understanding is that if the path is a/b/c and this dir contains a file fool.xml, the returned path would be "fool.xml", rather thatn "a/b/c/fool.xml".
completely true: this is why we have recently aligned the functionality of the file:list() function to match the current EXPath documentation. I have just added a post hoc entry in our Wiki to avoid future surprises [1].
If you want to prefix the relative file paths with the root directory without writing too many LOCs, you can take advantage of the XQuery 3.0 "simple map" and "concatenate" operators:
let $p := "/root/path" return file:list($p) ! ($p || '/' || .)
Hope this helps, Christian
basex-talk@mailman.uni-konstanz.de