Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an XSD validator for Node.js

I need to validate XML in a node.js application.I have found this, but it's basically a java plugin, and despite the excellent pun making opportunities, I would prefer not to use Java in my JavaScript. So is there a native node module that can validate XML based on an XSD schema? (1.1 compatibility very much preferred)

like image 890
mr23ceec Avatar asked Nov 10 '22 22:11

mr23ceec


1 Answers

there have neen some new developments since you originally asked:

  • https://github.com/libxmljs/libxmljs provides a javascript wrapper for libxml, though it does require some building/binding using node-gyp.
  • https://www.npmjs.com/package/xmllint is basically an Emscripten javascript port of libxml2's xmllint code.
  • another out-of-the-box solution to consider is translating the XSD to a JSON schema, translating the XML to JSON, and then running JSON validation. Though this has more steps and can be more error prone.

Hope this helps!

like image 195
RocketMan Avatar answered Nov 14 '22 23:11

RocketMan