background image

StAX Use Cases

<< Pull Parsing versus Push Parsing | StAX-Enabled Clients >>
<< Pull Parsing versus Push Parsing | StAX-Enabled Clients >>

StAX Use Cases

A StAX pull parser can filter XML documents such that elements unnecessary to the client
can be ignored, and it can support XML views of non-XML data.
StAX Use Cases
The StAX specification defines a number of use cases for the API:
Data binding
Unmarshalling an XML document
Marshalling an XML document
Parallel document processing
Wireless communication
SOAP message processing
Parsing simple predictable structures
Parsing graph representations with forward references
Parsing WSDL
Virtual data sources
Viewing as XML data stored in databases
Viewing data in Java objects created by XML data binding
Navigating a DOM tree as a stream of events
Parsing specific XML vocabularies
Pipelined XML processing
A complete discussion of all these use cases is beyond the scope of this chapter. Please refer to
the StAX specification for further information.
Comparing StAX to Other JAXP APIs
As an API in the JAXP family, StAX can be compared, among other APIs, to SAX, TrAX, and
JDOM. Of the latter two, StAX is not as powerful or flexible as TrAX or JDOM, but neither does
it require as much memory or processor load to be useful, and StAX can, in many cases,
outperform the DOM-based APIs. The same arguments outlined above, weighing the
cost/benefits of the DOM model versus the streaming model, apply here.
Why StAX?
Chapter 18 · Streaming API for XML
551