Java & J2EE Page 13 - Integrating XML with J2EE |
DOM is a useful API allowing you to build and transform XML documents in memory. Unfortunately, DOM is somewhat slow and resource hungry. To address these problems, the Java Architecture for XML Binding (JAXB) has been developed through the Java Community Process (JCP) with an expert group consisting of representatives from many commercial organizations. JAXB provides a mechanism that simplifies the creation and maintenance of XML-enabled Java applications. It does this by using an XML schema compiler (only DTDs and a subset of XML schemas and namespaces at the time of this writing) that translates XML DTDs into one or more Java classes, thereby removing the burden from the developer to write complex parsing code. The generated classes handle all the details of XML parsing and formatting, including code to perform error and validity checking of incoming and outgoing XML documents, which ensures that only valid, error-free XML is accepted. Because the code has been generated for a specific schema, the generated classes are more efficient than those in a generic SAX or DOM parser. Most important, a JAXB parser often requires a much smaller footprint in memory than a generic parser. Classes created with JAXB do not include tree-manipulation capability, which is one factor that contributes to the small memory footprint of a JAXB object tree. If you want to build an object representation of XML data, but need to get around the memory limitations of DOM, you should use JAXB. These following two bulleted lists summarize the advantages of JAXB and JAXP so you can decide which one is right for your application. Use JAXB when you want to
Use JAXP when you want to
blog comments powered by Disqus |