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
 

Transform Legacy Data to XML Using JAXP

By writing to the JAXP specification, Java developers can create extensible code routines to parse any type of data into XML. This tutorial shows you how to write your own JAXP-compliant parser to transform legacy data in a comma-separated value (CSV) format, output it to a DOM, and then transform into XML.


advertisement


he ability to parse and transform XML documents is nothing new for Java developers. There are several packages available that come with the tools to do it. But these products all have incompatible implementations, so once you start using one package, you're locked in.Sun Microsystems has attacked this problem by creating interfaces for many different aspects of XML programming. One of the packaged interfaces Sun created is the Java API for XML Processing (JAXP), which is part of its early release XML pack. JAXP abstracts both XML parsing and transformations. Thus, writing your XML processing code using JAXP will make it portable to any other implementation that supports JAXP. As of this writing, the XML pack comes with Xerces2, XalanJ, and Crimson, which all support JAXP. Many people consider Apache's Xerces2 and XalanJ to be the de facto standards for Java XML processing anyway, so their support for JAXP is no surprise.

In this article I will show you how to create your own legacy data parser using JAXP. Why write a parser for a non-XML document using JAXP? I want to show how to transform a legacy data file into an XML document. By using JAXP to parse the file I will be able to create a DOM representation of it, which can then easily be transformed to XML.Later in the article, I will demonstrate a simple XML transformation using JAXP. I'll use the legacy data parser created in the first part of the article to transform a comma-separated value (CSV) file into an XML document. Because the transformation uses JAXP, the code will never have to change so long as the parser you use conforms to JAXP's interface.



Comment and Contribute

 

 

 

 

 


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

 

 

Sitemap