background image

Streaming XML Parser Implementation

<< Using XMLEventWriter | Example Code >>
<< Using XMLEventWriter | Example Code >>

Streaming XML Parser Implementation

Sun's Streaming XML Parser Implementation
Application Server includes Sun Microsystems' JSR 173 (StAX) implementation, called the Sun
Java Streaming XML Parser (referred to as Streaming XML Parser). The Streaming XML Parser
is a high-speed, non-validating, W3C XML 1.0 and Namespace 1.0-compliant streaming XML
pull parser built upon the Xerces2 codebase.
In Sun's Streaming XML Parser implementation, the Xerces2 lower layers, particularly the
Scanner and related classes, have been redesigned to behave in a pull fashion. In addition to the
changes in the lower layers, the Streaming XML Parser includes additional StAX-related
functionality and many performance-enhancing improvements. The Streaming XML Parser is
implemented in the appserv-ws.jar and javaee.jar files, both of which are located in the
as-install/lib/ directory.
Included with this Java EE tutorial are StAX code examples, located in the
tut-install/javaeetutorial5/examples/stax/ directory, that illustrate how Sun's Streaming
XML Parser implementation works. These examples are described in
"Example Code" on
page 567
.
Before you proceed with the example code, there are two aspects of the Streaming XML Parser
of which you should be aware:
"Reporting CDATA Events" on page 566
"Streaming XML Parser Factories Implementation" on page 566
These topics are discussed below.
Reporting CDATA Events
The javax.xml.stream.XMLStreamReader implemented in the Streaming XML Parser does
not report CDATA events. If you have an application that needs to receive such events,
configure the XMLInputFactory to set the following implementation-specific
report-cdata-event
property:
XMLInputFactory factory = XMLInptuFactory.newInstance();
factory.setProperty(
"report-cdata-event", Boolean.TRUE);
Streaming XML Parser Factories Implementation
Most applications do not need to know the factory implementation class name. Just adding the
javaee.jar
and appserv-ws.jar files to the classpath is sufficient for most applications
because these two jars supply the factory implementation classname for various Streaming
XML Parser properties under the META-INF/services/ directory (for example,
javax.xml.stream.XMLInputFactory
, javax.xml.stream.XMLOutputFactory, and
javax.xml.stream.XMLEventFactory
).
Sun's Streaming XML Parser Implementation
The Java EE 5 Tutorial · September 2007
566