Bug #5010
closedStatic base URI missing trailing slash for -xp command line option
100%
Description
In https://saxonica.plan.io/boards/5/topics/8210, Martin Honnen writes:
I have started to use Saxon JS 2.2's
xslt3 -xp
option to quickly run/test some XPath 3.1 stuff.One quirk that bugs me is shown below:
C:\Users\marti>xslt3 -xp:"static-base-uri()" "file://C:/Users/marti" C:\Users\marti>xslt3 -xp:"resolve-uri('foo.xml', static-base-uri())" "file:///C:/Users/foo.xml"
So I run
xslt3
in the directoryC:\Users\marti
andstatic-base-uri()
gives mefile://C:/Users/marti
without a trailing slash meaning any attempt to find a local file in the working directory with e.g.resolve-uri('foo.xml', static-base-uri())
fails to find the file as it looks in the parent directory forfile:///C:/Users/foo.xml
.A similar test with Saxon Java (using the XQuery command line API as it doesn't have an XPath one) gives
C:\Users\marti>java -cp "C:\Program Files\Saxonica\SaxonHE10-5J\saxon-he-10.5.jar" net.sf.saxon.Query -qs:"static-base-uri()" <?xml version="1.0" encoding="UTF-8"?>file:/C:/Users/marti/ C:\Users\marti>java -cp "C:\Program Files\Saxonica\SaxonHE10-5J\saxon-he-10.5.jar" net.sf.saxon.Query -qs:"resolve-uri('foo.xml', static-base-uri())" <?xml version="1.0" encoding="UTF-8"?>file:/C:/Users/marti/foo.xml
so there I get a static base URI with a trailing slash meaning files in the working directory are found when I resolve against the static base URI.
The problem with Saxon JS 2.2's base URI also arises with e.g.
xslt3 -xp:"doc('test2021052801.xml')"
, the named file exists in my working directory but Saxon gives an error as it looks in the parent directory:Error FODC0002 Cannot read file file:///C:/Users/test2021052801.xml - ENOENT: no such file or directory, open 'C:\Users\test2021052801.xml'
Please register to edit this issue
Also available in: Atom PDF Tracking page