I correct myself - probably one should use file:path-to-uri(file:parent('.'))
rather than replace(file:parent('.'),'\', '/')
in order to make the result of file:parent('.') usable in fn:resolve-uri.
Come to think of it - maybe a convenience function 'file:current-dir()' (= file:parent('.')) would be worthwhile, considering the importance of the current directory.
Cheers, Hans-Juergen
-------------------------------------------- Hans-Juergen Rennau hrennau@yahoo.de schrieb am Di, 18.2.2014:
Betreff: Re: [basex-talk] Sought: a pattern of file:list usage An: "Christian Grün" christian.gruen@gmail.com CC: "BaseX" basex-talk@mailman.uni-konstanz.de Datum: Dienstag, 18. Februar, 2014 12:38 Uhr
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