Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Discover RELAX NG, A Simple Schema Solution : Page 4

With the goals of compact syntax and compatibility, the Regular Language Description for XML (RELAX NG) eases the pain of working with cumbersome DTDs and XSDs.




Application Security Testing: An Integral Part of DevOps

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.


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?

Raghu Donepudi, an independent contractor, currently is a technical manager for a federal government agency. He has a master's degree in Computer Science from Lamar University in Texas. He is a Sun-certified Java developer and the author of many software design techniques.
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date