background image

StAX API

<< Comparing StAX to Other JAXP APIs | Iterator API >>
<< Comparing StAX to Other JAXP APIs | Iterator API >>
S
T
AX API
81
Table 4­1 synopsizes the comparative features of StAX, SAX, DOM, and TrAX
(table adapted from "Does StAX Belong in Your XML Toolbox?"
(
http://www.developer.com/xml/article.php/3397691
) by Jeff Ryan).
StAX API
The StAX API exposes methods for iterative, event-based processing of XML
documents. XML documents are treated as a filtered series of events, and infoset
states can be stored in a procedural fashion. Moreover, unlike SAX, the StAX
API is bidirectional, enabling both reading and writing of XML documents.
The StAX API is really two distinct API sets: a cursor API and an iterator API.
These two API sets explained in greater detail later in this chapter, but their main
features are briefly described below.
Cursor API
As the name implies, the StAX cursor API represents a cursor with which you
can walk an XML document from beginning to end. This cursor can point to one
thing at a time, and always moves forward, never backward, usually one infoset
element at a time.
Table 4­1 XML Parser API Feature Summary
Feature
StAX
SAX
DOM
TrAX
API Type
Pull, streaming
Push, streaming
In memory tree
XSLT Rule
Ease of Use
High
Medium
High
Medium
XPath Capability
No
No
Yes
Yes
CPU and Memory Efficiency
Good
Good
Varies
Varies
Forward Only
Yes
Yes
No
No
Read XML
Yes
Yes
Yes
Yes
Write XML
Yes
No
Yes
Yes
Create, Read, Update, Delete
No
No
Yes
No