[jdom-interest] StAX support

Michael Kay mike at saxonica.com
Mon Nov 14 08:25:51 PST 2011

 >JDOM is about making XML handling easy, philosophically JDOM should 
make it easy to work with what you have, and, if that happens to be a 
StAX source/sink, then it should be easy to feed that in to (out of) 

I think there's a need to identify use cases.

If people are starting with lexical XML and want to build a JDOM 
representation of it, then they don't care what kind of parser is used.

If they have some source of StAX events and want to build a JDOM 
representation of it, then that's a potential use case; but I'm not sure 
it's a very convincing one because most products/components that want to 
output XML prefer to push it rather than making it available to be 
pulled; the reason for that is the same as the justification for StAX in 
the first place:  programmers like to own the main control loop, which 
means they like to pull their input and push their output.

(From that perspective, supporting the StAX push interfaces would 
actually make more sense than supporting the StAX pull interface, 
because if you want to output XML, sending it to a StAX XMLStreamWriter 
is much easier than sending it to a SAX ContentHandler. However, SAX is 
so entrenched as the canonical push API that XMLStreamWriter isn't going 
to displace it any time soon.)

Another factor here is JDK 1.5. StAX isn't present in JDK 1.5 by 
default, so any use of it in a product designed to work with JDK 1.5 is 
going to cause a configuration hassle.

Michael Kay

More information about the jdom-interest mailing list