RELAX NG in Java
The JAXB libraries in the Java Web Services Developer Pack (Java WSDP) 1.5 include functionality for RELAX NG. JAXB 1.5 provided the initial support for RELAX NG grammar.
The example "publicHolidays.rng" in the downloadable code for this article provides the schema for a list of public holidays in US. The following tags specify the package name to be used for the Java classes generated by JAXB:
<jaxb:schemaBindings>
<jaxb:package name="publicHoliday"/>
</jaxb:schemaBindings>
After JAXB generates the Java files, you compile them. In the example code, the RELAXNGExample parses the sample XML file and prints the contents. Independence Day is incorrectly defined as June 4th in the sample publicHoliday.xml file. RELAXNGExample corrects the date within the Java code by setting the month to July, revalidates it, and prints the new contents to the screen.
RELAX NG and JAXB: Simple XML
JAXB makes parsing and loading XML files into Java applications simple; RELAX NG makes defining the XML schemas easy. Use RELAX NG and JAXB in your next enterprise Java application. Why wait, when it's so
simple and easy?