See the sample code in the test directory to quickly get up to speed. Run the sample as follows:
$ java -jar rngom-sample.jar <schema file>
RNGOM defines several interface sets through which applications interact with RNGOM.
RNGOM comes with a few default implementations of the above interface sets.
To use rngom.binary or rngom.digest packages, you need to have appropriate datatype library implementaions that implement the org.relaxng.datatype API. This typically means you'd want to have an XML Schema datatypes library implementation such as xsdlib.jar. By default, you just need to set classpath to include this jar and that should work. To customize this process, refer to javadoc.
The RELAX NG spec defines a series of "restrictions" that correct RELAX NG schemas have to follow. To check those, change your following normal code:
Parseable parseable = ...; YourParsedPattern = (YourParsedPattern)parseable.parse(schemaBuilder);
... to the following:
import org.kohsuke.rngom.ast.util.CheckingSchemaBuilder; Parseable parseable = ...; YourParsedPattern = (YourParsedPattern)parseable.parse(new CheckingSchemaBuilder(schemaBuilder,errorHandler));
See its javadoc for more details. Doing this guarantees that your application will reject all the incorrect schemas.
For better or worse, James Clark didn't leave much comment in his code, so you are more than welcome to contribute javadoc on those interfaces :-)
The abovementioned sample program prints out the callbacks and their parameters, so try it to learn about how the callbacks are called.
If you can require JDK 5.0 as your runtime environment, use rngom.jar instead of rngom-1.3.jar. This is a generified version of RNGOM that provides additional type safety.
To use RNGOM with JDK 1.3 or later, redistribute jax-qname.jar, rngom-1.3.jar, and relaxngDatatype.jar. You also need the JAXP API and an implementation.
To use RNGOM with JDK 1.4 or later, the list is the same except that you don't need to have a JAXP API nor its implementation (because the JRE has one already)
To use RNGOM with JDK 5.0 or later, just redistribute rngom.jar and relaxngDatatype.jar.