Despite the wide adoption of the Document Object Model (DOM) and the Simple API for XML (SAX), enterprise developers face the numerous shortcomings of these technologies almost daily.
Tutorial Details:
My last JavaWorld article "Simplify XML Processing with VTD-XML" looked at three important benefits of VTD-XML: performance, memory usage, and ease of use. VTD-XML makes XML applications not only easier to write, but also leaner and faster. XML applications written in VTD-XML are 10 times more responsive when compared to the same applications written with the Document Object Model (DOM) and are capable of serving 10 times the workload, while maintaining the same quality of services for proportionally bigger XML messages.
However, parsing is often only part of what needs to be done in an XML-based application; many applications change the XML data as well. Consider the following three use-cases involving XML content updates:
1. An address-book application internally saves data into XML format, and the user wants to update the contact information (e.g., a phone number)
2. An XML-enabled content switch inspects the incoming and outgoing SOAP messages and selectively turns on the values of mustUnderstand attributes in the SOAP header
3. An SOA (service-oriented architecture) security application canonicalizes a subset of XML data for the subsequent signing and encryption, then inserts the digest and ciphered text back into XML payload
The double whammy of updating XML with DOM or SAX
Unfortunately, DOM and SAX (Simple API for XML) tax application performance twice when applying changes to XML. First with parsing, which is notoriously slow and CPU intensive; even worse is the reserialization needed to generate updated XML. Consider modifying the text content of the following XML snippet from "red" to "blue."
red
Using DOM, you would have to go through the following three steps:
1. Build the DOM tree
2. Navigate to and then update the text node
3. Write the updated structure back into XML
SAX and Pull are not even worth mentioning here since neither provides you with the liberty to navigate the tree structure. If the XML file size increases, writing out updated XML—effectively, many string concatenations, buffer allocations, and encoding conversions—further degrades overall application performance already constrained by slow parsing.
Read
Tutorial at: Click here to view the tutorial
Rate Tutorial: Cut, paste, split, and assemble XML documents with VTD-XML
View Tutorial: Cut, paste, split, and assemble XML documents with VTD-XML
Related
Tutorials:
Code generation using Javadoc - JavaWorld August
2000
Code generation using Javadoc - JavaWorld August
2000 |
XML document
processing in Java using XPath and XSLT - JavaWorld September 2000
XML document
processing in Java using XPath and XSLT - JavaWorld September 2000 |
Mapping XML to Java, Part 1 - JavaWorld August 2000
Mapping XML to Java, Part 1 - JavaWorld August 2000 |
Get the app out - JavaWorld January 2001
Get the app out - JavaWorld January 2001 |
Jato: The new kid on the open source block - JavaWorld March 2001
Jato: The new kid on the open source block - JavaWorld March 2001 |
XML APIs for databases - JavaWorld January 2000
XML APIs for databases - JavaWorld January 2000 |
Axis: The next generation of Apache SOAP
Axis: The next generation of Apache SOAP |
Generate JavaBean classes dynamically with XSLT
Generate JavaBean classes dynamically with XSLT |
XML glossary
XML glossary |
Yes, you can secure your Web services documents, Part 2
Yes, you can secure your Web services documents, Part 2 |
Publish and find UDDI tModels with JAXR and
WSDL
Publish and find UDDI tModels with JAXR and
WSDL |
Unwrap the package statement's
potential
Unwrap the package statement's
potential |
Joott Quick Start Guide
Joott Quick Start Guide
JooTemplates is a templating system to generate business documents, such as forms, mailings and reports. It is being developed with the following aims |
JSP 2.0: The New Deal, Part 3
JSP 2.0: The New Deal, Part 3
More Flexible JSP Document Format Rules
The JSP specification supports two types of JSP pages: regular JSP pages containing any type of text or markup, and JSP Documents, which are well-formed XML documents; i.e., docum |
JXMLPad 2.3
JXMLPad 2.3
JXMLPad is a pure Swing java component/framework for editing XML/XHTML document.
|
Wi.Ser (WidgetServer) unified rich client framework
Wi.Ser is a Java/XML server-side GUI-framework which enables an application to run as either a monolithic Swing application, a thin-client/server Swing application, or as a Web application without any change!
|
Parsing and Processing Large XML Documents with Digester Rules
Parsing and Processing Large XML Documents with Digester Rules
XML is commonly used for integration with third-party applications or web services, especially those that are running on non-Java platforms. On the other hand, if the code is running in a man |
JXMLPad 3.1 FC
JXMLPad is a pure Swing java component/framework for editing XML/XHTML document. |
Use Java to Interact with Your Clipboard
These days end users expect to use the ubiquitous "clipboard" concept as a transfer station for data, and if your applications don't support it, users won't be pleased. Learn how to use the java.awt.datatransfer package to cut, copy, and paste to a clipbo |
Strut your stuff with JSP tags
Learn how to use the custom tags from the open source Struts library and create extensions that ease the coding of properties associated with field values and user input validation. The Struts package is part of the open source Jakarta project. |
|
|
|