JAXP - perhaps beauty is only in the eye of the beholder

From: Frank (none_at_nospam.org)
Date: 11/22/04


Date: Mon, 22 Nov 2004 01:27:51 GMT

Hello folks,

I've written a couple applications now that have been able to utilize JAXP
to do a little processing with XML documents, and obtain some results. The
problem seems to be that these programs feel like haphazard contraptions
of code (implementing the correct interfaces, extending the right classes,
and spawning the correct inner classes) just to parse a simple document.
Now, my first couple apps with an unfamiliar language or API will be ugly
- I *expect* that. But cleaning up after an app using JAXP? I'm not seeing
it..

Some of the people I've spoken with have commented that many people prefer
DOM over SAX, not because they need to be able to manipulate the document
or even access random parts of the document, but because the API for DOM
is more intuitive than that for SAX. The second strike against SAX: I have
yet to even find a way to simply append data to the Document root using
SAX. It seems all modifications to a document require a contorted muddling
about with a Transformer, and must inevitably be passed off to a DOM
structure.

On top of that, the only two XML parsers that ever seem to be documented
(in detail at least) are SAX and DOM. One that can't allow any mutibility
to the document, and one that must load the entire document into RAM -
undesirable for large documents, or scenarios where the app will open the
document for long periods of time with infrequent modifications. I can
think of at least two other strategies that have varying trade-offs, but
do strike a middle ground.

I say all this. I'm considering writing my own XML parser library. But
before I dig in too deep... are there perhaps other parsers that have
already addressed the issues I've cited? As I'm thinking, I could design a
SAX parser - something that behaves kind of like an Iterator (though not
using that interface specifically), instead of some event dispatcher. It
just feels like working with JAXP is akin to flirting with a pretty
girl... until she smiles and reveals two missing front teeth. I'm not
calling it defective, but it makes you stop to question if you're
travelling down the right track.

Feedback appreciated,

Frank



Relevant Pages

  • Re: XML CDATA special characters
    ... I didn't mention SAX, is that the standard PHP parser I'm using now? ... I'll just dive into DOM now and see where this will all end up. ... basic XML only has 5 pre-defined default entities. ... If you try and use HTML ...
    (comp.lang.php)
  • Re: torture
    ... If you're using Java 1.4 then you already have an XML parser built in to ... manipulable object representation of the XML document in memory. ... The SAX API works by reading the document and generating callbacks to ...
    (comp.lang.java.programmer)
  • Re: XML CDATA special characters
    ... Simple Api for Xml (SAX) is indeed what PHP's inadequately named the ... "XML extension". ... implements that standard. ... >>DOM API and not the SAX API. ...
    (comp.lang.php)
  • Re: XML::Parser Style => Object
    ... >>deprecated now, in favour of SAX... ... XML::Parser is still useful as a basic XML parsing layer for other ... Perl, which might make it easier for people who don't have a compiler on ...
    (comp.lang.perl.misc)
  • XSLT output missing XML elements
    ... I'm using JAXP for XSLT - I'm using the examples from ... I'm using the following XML ... StreamSource xslSource = new StreamSource; ... Transformer transformer = template.newTransformer; ...
    (comp.text.xml)