Re: [Sax-devel] Should I use sax?
Brought to you by:
dmegginson
From: Chris B. <d0...@hu...> - 2006-05-23 08:53:12
|
David Megginson wrote: > On 22/05/06, Michael Glavassevich <mrg...@ca...> wrote: >> If you're writing new code, I would avoid using Xerces' native >> serializers. They are non-standard, not particularly well =20 >> maintained and >> likely to be deprecated [1] soon (perhaps in the next release). =20 >> JAXP's >> TransformerHandler [2] is a much better choice for serializing SAX =20= >> events. > > Speaking of new code, I should mention that another option is to use > StAX instead of SAX. Like SAX, StAX is a streaming API, so in theory, > it should be as efficient as SAX (I haven't run side-by-side tests). > However, since StAX is a pull parser, it leaves you in control of the > central loop instead of having to write event handlers. Here's an > intro: > > http://www.xml.com/pub/a/2003/09/17/stax.html > > StAX also covers writing. Does anyone know how stable and efficient > current StAX implementations are? The GNU Classpath default XML parser implementation is entirely based =20= on an underlying StAX parser. The SAX parser pulls events off this =20 StAX parser and delivers them as SAX events, and DOM trees are built =20 from this. This parser implementation is used in nearly all free Java runtimes =20 including gcj, kaffe, jamvm, cacao etc, and gets a lot of exercise in =20= free (gcj compiled-to-native) Eclipse, which makes extensive use of XML. Regarding efficiency, the SAX-over-StAX parser, despite delegating to =20= another implementation, takes approximately 48 seconds to parse a =20 typical set of documents that takes 60 seconds to parse with =C3=86lfred2.= =20 The same set of documents takes 42 seconds to parse with Xerces2's =20 SAX parser. I don't have straightforward comparison figures with =20 other StAX implementations like codehaus; I would suspect that it is =20 not as performant but is more conformant - attention to XML and SAX =20 conformance was the driving force behind this parser, and conformance =20= results can be found at http://builder.classpath.org/xml/SAXTest/ --=20 =E7=8A=AC Chris Burdess "They that can give up essential liberty to obtain a little safety deserve neither liberty nor safety." - Benjamin Franklin |