Am Sonntag, 25. September 2022 um 18:36:33 MESZ hat Graydon <graydonish@gmail.com> Folgendes geschrieben:
On Sun, Sep 25, 2022 at 10:04:51AM +0000, Hans-Juergen Rennau scripsit:
> Hi, Graydon,
Hello!
> you ask what I mean by "Providing the parameter value to file:children as a relative path".
>
> With "the parameter value" I mean the value passed to file:children() or file:descendants(), and it's clear what is meant by a relative path (a path not starting at the foot of the file system).
> For this reason, your statement:"file:resolve-path('../xslt',file:base-dir()) => file:children() works.
> That's what I'd think of as providing a relative path."confuses me, because you do provide an absolute path, as the argument is an invocation of file:resolve-path().
I do provide an absolute path, but via a relative path that has to be
resolved against a base. I think that's how relative paths work because
I've never been able to get a true relative path to work in practice,
and have put this down to miscomprehending something.
I now think that I was miscomprehending what the docs say about what
file:base-dir() returns; I took that to mean the returned value would be
the location of the BaseX executable, not the location of the XQuery
module. (thank you! the below was usefully clear about this.)
> As you bring function file:base-dir() into play, let me point out one
> remarkable fact: whereas all (?) functions of the file module resolve
> relative paths against the current working directory, this function
> does not return the current working directory (for that we
> have file:current-dir()), but the "parent directory of the static base
> URI", in other words: the directory containing the XQuery module
> containing the code.
If I run:
(file:base-dir(),file:current-dir(),file:resolve-path('..'),file:children('..'))
in the GUI, without saving it, and having closed everything else, I get:
/home/graydon/xcential/git/Oregon-DPMS/modelling/amending/ixml/xquery/
/home/graydon/
/home/
../graydon/
That first path is the last place I saved a query from the GUI.
If I close that tab, close the GUI, restart the GUI, and paste in that
same bit of XPath, I get the same result. So I think the value for
file:base-dir persists. (I'm a bit surprised by file:current-dir(),
too, but will put that down to starting BaseX from a panel shortcut.)
It's not immediately clear to me that the file:base-dir value should
persist. It seems like this could produce a lot of surprise.
> Finally, let me summarize my point: (1) The functions file:children()
> and file:descendants() take a single parameter which is a path which
> may be specified as absolute path or relative path to be resolved
> against the current working directory. (2) Irrespectived of how the
> argument was supplied, the functions must always return absolute
> paths.(3) If you want a file listing to return relative paths, use
> function file:list().
No arguement from me on these points.
Though I will note that my recollection is that they never have.
--
Graydon Saunders |
graydonish@gmail.comÞæs oferéode, ðisses swá mæg.
-- Deor ("That passed, so may this.")