- Clone
- yarn install to get dependencies
- yarn compile to generate sef file (if you change the .xsl file)
- node index.js to run the example.
Node v14.10.0, Win10 64
Without changes:
(base) PS C:\dev\random\saxonjs-global-examples\01-global-functions> node .\index.js
Transformation failure: ReferenceError: window is not defined
(node:7172) UnhandledPromiseRejectionWarning: ReferenceError: window is not defined
at Object.window (C:\dev\random\saxonjs-global-examples\01-global-functions\node_modules\saxon-js\SaxonJS2N.js...)
....
at C:\dev\random\saxonjs-global-examples\01-global-functions\node_modules\saxon-js\SaxonJS2N.js:5463:480
at async start (C:\dev\random\saxonjs-global-examples\01-global-functions\index.js:23:33)
Now open index.js and uncomment these lines:
global["window"] = {extensionFunction};
New result:
$ node .\index.js
INPUT: <root></root>
OUTPUT: <?xml version="1.0" encoding="UTF-8"?><result>Hello from JavaScript</result>