3

Is there any easy way to create XML based on XML schema in Node.js? Currently I see modules like xmlbuilder that does help in creating XML from scratch ( does not follow schema). I want something high level, based on XML schema /XSD which will help in creating xml. Like POJOs are created based on XSD and now easy to populate POJOs and then create XML.

Thanks for any hints...

1 Answer 1

2

I am the author of Jsonix which is a powerful schema-driven XML<->JS converter, working in Node.js as well as in browsers.

See this answer for a complete example:

Schema-driven means that you can take an XML Schema and generate Jsonix mappings out of it. You can then serialize your JSON data conforming to the original XML Schema or unmarshal XML in that schema. Jsonix considers types and structures of the schema.

Sign up to request clarification or add additional context in comments.

4 Comments

Wait, what? It requires Java?
@KeithTyler Jsonix - no, it's pure JavaScript. Jsonix Schema Compiler - yes.
Well, if I want to use jsonix to generate compliant XML based on a known schema, I'm dependent on the Java-based schema compiler. Any reason why jsonix can't just parse the xsd natively?
In the compile-time - yes, in the runtime - no. The reason for the Java dependency is that Jsonix Schema Compiler uses JAXB/XJC undeneath which is Java. It would be a huge effort to rewrite it in JS. And, frankly, I see no reason to do this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.