SAX is worse. By embedding the notion of structure, XML takes a giant step forward when compared to an unstructured format such as CSV. SAX takes a giant step backwards by forcing you to treat XML as CSV and, at the same time, bear the burden doing so.
And more harmful specs are in the current Web services stack, such as ones related to XML signing and encrypting. What is common among all bad standards? They kill your application performance and virtually guarantee you will fail to reach the performance requirement for your next SOA project. Just make sure that you know when to say no to them!
Keep things simple
XML is popular largely because it is so simple. Then why should it take page after page of documentation to learn how to program XML using DOM and SAX? Why so complicated? Remember the failed attempts of DCOM and CORBA? Is this déjà vu? Let's keep things simple; simple things usually work better than complicated ones. VTD-XML works so well because of its simplicity.
XML does not have a performance issue
The two oft-mentioned overheads of XML are verbosity and performance. While XML indeed takes up more space than CSV, it also is self-describing and more extensible. Is XML slow? No, it is not and has never been. VTD-XML is proof of that. The performance problem belongs to DOM and SAX. In other words, the so-called "XML bloat" is more suitably described as DOM's object bloat or SAX's code bloat, neither having anything to do with XML.
Object-oriented representation of XML is the problem
So why are DOM and SAX slow and ugly? Apparently, even people overcommitted to using objects to model XML are well aware of the performance impact of allocating a large number of objects. By the same token, treating XML as serialized Java objects (as in XML's Java binding) suffers from the same insurmountable performance overhead—a good thing to realize since the loose-coupling principle of XML/Web services precisely states that XML should not be treated as merely the serialization of Java objects.
The best has yet to come
As a broadly useful and advanced option that goes beyond DOM and SAX, VTD-XML has taken several big steps in the right direction. But the best is about to get better. VTD-XML has more ground-breaking features that will most certainly push the efficiency of XML to a new height never before thought possible. So please stay tuned.
Learn more about this topic
- Download the code samples that accompany this article
- "Simplify XML Processing with VTD-XML," Jimmy Zhang (JavaWorld, March 2006)
- For more articles on SOAs, browse the Web Services and SOAs section of JavaWorld's Topical Index
- For more articles on working with XML, browse the Java and XML section of JavaWorld's Topical Index