Project

Profile

Help

Bug #5010

closed

Static base URI missing trailing slash for -xp command line option

Added by Debbie Lockett almost 3 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Category:
Command line
Sprint/Milestone:
-
Start date:
2021-05-28
Due date:
% Done:

100%

Estimated time:
Applies to JS Branch:
2
Fix Committed on JS Branch:
2
Fixed in JS Release:
SEF Generated with:
Platforms:
Company:
-
Contact person:
-
Additional contact persons:
-

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 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'

Please register to edit this issue

Also available in: Atom PDF Tracking page