Leonidas-from-XIV/node-xml2js — pull request #46 by salsita (2012-02-07 19:08:06+00:00)
Title: Support for schema-driven generation

We've been using this code and ran into the problem that arrays in the source XML are not generated as arrays unless they contain more than one item. We solved this by using a JSON schema for our data types to drive the generation. In this way we can handle arrays and other data types (e.g. integers) properly. We can also perform validation (e.g. to make sure that required properties are included).

This feature requires this rather small change to your code. The validator support is generic so any type of schema metadata could be used (XML schema, DTD, simple list of array properties, etc.). I've written a validator for JSON schema that we are using (see https://github.com/salsita/xml2js-schema).

I'm interested to know what you think about this approach. If you agree that this feature makes sense I'll continue to improve the JSON schema support (and probably rewrite the validator in CoffeeScript).