NodeJs XSLT Transformation
Asked Answered
L

2

12

I need to transform an XML document using XSLT in nodejs. I can’t seem to find a library for nodejs that is currently maintained and encompasses the full standard of XSLT.

Does anyone have any suggestions on a package or something in native nodejs to perform transformation?

Lavinia answered 14/8, 2019 at 13:22 Comment(2)
not xslt but i built a package for transforming xml to json via xpath template. you may want to check it out github.com/tuananh/camaroRosenbaum
Yeah I need to transform xml using xslt 2 into another xml format. Can’t use json.Lavinia
D
12

2020 Update

Saxon-JS 2 now supports XSLT 3.0 in Node.js and in the browser!


Former answer

Your only (pure JavaScript, XSLT standards compliant) hope is Saxon-JS, but it may not be entirely ready to run on Node.js yet:

Michael Kay reads Q/A here and may perhaps provide an update beyond what's listed in the above links.

Disbelieve answered 14/8, 2019 at 14:24 Comment(10)
@user3597741: How did you find Saxon to be overly complicated?Disbelieve
Well you multiple pieces. Saxon-ee and Saxon-js. And there are charges.Lavinia
Saxon-js is also not compatible with NodeJS. They are working on it but sounds far offLavinia
Charges: Professional developers do not hesitate to pay for tools; their time is worth orders of magnitude more. Compatible: I did say it may not be entirely ready to run on Node.js yet and provided several supporting references, some indicating third-party success with adaptations and several indicating intent and progress. Sorry not to have an ideal solution to tell you about right now.Disbelieve
Answer from Saxonica is that we're working on it. Currently passing about 99% of tests. But there's still some functionality we want to put in before we release (e.g. conformant HTML serialization) and some performance issues we want to iron out. Thanks for your patience.Francklyn
Saxon-JS 2 for Node.js is released today (12 June 2020) - package saxon-js on npm.Francklyn
@MichaelKay: That's great news! Congratulations on the major release and major accomplishment!!Disbelieve
@MichaelKay First of all thanks for this library! However, the documentation on using SaxonJS isn't clear enough to run it on NodeJS. Problem I've encounter was that importing the npm package using const SaxonJS = require('saxon-js'); didn't work. Although minified js file in node_module is hard to read, I was able to find that you are adding SaxonJS on window object. I think you need to update your documentation for nodejs users to indicate how to import SaxonJS in javascript file.Cud
@MichaelKay, saxon-js has not crashed a single time over about 100 calls. It also runs fast on the server. saxon-c for python crashes about 50% of the time. and won't even install on the (shared) server because the required C compiler is missing on that server. Are these different code bases? Is there a "saxon-js"y thing for python I should try out instead of saxon-c? Thanks!Jeanettajeanette
@Jeanettajeanette Please don't ask questions in the form of a comment on a three-year-old answer to a different question! Please raise a new question that's specific to your problem. Yes, SaxonC is a completely different code base to SaxonJS.Francklyn
F
1

encompasses the full standard of XSLT

could be treated as "compliant with browser implementation" in order to reuse XSLT as in browser as on server side. Native client side implementation could be significant denominator as speed and CPU load is level of magnitude is different in comparison with JS-based implementation.

https://www.npmjs.com/package/xslt-processor is promising cross-tier compatible implementation of XSLT 1.0.

Fadden answered 11/12, 2020 at 1:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.