background image

4. Streaming API for XML

<< The factoryMethod | Streaming Versus DOM >>
<< The factoryMethod | Streaming Versus DOM >>
77
4
Streaming API for XML
T
his chapter focuses on the Streaming API for XML (StAX), a streaming
Java-based, event-driven, pull-parsing API for reading and writing XML docu-
ments. StAX enables you to create bidrectional XML parsers that are fast, rela-
tively easy to program, and have a light memory footprint.
StAX provides is the latest API in the JAXP family, and provides an alternative
to SAX, DOM, TrAX, and DOM for developers looking to do high-performance
stream filtering, processing, and modification, particularly with low memory and
limited extensibility requirements.
Note: To synopsize, StAX provides a standard, bidirectional pull parser interface
for streaming XML processing, offering a simpler programming model than SAX
and more efficient memory management than DOM. StAX enables developers to
parse and modify XML streams as events, and to extend XML information models
to allow application-specific additions. More detailed comparisons of StAX with
several alternative APIs are provided below, in "Comparing StAX to Other JAXP
APIs.
"
Why StAX?
The StAX project was spearheaded by BEA with support from Sun Microsys-
tems, and the JSR 173 specification passed the Java Community Process final
approval ballot in March, 2004 (
http://jcp.org/en/jsr/detail?id=173
).
The primary goal of the StAX API is to give "parsing control to the programmer