RELAX NG Pluggable Datatype Libraries

A vendor-independent Java interface for RELAX NG datatype libraries has been developed by James Clark and KAWAGUCHI Kohsuke. RELAX NG datatype libraries should be interchangeable between RELAX NG validators that support this interface. The interface is hosted at SourceForge in the relaxng project and documentation.

In particular, the Jing validator now supports this interface.

The interface allows validators to find datatype libraries dynamically at run-time. In order for a validator to be able to find a datatype library:

This will only work with JDK 1.2 or greater. It will not work with JDK 1.1.

This package contains a very simple example of a datatype library. The datatype library is implemented by the class com.thaiopensource.datatype.sample.BalancedString. The bulk of the implementation is inherited from the abstract class com.thaiopensource.datatype.sample.SimpleDatatypeLibrary, which provides default implementations for the methods in the interfaces which a datatype library must implement. A class that derives from SimpleDatatypeLibrary has only to implement a boolean isValid(String literal) method. The datatype library has the URI http://www.thaiopensource.com/relaxng/datatypes/sample, and contains exactly one datatype, which is called balancedString. This datatype allows any string in which parentheses are properly balanced (nested). To use this sample datatype library, simply include datatype-sample.jar in your CLASSPATH. You will then be able to validate against schemas using this additional datatype. The file datatype-sample.rng is a simple RELAX NG schema using this datatype; valid.xml is an instance that is valid with respect to this schema; invalid.xml is an instance that is not valid with respect to this schema.

James Clark