I'm having trouble importing SaxonJS to NodeJS application.
const saxonJs = require("saxon-js");
console.log(Object.getOwnPropertyNames(saxonJs));
// [ ]
console.log(Object.getOwnPropertyNames(window.SaxonJS));
/**
[
'atom', 'Atomic',
'transform', 'Serializer',
'serialize', 'StringWriter',
'getProcessorInfo', 'getResource',
'setLogLevel', 'getLogLevel',
'setPlatform', 'getPlatform',
'getNavigator', 'timeStamp',
'internalTransform', 'checkOptions',
'makeAtomicValue', 'getItemDetails',
'XdmArray', 'XdmFunction',
'XdmMap', 'U',
'XError', 'XPath',
'XS', 'Developer'
]
*/
const testOutput = saxonJs.transform({
stylesheetFileName: xslt_filepath,
sourceFileName: source_filename,
destination: 'raw',
});
// returns TypeError: saxonJs.transform is not a function
window.SaxonJS.transform({
stylesheetFileName: xslt_filepath,
sourceFileName: inputFiles[j],
destination: 'raw',
});
// XError: Cannot supply stylesheetFileName in browser
returns TypeError: saxonJs.transform is not a function
what is going on?
saxon-js
, it seems that main file being imported is actuallySaxonJSN.js
. Could you be kind to explain howSaxonJSN.js
determine whether it is running from browser or node.js? I'm running the code insidejest
testing framework to transform xml and validate them with expected output. Perhaps it's something I need to configure from testing framework. – Katlynkatmai