The only problem I’ve noticed with Java and SAX is that SAX is a “sequential construction” API whereas Java is a “one-shot fire-and-forget” system.
(This, incidentally, is one of the many areas where java is a bitch to write good library code, because only being allowed to do the constructor in a single method call is too restrictive for many real life cases.)
I would use DOM except that:
- names of classes and interfaces in API suck (irritatingly confusing)
- API is unwieldy (I struggle to believe that such a system had to have such a complex API)
- doesn’t SEEM (am I wrong here?) well-suited to debugging and sequential development
SAX is conceptually incredibly simple to use (indeed, the S stands for SIMPLE does it not?) and I find other coders who haven’t used it are able to view edit and maintain source with no learning curve (since it follows the traditional “recipe style” algorithm: you just write down what you want it to do sequentially, triggered off events).
OTOH Sun have shafted SAX a bit by providing an implementation in 1.4 which can’t handle exceptions properly (nb: try throwing a nullpointerexception in some SAX code, and see what exception the java runtime then reports. hint: it throws away all the info on what exception actually occurred and where, due to a bug in the exception chaining)
[yes, I did log the bug with Sun a looooong time ago (and they accepted it). I’m pretty sure that it’s still not fixed though…]