Support #4700
closedProblems running Saxon-JS CLI from Powershell
0%
Description
I had no problem with Saxon-JS until I upgraded to Node 14.8.0. I was able to use the xslt3 CLI tool to both generate SEFs and process XSLT directly. However, after reinstalling Saxon-JS I started getting the following errors:
PS E:\Code\FBI\stor223\stor223-dev\NIEM-GJXDM\xslt> xslt3 -xsl:test.xsl -export:test.sef.json -nogo Error: Command line option -xsl requires a value at d (C:\Users\kurtc\AppData\Roaming\npm\node_modules\xslt3\xslt3.js:5:297) at C:\Users\kurtc\AppData\Roaming\npm\node_modules\xslt3\xslt3.js:6:317 at Array.forEach () at f.setActualOptions (C:\Users\kurtc\AppData\Roaming\npm\node_modules\xslt3\xslt3.js:5:449) at main$$module$temp$js$source$nodeJS$command (C:\Users\kurtc\AppData\Roaming\npm\node_modules\xslt3\xslt3.js:33:197) at Object. (C:\Users\kurtc\AppData\Roaming\npm\node_modules\xslt3\xslt3.js:41:201) at Object. (C:\Users\kurtc\AppData\Roaming\npm\node_modules\xslt3\xslt3.js:41:383) at Module._compile (internal/modules/cjs/loader.js:1251:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1272:10) at Function.Module._load (internal/modules/cjs/loader.js:962:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) Invalid command line input: test.xsl Usage: see http://www.saxonica.com/saxon-js/documentation/index.html#!nodejs/command-line Options available: -?, -co, -debug, -export, -im, -it, -master, -nogo, -ns, -o, -s, -t, -tp, -xsl Use -XYZ:? for details of option XYZ Params: param=value Set stylesheet string parameter +param=filename Set stylesheet document parameter ?param=expression Set stylesheet parameter using XPath !param=value Set serialization parameter (bindings and values containing punctuation may need to be quoted in some command shells, e.g. in PowerShell: "{NS}key=val" ?range="1 to 20" ) Usage: see http://www.saxonica.com/saxon-js/documentation/index.html#!nodejs/command-line Options available: -?, -co, -debug, -export, -im, -it, -master, -nogo, -ns, -o, -s, -t, -tp, -xsl Params: param=value Set stylesheet string parameter +param=filename Set stylesheet document parameter !param=value Set serialization parameter (bindings and values containing punctuation may need to be quoted in some command shells, e.g. in PowerShell: "{NS}key=val" ?range="1 to 20" ) Missing '=' in parameter 'test.xsl' Internal error: bad input to string constructor #undefined Error at Object.a [as internalError] (C:\Users\kurtc\AppData\Roaming\npm\node_modules\xslt3\node_modules\saxon-js\SaxonJS2N.js:26:474) at new v (C:\Users\kurtc\AppData\Roaming\npm\node_modules\xslt3\node_modules\saxon-js\SaxonJS2N.js:47:429) at Object.fromString (C:\Users\kurtc\AppData\Roaming\npm\node_modules\xslt3\node_modules\saxon-js\SaxonJS2N.js:77:356) at C:\Users\kurtc\AppData\Roaming\npm\node_modules\xslt3\xslt3.js:16:228 at getParams$$module$temp$js$source$nodeJS$command (C:\Users\kurtc\AppData\Roaming\npm\node_modules\xslt3\xslt3.js:15:132) at main$$module$temp$js$source$nodeJS$command (C:\Users\kurtc\AppData\Roaming\npm\node_modules\xslt3\xslt3.js:34:7) at Object. (C:\Users\kurtc\AppData\Roaming\npm\node_modules\xslt3\xslt3.js:41:201) at Object. (C:\Users\kurtc\AppData\Roaming\npm\node_modules\xslt3\xslt3.js:41:383) at Module._compile (internal/modules/cjs/loader.js:1251:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1272:10) at Module.load (internal/modules/cjs/loader.js:1100:32) at Function.Module._load (internal/modules/cjs/loader.js:962:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) at internal/main/run_main_module.js:17:47 Error SXJS0004
I have tried with multiple variations of command line arguments and have been getting errors consistently if I attempt to actually run XSLT3 with parameters.
I have also discovered that I cannot get Oxygen 22.0 to build SEF.JSON files, though it generates the intermediate SEF.XML files. I had similar issues across both Windows and Ubuntu.
I'm hoping to use saxonjs in a production system soon for a US government project so this is causing issues.
Files
Updated by Michael Kay over 4 years ago
- Project changed from Saxon to SaxonJS
- Applies to JS Branch 2.0 added
Strange: I'm not sure we've run on that node.js version, but the failure is surprising. We'll see if we can reproduce it.
As regards oXygen, I don't think they have yet released a version with support for Saxon-JS 2. You'll have to wait for that.
Updated by Michael Kay over 4 years ago
I upgraded to node.js 14.9.0 (on MacOS) and couldn't reproduce the problem:
mackay:samples mike$ xslt3 -xsl:styles/books.xsl -t -nogo -export:/dev/null
Saxon-JS 2.0 from Saxonica
Node.js version v14.9.0
Compiling stylesheet /Users/mike/repo/samples/styles/books.xsl
Stylesheet compilation time: 0.456s
Stylesheet exported to SEF file /dev/null
mackay:samples mike$
I'll give it a try on a Windows box in the morning.
Updated by Michael Kay over 4 years ago
I've now installed node.js 14.9.0 and Saxon-JS 2 on Windows, and I'm getting a different error:
C:\Users\mike>xslt3 -xsl:GitHub/saxon-dev/samples/styles/books.xsl -s:GitHub/saxon-dev/samples/data/books.xml -t
Saxon-JS 2.0 from Saxonica
Node.js version v14.9.0
Compiling stylesheet C:\Users\mike\GitHub\saxon-dev\samples\styles\books.xsl
Stylesheet compilation time: 0.654s
SEF generated by Saxon-JS 2.0 at 2020-09-01T09:50:19.062+01:00 with -target:JS -relocate:true
<!DOCTYPE html>
<html><!--Generated at 2020-09-01T09:50:19.413+01:00-->Transformation failure: Error SERE0008 at books.xsl#19
(decimal 13) is not available in the chosen encoding
Transformation failed: Error SERE0008 at books.xsl#19
(decimal 13) is not available in the chosen encoding
Execution time: 0.40s
Memory used: 19.58Mb
This is some kind of problem with Windows line endings which needs to be investigated separately, but it's got well beyond the point where you were reporting it failing. So it's hard to know what to suggest next. I guess if you upgraded from 14.8 to 14.9 that would eliminate one (unlikely) possible cause.
Updated by Michael Kay over 4 years ago
I have raised the Windows line ending problem as bug #4702 (though on investigation, it's debatable whether it's a bug).
Updated by Norm Tovey-Walsh over 4 years ago
I wasn't able to reproduce it either. Have you tried the nuclear option of deleting node_modules and reinstalling? I wonder if there's some cruft lying around from some other upgrade operation or something.
Updated by Michael Kay over 4 years ago
Looking more closely at the actual error messages, and the corresponding code paths, we see both
Command line option -xsl requires a value
and
Invalid command line input: test.xsl
This suggests to me that the input -xsl:test.xsl
has somehow reached Saxon as two separate arguments, -xsl
and test.xsl
. So perhaps the command line input is somehow being mangled before it reaches Saxon?
Updated by John Lumley over 4 years ago
Are you perhaps using PowerShell? In such cases PowerShell preparses the arguments/options, whereas xslt3 expects to do its own parsing, so quoting is needed. I thought I’d documented this somewhere but can’t find at present.
John Lumley
Sent from my iPad
On 1 Sep 2020, at 14:50, Saxonica Developer Community notifications@plan.io wrote:
Updated by Kurt Cagle over 4 years ago
- Company set to Kurt Cagle
- Contact person set to Kurt Cagle
- File Semantical Logo.png Semantical Logo.png added
I am using PowerShell on Windows 10. Still getting the same error despite
quoting the stylesheet and source.
PS E:\code\saxon> xslt3 -xsl:"newFeatures.xsl" -s:"gameEncoding.xml"
Error: Command line option -xsl requires a value
at d
(C:\Users\kurtc\AppData\Roaming\npm\node_modules\xslt3\xslt3.js:5:297)
at C:\Users\kurtc\AppData\Roaming\npm\node_modules\xslt3\xslt3.js:6:317
at Array.forEach ()
at f.setActualOptions
(C:\Users\kurtc\AppData\Roaming\npm\node_modules\xslt3\xslt3.js:5:449)
at main$$module$temp$js$source$nodeJS$command
(C:\Users\kurtc\AppData\Roaming\npm\node_modules\xslt3\xslt3.js:33:197)
at Object.
(C:\Users\kurtc\AppData\Roaming\npm\node_modules\xslt3\xslt3.js:41:201)
at Object.
(C:\Users\kurtc\AppData\Roaming\npm\node_modules\xslt3\xslt3.js:41:383)
at Module._compile (internal/modules/cjs/loader.js:1251:30)
at Object.Module._extensions..js
(internal/modules/cjs/loader.js:1272:10)
at Module.load (internal/modules/cjs/loader.js:1100:32)
at Function.Module._load (internal/modules/cjs/loader.js:962:14)
at Function.executeUserEntryPoint [as runMain]
(internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
Invalid command line input: newFeatures.xsl
Usage: see
http://www.saxonica.com/saxon-js/documentation/index.html#!nodejs/command-line
Options available: -?, -co, -debug, -export, -im, -it, -master, -nogo, -ns,
-o, -s, -t, -tp, -xsl
Use -XYZ:? for details of option XYZ
Params:
param=value Set stylesheet string parameter
+param=filename Set stylesheet document parameter
?param=expression Set stylesheet parameter using XPath
!param=value Set serialization parameter
(bindings and values containing punctuation may need to be quoted in some
command shells,
e.g. in PowerShell: "{NS}key=val" ?range="1 to 20" )
Invalid command line input: gameEncoding.xml
Usage: see
http://www.saxonica.com/saxon-js/documentation/index.html#!nodejs/command-line
Options available: -?, -co, -debug, -export, -im, -it, -master, -nogo, -ns,
-o, -s, -t, -tp, -xsl
Use -XYZ:? for details of option XYZ
Params:
param=value Set stylesheet string parameter
+param=filename Set stylesheet document parameter
?param=expression Set stylesheet parameter using XPath
!param=value Set serialization parameter
(bindings and values containing punctuation may need to be quoted in some
command shells,
e.g. in PowerShell: "{NS}key=val" ?range="1 to 20" )
Missing '=' in parameter 'newFeatures.xsl'
Internal error: bad input to string constructor #undefined
Error
at Object.a [as internalError]
(C:\Users\kurtc\AppData\Roaming\npm\node_modules\xslt3\node_modules\saxon-js\SaxonJS2N.js:26:474)
at new v
(C:\Users\kurtc\AppData\Roaming\npm\node_modules\xslt3\node_modules\saxon-js\SaxonJS2N.js:47:429)
at Object.fromString
(C:\Users\kurtc\AppData\Roaming\npm\node_modules\xslt3\node_modules\saxon-js\SaxonJS2N.js:77:356)
at C:\Users\kurtc\AppData\Roaming\npm\node_modules\xslt3\xslt3.js:16:228
at Array.forEach ()
at getParams$$module$temp$js$source$nodeJS$command
(C:\Users\kurtc\AppData\Roaming\npm\node_modules\xslt3\xslt3.js:15:132)
at main$$module$temp$js$source$nodeJS$command
(C:\Users\kurtc\AppData\Roaming\npm\node_modules\xslt3\xslt3.js:34:7)
at Object.
(C:\Users\kurtc\AppData\Roaming\npm\node_modules\xslt3\xslt3.js:41:201)
at Object.
(C:\Users\kurtc\AppData\Roaming\npm\node_modules\xslt3\xslt3.js:41:383)
at Module._compile (internal/modules/cjs/loader.js:1251:30)
at Object.Module._extensions..js
(internal/modules/cjs/loader.js:1272:10)
at Module.load (internal/modules/cjs/loader.js:1100:32)
at Function.Module._load (internal/modules/cjs/loader.js:962:14)
at Function.executeUserEntryPoint [as runMain]
(internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
Error SXJS0004
Internal error: bad input to string constructor #undefined
PS E:\code\saxon>
Kurt Cagle
Founder, Semantical LLC
kurtcagle@gmail.com
443-837-8725
On Tue, Sep 1, 2020 at 9:04 AM Saxonica Developer Community <
notifications@plan.io> wrote:
Updated by Norm Tovey-Walsh over 4 years ago
I think possibly John meant you had to quote the whole argument so that PowerShell doesn't try to: "-xsl:newFeatures.xsl" but I could be mistaken.
Updated by John Lumley over 4 years ago
IIRC you have to quote the complete pair e.g. “-xsl:foo.xsl”
As a check alternative use cmdprompt to check - it’s what I use for all my compilations... I don’t need PowerShell capabilities
Sent from my iPad
On 1 Sep 2020, at 19:33, Saxonica Developer Community notifications@plan.io wrote:
Updated by Kurt Cagle over 4 years ago
Hmm ... using the command prompt did the trick. So it looks to be a
Powershell issue
Kurt Cagle
Founder, Semantical LLC
kurtcagle@gmail.com
443-837-8725
On Tue, Sep 1, 2020 at 11:39 AM Saxonica Developer Community <
notifications@plan.io> wrote:
Updated by Debbie Lockett about 4 years ago
- Tracker changed from Bug to Support
- Subject changed from Having severe Saxon-JS errors to Problems running Saxon-JS CLI from Powershell
- Status changed from New to In Progress
- Assignee set to Debbie Lockett
- Priority changed from High to Normal
Reclassifying and relabelling this as a support issue. But leaving open, because we should add some details in the documentation.
Note also the previous saxon-help list discussion (from June 2020):
Willem Van Lishout:
Not sure if a bug or not, but running Saxon-JS 2 from Powershell 7.0 on Windows only seems to work when the arguments (including their keys) are wrapped inside double quotes.
So this doesn't work: xslt3 -s:c:\temp\temp.xml -xsl:c:\temp\Untitled1.xsl
(Missing '=' in parameter 'c:\temp\temp.xml' Internal error: bad input to string constructor #undefined)
While this does work (and it took me quite a while to figure it out): xslt3 "-s:c:\temp\temp.xml" "-xsl:c:\temp\Untitled1.xsl"
This only happens in Powershell, not in cmd.exe.
John Lumley:
Apparently when Powershell sees ‘-something’ it parses an argument of the given name which is passed to the command... see https://stackoverflow.com/questions/5527261/how-to-pass-arugments-to-saxon-xquery-in-windows-powershell for some old stuff on this. xslt3 does its own argument processing, based on the white space-separated array args Node.js process uses.
Updated by Debbie Lockett about 4 years ago
- Status changed from In Progress to Resolved
Note added in documentation about needing to wrap arguments with double quotes when running from Powershell: https://www.saxonica.com/saxon-js/documentation/index.html#!nodejs/command-line. (Committed and updated online.)
Updated by Community Admin almost 4 years ago
- Applies to JS Branch 2 added
- Applies to JS Branch deleted (
2.0)
Updated by Debbie Lockett almost 4 years ago
- Status changed from Resolved to Closed
Please register to edit this issue
Also available in: Atom PDF Tracking page