Project

Profile

Help

Bug #5761

closed

fn:transform called from XPath with simplified stylesheet gives error XTTE0590 in XSLT-SEF-compiler.xsl: "Required cardinality of value of parameter $stylesheet-base-uri is exactly one; supplied value is empty"

Added by Martin Honnen about 2 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
XX compiler
Sprint/Milestone:
Start date:
2022-12-11
Due date:
% Done:

100%

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

Description

While testing whether SaxonJS supports the simplified stylesheet module syntax I found that it seems to work when using xslt3 from the command line but when I try to use fn:transform from the XPath API (i.e. SaxonJS.XPath.evaluate) I get an error XTTE0590 in XSLT-SEF-compiler.xsl: "Required cardinality of value of parameter $stylesheet-base-uri is exactly one; supplied value is empty".

Sample code:

const SaxonJS = require('saxon-js');

const xml = `<expense-report>
  <total>2500</total>
</expense-report>`;

const xslt = `<html xsl:version="3.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Expense Report Summary</title>
  </head>
  <body>
    <p>Total Amount: <xsl:value-of select="expense-report/total"/></p>
  </body>
</html>`;

const result = SaxonJS.XPath.evaluate(`
  transform(map {
    'stylesheet-text' : $xslt,
    'source-node' : parse-xml($xml),
    'delivery-format' : 'serialized'
  })?output
`,
  null,
  {  params : { xml : xml , xslt : xslt } }
);

console.log(result);

Complete error output:

C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4390
push:function(h,H,Q){if("undefined"===typeof Q)throw ob.Sa(Error().stack,1,H.fixed.Ha),new L("No output for "+m(h));if(t[h.N]){var c=e(h);try{c(H,Q)}catch(n){throw n instanceof L&&!n.xsltLineNr&&nb(n,h),n;}}else{c=Xd.elaborate(h);try{for(var d=c(H),l;null!=(l=d.next());)Q.append(l)}catch(n){throw n instanceof L&&!n.xsltLineNr&&nb(n,h),n;}}},Vi:g,Kf:r,gh:q}}();var We=function(){function a(O,ja,aa,z,A){function F(G){return null===n.La(G)}function I(G){return G.nodeType===E.nodeType&&(null===R?!0:n.$(G).equals(R))}var V=A.fixed.evaluator;if(ja){var E=V.evaluate(ja,A).next();if(!E||!n.O(E))throw new L("xsl:number/@select must yield a single node","XTTE1000");}else A.failIfNoCurrentFocus("XTTE0990","xsl:number"),E=A.getCurrentFocus();var R=n.$(E),K=I;if(null!==aa){var ea=Be.ld(aa);K=function(G){return Be.matches(ea,G,A)}}if(null===z)ja=F;else{var ha=Be.ld(z);

                                      ^
Error
    at new L (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4109:549)
    at B (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4618:172)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4618:473
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4594:373
    at Array.forEach (<anonymous>)
    at Object.y [as lf] (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4594:276)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4375:408
    at Object.push (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4390:143)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4600:290
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4618:382
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4670:281
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4386:258
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4358:33
    at Array.forEach (<anonymous>)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4358:6
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4386:309
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4358:33
    at Array.forEach (<anonymous>)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4358:6
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4378:287
    at q (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4361:439)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4378:255
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4358:33
    at Array.forEach (<anonymous>)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4358:6
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4379:17
    at Object.push (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4390:143)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4600:290
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4386:258
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4358:33
    at Array.forEach (<anonymous>)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4358:6
    at Object.push (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4390:143)
    at e.hf (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4976:4)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4973:289
    at wc.ca.forEachItem (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4206:583)
    at e.Bb (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4973:256)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4376:8
    at Object.push (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4390:143)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4600:290
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4618:382
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4670:281
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4386:258
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4358:33
    at Array.forEach (<anonymous>)
    at Array.<anonymous> (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4358:6)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4377:237
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4386:309
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4358:33
    at Array.forEach (<anonymous>)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4358:6
    at Object.push (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4390:143)
    at e.hf (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4976:4)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4973:289
    at wc.ca.forEachItem (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4206:583)
    at e.Bb (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4973:256)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4376:8
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4358:33
    at Array.forEach (<anonymous>)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4358:6
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4379:17
    at Object.push (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4390:143)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4600:290
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4386:258
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4358:33
    at Array.forEach (<anonymous>)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4358:6
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4386:309
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4386:309
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4386:309
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4358:33
    at Array.forEach (<anonymous>)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4358:6
    at Object.push (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4390:143)
    at e.hf (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4976:4)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4973:289
    at wc.ca.forEachItem (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4206:583)
    at e.Bb (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4973:256)
    at Object.e [as internalTransform] (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4989:102)
    at aa (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4566:27)
    at transform (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4575:119)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4632:444
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4646:463
    at Object.I [as evaluate] (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4600:203)
    at Object.evaluate (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4936:362)
    at Object.<anonymous> (C:\Users\marti\OneDrive\Documents\xslt\blog-xslt-3-by-example\simplified-stylesheet\test-input1-xslt1.js:18:30)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47 {
  message: 'Required cardinality of value of parameter $stylesheet-base-uri is exactly one; supplied value is empty',
  name: 'XError',
  code: 'XTTE0590',
  xsltLineNr: '372',
  xsltModule: 'XSLT-SEF-compiler.xsl'
}

I don't have to set a stylesheet base URI or change anything in the JavaScript code, as soon as I provide a normal stylesheet module as xslt the code works fine. So somehow the simplified stylesheet module does not work when used with the XPath API and fn:transform as shown above.

Actions #1

Updated by Norm Tovey-Walsh over 1 year ago

This is certainly an interesting one. I'm not (personally) a huge fan of simplified stylesheet modules, but they ought to work. And the reason why they don't is a very mysterious case where a tunnel parameter goes missing. It doesn't look like there's any reason why it shouldn't work. The XX compiler is prepared for the case and does the right thing, but then, like I said, the tunnel parameter for $stylesheet-base-uri goes AWOL.

Actions #3

Updated by Norm Tovey-Walsh over 1 year ago

  • Status changed from New to Resolved
  • Applies to JS Branch Trunk added
  • Fix Committed on JS Branch Trunk added

This turned out to be a simple error in the way the $stylesheet-base-uri is being used as a tunnel parameter in the XX compiler.

Actions #4

Updated by Norm Tovey-Walsh about 1 year ago

  • Fix Committed on JS Branch 2 added

Patch applied to saxonjs2 branch as well

Actions #5

Updated by Debbie Lockett about 1 year ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in JS Release set to SaxonJS 2.6

Bug fix applied in the SaxonJS 2.6 maintenance release.

Please register to edit this issue

Also available in: Atom PDF Tracking page