Skip to main content

Validate XML using RELAX NG and JAXP 1.3.

Posted by kohsuke on February 10, 2006 at 7:23 PM PST

RELAX NG is a schema language for XML. It allows you to describe a structure of XML in a way much easier to read/write than W3C XML Schema, and it can be useful both for humans (to understand what XML is OK) and for programs (to mechanically determine if an XML is OK or not.)

Historically many good RELAX NG validators, like MSV or Jing, has been available through another validation API called JARV, which predates JAXP 1.3.

But since now JAXP 1.3 is available widely (in particular it's in J2SE 5.0), it would be really nice if one can use them through JAXP 1.3 validation API. So I wrote a little adapter layer so that I can use validators written for JARV through JAXP 1.3.

To use this, you don't have to know anything about JARV. Just put isorelax-jaxp-bridge.jar and a JARV implementation in your classpath, and write a program like this:

SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.RELAXNG_NS_URI);

The complete example is also available. For more about JAXP 1.3 validation API, see this.

Related Topics >>

Comments

Validate XML using RELAX NG

Hi,
The code is not working on Java 1.6.0. I read various comments and it seems there are some general modifications required in order to make it working. Do you have new version compatible with new Java (as the old one is not maintained any more) or could you please make necessary modifications in your code?
Thanks in advance
Maciej