The -s option resolves spaces incorrectly in filenames
Martin Honnen writes:
I thought I had reported a problem for Saxon JS 2.0: when I run e.g.
xslt3 -s:input.xml -xsl:sheet.xsl -t on Windows where I am in a directory that contains a space in the path (e.g.
C:\Users\John Doe\folder\subfolder) with 2.0 and still with 2.1 I get an error that indicates that the source is failing to be loaded from
C:/Users/John%20/Doe/folder/subfolder/input.xml (note the percentage encoding of the space) e.g.
Saxon-JS 2.1 from Saxonica Node.js version v12.18.0 Compiling stylesheet C:\Users\John Doe\folder\subfolder\sheet.xsl Stylesheet compilation time: 0.199s Transformation failed: Error SXJS0006 Failed to read XML source input (Failed to read C:/Users/John%20/Doe/folder/subfolder/input.xml(no such file))
So it appears the relative stylesheet URI (or is Saxon JS only treating that option as a file name?) works fine but the relative input URI fails.
https://saxonica.plan.io/issues/4590 is kind of related although that is an output URI not an input URI.
Updated by Philip Fearon over 1 year ago
This problem (using Saxon-JS 2.1), with space characters escaped to '%20' in paths, appears to affect all paths supplied in the command-line.
For example, on macos:
black2:saxonjs-test philipf$ node node_modules/xslt3/xslt3.js -xsl:transform.xsl "-s:new dir/input.xml" -o:result.xml Transformation failed: Error SXJS0006 Failed to read XML source input (Failed to read /Users/philipf/dev/saxonjs-test/new%20dir/input.xml(no such file))
It seems command-line paths are converted to URIs but not correctly restored back again to file paths later on. Would url.fileURLToPath(url) (https://nodejs.org/api/url.html#url_url_fileurltopath_url) help in this case?
Please register to edit this issue