Re: Are there any tools which generates Java code to reading XML
files?
Robbo quoted or indirectly quoted someone who said :
I would be glad, if you could tell me, what is the reason
for existing of SAXParserFactory, since there are better
(faster in coding) solutions?
'SAXParserFactory' exists for the purpose of enabling "applications to
configure and obtain a SAX based parser to parse XML documents", as
you would know if you read its Javadocs.
Roedy Green wrote:
Even if it were utterly useless compared with the alternatives, it
would still have to exist to support legacy apps.
And of course, it's far from useless.
An essay is in order to explain the advantages and disadvantages of
the various XML tools, and the circumstances under which you would
best choose each one.
If anyone wants to toss some ideas into the ring, I will compile them
for the entry athttp://mindprod.com/jgloss/xml.html
SAX parsing is superior to DOM parsing (by which I include all the
different DOM-based approaches) when you want to represent the
information from the XML document in some structure different from the
document structure or need really, really fast parsing. It's much,
much faster than DOM-based parsing because it pulls in the information
directly into your object model without the intermediate DOM
structure, in a single pass through the document, using much less
memory overall. It is good when you have a specific target object
structure for the information, and don't need or want XPath/XQuery or
equivalent means of access to the document structure. XPath and
XQuery can really slow an application down, especially as document
structures get large (approaching 1 GB).
As for DOM-based approaches being faster to code, I don't think that's
necessarily true. A project I was on last year had its development
slowed down horribly by its attempt to use DOM parsing. The documents
were quite large, and the geometric increase in processing time caused
by that was forcing all kinds of epicycles to try to improve things.
They'd have had a solution much faster if they'd used SAX (or StAX)
parsing.
--
Lew