Using RELAX NG with JAXP


Put the latest jing to your classpath.

<dependency>
  <groupId>com.thaiopensource</groupId>
  <artifactId>jing</artifactId>
  <version>20091111</version> <!-- change this if updated -->
  <scope>test</scope> <!-- change this if your scope is different -->
</dependency>

RELAX NG

System.setProperty(
    SchemaFactory.class.getName() + ":" + XMLConstants.RELAXNG_NS_URI,
    "com.thaiopensource.relaxng.jaxp.XMLSyntaxSchemaFactory");
final SchemaFactory factory =
    SchemaFactory.newInstance(XMLConstants.RELAXNG_NS_URI);
final Schema schema = factory.newSchema(new File("schema.rng"));

RELAX NG Compact

System.setProperty(
    SchemaFactory.class.getName() + ":" + XMLConstants.RELAXNG_NS_URI,
    "com.thaiopensource.relaxng.jaxp.CompactSyntaxSchemaFactory");
final SchemaFactory factory =
    SchemaFactory.newInstance(XMLConstants.RELAXNG_NS_URI);
final Schema schema = factory.newSchema(new File("schema.rnc"));

See RELAX NG home page
See thaiopensource.com/relaxng


Thank you, Mr. James Clark.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s