NodeJS में SaxonJS
Sep 14 2020
मुझे SaxonJS को NodeJS एप्लिकेशन पर आयात करने में समस्या हो रही है।
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
रिटर्न TypeError: saxonJs.transform एक फ़ंक्शन नहीं है
क्या हो रहा है?
जवाब
MichaelKay Sep 14 2020 at 19:48
प्रयत्न
require('SaxonJS2N.js')
मुझे लगता है कि आपने Node.js संस्करण के बजाय सैक्सन-जेएस के ब्राउज़र संस्करण को उठाया है।