Project

Profile

Help

Bug #5430

closed

Use of deliverResultDocument in SaxonJS.transform options causes error "Unsupported result-document destination undefined"

Added by Martin Honnen 3 months ago. Updated about 2 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
API
Sprint/Milestone:
Start date:
2022-03-28
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

As reported on Slack, the use of deliverResultDocument with Saxon-JS (tested with2.3 and Node.js 14) can give an error "Unsupported result-document destination undefined".

The JavaScript code I have tried is

const path = require('path');

var urlModule = require('url');

const baseURI = urlModule.pathToFileURL(path.join(path.resolve('.'), 'foo.xml'));

console.log(`baseURI: ${baseURI.href}`);

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

var options = {
  'stylesheetLocation' : 'sheet1.sef.json',
  'sourceLocation' : 'input1.xml',
  'destination' : 'serialized',
  'baseOutputURI' : baseURI.href,
  'deliverResultDocument': function(uri) {
     return {
       'destination' : 'serialized',
       'save' : function(resultUri, result, encoding) {
          console.log(resultUri, result);
        }
     };
   }
};

SaxonJS.transform(options); //SaxonJS.transform(options, 'sync');

console.log(options.principalResult);

When I run that (sef.json and input sample are attached) I get

baseURI: file:///C:/Users/marti/some-path/some-dir/foo.xml

C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4167
c;c=c.actor;c.C&&F(c)(L,d)}},valueOf:function(h){var L=Wd.Oa(h),d={};Wd.Bb(h,"d")&&(d.DISABLE_ESCAPING=!0);return function(c,k){c=l(L(c));k.text(c,d)}}};return{Pg:w,elaborateForPush:e,getComplexContentOutputter:function(h){return new a(h)},push:function(h,L,d){if("undefined"===typeof d)throw rb.lb(Error().stack),new K("No output for "+m(h));if(r[h.N]){var c=e(h);try{c(L,d)}catch(n){throw n instanceof K&&!n.xsltLineNr&&nb(n,h),n;}}else{c=Wd.elaborate(h);try{for(var k=c(L),q;null!=(q=k.next());)d.append(q)}catch(n){throw n instanceof



                         ^
Error
    at new K (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:3887:513)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4436:297
    at L (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4135:641)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4164:69
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4136:33
    at Array.forEach (<anonymous>)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4136:6
    at Object.push (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4167:370)
    at e.uf (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4745:502)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4743:284
    at wc.ba.forEachItem (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:3985:583)
    at e.Ib (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4743:251)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4741:414
    at Object.u [as rj] (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4139:435)
    at SC (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4741:310)
    at e.uf (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4746:72)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4743:284
    at wc.ba.forEachItem (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:3985:583)
    at e.Ib (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4743:251)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4741:414
    at Object.u [as rj] (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4139:294)
    at SC (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4741:310)
    at e.uf (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4746:72)
    at e.Qk (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4744:70)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4165:171
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4136:33
    at Array.forEach (<anonymous>)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4136:6
    at Object.push (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4167:370)
    at e.uf (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4745:502)
    at C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4743:284
    at wc.ba.forEachItem (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:3985:583)
    at e.Ib (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4743:251)
    at e (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4758:179)
    at t (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4761:137)
    at Object.transform (C:\Users\marti\AppData\Roaming\npm\node_modules\saxon-js\SaxonJS2N.js:4781:375)
    at Object.<anonymous> (C:\Users\marti\OneDrive\Documents\xslt\blog-xslt-3-by-example\saxon-js-xsl-result-document-uri-tests\runTransformSyncCaptureResultsExplicitly1.js:26:9)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
    at internal/main/run_main_module.js:17:47 {
  message: 'Unsupported result-document destination undefined',
  name: 'XError',
  code: 'XXXX9999',
  xsltLineNr: '15',
  xsltModule: 'sheet1.xsl'
}

Files

input1.xml (71 Bytes) input1.xml Martin Honnen, 2022-03-28 23:25
runTransformSyncCaptureResultsExplicitly1.js (740 Bytes) runTransformSyncCaptureResultsExplicitly1.js Martin Honnen, 2022-03-28 23:25
sheet1.sef.json (6.54 KB) sheet1.sef.json Martin Honnen, 2022-03-28 23:25
sheet1.xsl (876 Bytes) sheet1.xsl Martin Honnen, 2022-03-28 23:25

Please register to edit this issue

Also available in: Atom PDF Tracking page