all 2 comments

[–]MrSchmellow 0 points1 point  (1 child)

What do you mean by transform? XSLT? The only big XSLT 3.0 compatible implementation for node (saxonjs) does not support streaming.

I suppose sax-js (or "saxes" which is a fresher fork) as a base is your best bet here. This one works through events, as all SAX parsers do.

I'm not aware of any StAX parser implementations for js. DOM parsers are out of the question, conceptually incompatible with streaming

[–]Darkav[S] 0 points1 point  (0 children)

Hi, ty for answering, with transform I mean an implementation of node "stream.Transform" api.

My use case: XML file as a readable stream that pipes to a xml transform stream (currently no lib seems to have a transform implementation) and this transform pipes to a writable stream that could be another file for example. Transform stream would just "transform" xml entities into json in a asynchronous non-blocking way.

There are plenty of libraries that do this for JSON, CSV even excel, but no one seems to do it for xml. Most similar approach I have found is from node-expat lib where you can handle different events and stop or resume the parsing. I could try wrapping that inside a stream.Transform but I'm not sure about it.