Ted Leung on the air
Ted Leung on the air: Open Source, Java, Python, and ...
Ted Leung on the air: Open Source, Java, Python, and ...
Thu, 18 Sep 2003
StAX + XMLBeans == Java XML APIs
Eliotte Rusty Harold has an XML.com article on
StAX. It's a good introduction to this style of API.
He didn't like the use of integer type codes, preferring to have objects. I view StAX as a replacement for SAX, which is basically the bottom of the stack for XML processing API's. You can use SAX or StAX to build trees or beans or whatever you like. So any performance penalty that you impose on StAX is something you've imposed on everybody above you in the food chain, and there's no way to get that performance back if you need it. I think that they did the right thing here. The performance of reflection is never going to match integer comparison. Also, Andy Clark, the author of NekoPull is a member of the expert group as well.
As noted, the state management is much easier than SAX -- it allows you to write a more recursive-descent style of object construction. One of the problems with SAX is that it's very hard to use it to create objects in a way that allows you to reuse the objects and the SAX handler for building those objects. StAX makes that go away.
In many cases what you want is an easy to manipulate representation of the XML data. This is very frequently a Java Bean. So what you really want is an API that takes an XML stream, and gives me back the right Java Bean. And that's what XMLBeans is all about.
So in my view of the Java XML API world, there's StAX at the bottom, and on top of that you have XMLBeans. If you need to do weird document editing tree stuff, then there's StAX at the bottom, and on top of that there's the DOM or XOM or JDOM or whatever. But for most applications that I've worked on, the combination of StAX and XMLBeans would cover it. If you look at the XMLBeans Roadmap, you'll see that one of the goals is to support StAX (JSR 173), which would mean one stop shopping, er, downloading. My hope is that as XMLBeans evolves we'll be able to have a simple to use library.
[01:06] |
[computers/programming/xml] |
# |
TB |
F |
G |
2 Comments |
I'm curious, would a pull based API be more difficult to build XML pipelines than push based (i.e. event driven) APIs?
Posted by Carlos E. Perez at Thu Sep 18 05:53:28 2003
Posted by Carlos E. Perez at Thu Sep 18 05:53:28 2003
Hi Carlos,
I think that it will be more inconvenient to build pipelines with StAX. That's probably the one case where SAX has an advantage. Stefano will probably smack me, but that particular case isn't a high runner use case in my experience. But I know it is for others. Thanks for asking/bringing this up.
Posted by Ted Leung at Thu Sep 18 12:02:38 2003
I think that it will be more inconvenient to build pipelines with StAX. That's probably the one case where SAX has an advantage. Stefano will probably smack me, but that particular case isn't a high runner use case in my experience. But I know it is for others. Thanks for asking/bringing this up.
Posted by Ted Leung at Thu Sep 18 12:02:38 2003
You can subscribe to an RSS feed of the comments for this blog:
Add a comment here:
You can use some HTML tags in the comment text:
To insert a URI, just type it -- no need to write an anchor tag.
Allowable html tags are:
You can also use some Wiki style:
URI => [uri title]
<em> => _emphasized text_
<b> => *bold text*
Ordered list => consecutive lines starting spaces and an asterisk
To insert a URI, just type it -- no need to write an anchor tag.
Allowable html tags are:
<a href>
, <em>
, <i>
, <b>
, <blockquote>
, <br/>
, <p>
, <code>
, <pre>
, <cite>
, <sub>
and <sup>
.You can also use some Wiki style:
URI => [uri title]
<em> => _emphasized text_
<b> => *bold text*
Ordered list => consecutive lines starting spaces and an asterisk