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

F

Frank

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
 
A

Aleksander Straczek

Frank wrote:
[cut]
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.
Have you tried dom4j? http://www.dom4j.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top