Project

Profile

Help

Should static-base-uri() return the working directory's file URI with a trailing slash?

Added by Martin Honnen over 3 years ago

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 directory C:\Users\marti and static-base-uri() gives me file://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 for file:///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'

Replies (1)

RE: Should static-base-uri() return the working directory's file URI with a trailing slash? - Added by Debbie Lockett over 3 years ago

Thanks for the report. Yes this looks like a bug for the -xp command line option, so I've raised a bug to track it: https://saxonica.plan.io/issues/5010

    (1-1/1)

    Please register to reply