Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

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.


advertisement

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?



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.

 

 

Sitemap