Oh, this greatly helped indeed! I was not aware of file:parent.
I conclude that an application which expects external input for both, fn:doc and file:list, has the choice between two ways of providing consistent resolution of relative paths:
(a) "always resolve against tool location": when using file:list, resolve relative paths against the static URI of the tool (fn:resolve-uri($rpath)), and when using fn:doc, use relative paths unchanged. (b) "always resolve against current directory": when using file:list, use relative paths unchanged, and when using fn:doc, resolve relative paths against the current directory: doc(resolve-uri($rpath, replace(file:parent('.'),'\','/')))
Great.
One REMARK. On a Windows system, file:parent returns a path with backslashes. When supplying this as second argument to fn:resolve-uri, an error occurs:
resolve-uri('abc.xml',file:parent('.')) => [FORG0002] URI argument is invalid: "C:\user\ptools".
One has to manually replace the backslashes by forward slashes: resolve-uri('abc.xml',replace(file:parent('.'),'\','/'))
This is a little pitfall, as the function's rejection of backslash is not necessarily expected. (By the way, Saxon behaves exactly the same.)
Once more, thanks a lot! Hans-Juergen
-------------------------------------------- Christian Grün christian.gruen@gmail.com schrieb am Di, 18.2.2014:
Betreff: Re: [basex-talk] Sought: a pattern of file:list usage An: "Hans-Juergen Rennau" hrennau@yahoo.de CC: "BaseX" basex-talk@mailman.uni-konstanz.de Datum: Dienstag, 18. Februar, 2014 11:07 Uhr
Dear Hans-Jürgen,
This is how you can list all files in the directory of your query file:
let $dir := file:parent(static-base-uri()) for $file in file:list($dir) return $dir || $file
And this is how you can find out the current working directory:
file:parent('.')
Does this help? Christian