Question

I'd like to do RelaxNG (preferred) or XSD (if I have to) schema validation in client-side JavaScript. Any good libraries for this? Google finds jsrelaxngvalidator but I'm having trouble getting it running and it seems unmaintained. Target browsers are Firefox and Chrome only.

Was it helpful?

Solution

SmartClient can load an XSD and generate a form for editing the data, complete with validation rules and user friendly error messages:

http://www.smartclient.com/#xmlSchemaImport

You can also serialize the data that the user inputs and produce an XML document that conforms to the XSD (correctly namespaced and all that) using DataSource.xmlSerialize().

http://www.smartclient.com/docs/8.0/a/b/c/go.html#method..DataSource.xmlSerialize

This functionality is all implemented in the browser (no server component) and is all in the free OSS version (SmartClient LGPL).

Note this particular feature is part of a much larger system that may or may not fit your needs - SmartClient is primarily for large scale enterprise business applications.

OTHER TIPS

The answer seems to be "No": we got jsrelaxngvalidator working in the end, but it has bizarre restrictions on what it supports, requires lots of libraries to run (incl. a custom SAX parser also in beta) and does weird stuff like downloading 18 XSLTs over the wire to preprocess the schemas, so we gave up it.

Instead, I rewrote the schema as JSON Schema, with client-side validation using JSV. The learning curve was a bit steep, but it's working nicely now.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top