Sun's Streaming Parser Implementation

The JWSDP 1.6 includes an Early Access (EA) release of Sun Microsystem's JSR 173 (StAX) implementation, called the Sun Java Streaming XML Parser (SJSXP). The SJSXP 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 SJSXP 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 the lower layers, the SJSXP includes additional StAX-related functionality and many performance-enhancing improvements. The SJSXP is implemented in sjsxp.jar, which is located in the <JWSDP_HOME>/sjsxp/lib directory.

Included with this SJSXP EA distribution are code samples that illustrate how the implementation works. These samples are described in the Sample Code section, later in this chapter.

Before proceeding with the sample code, there are three important aspects of the SJSXP about which you should be aware:

These three topics are discussed below.


There are two JAR files in the SJSXP implementation. Both of these JARs are located in the <JWSDP_HOME>/sjsxp/lib directory:

Complete listings of the contents of these two JARs are provided in Appendix B, "SJSXP JAR Files."

Reporting CDATA Events

The implemented in the SJSXP 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); 

SJSXP Factories Implementation

Most applications do not need to know the factory implementation class name. Just adding the sjsxp.jar file to the classpath is sufficient for most applications because sjsxp.jar supplies the factory implementation classname for various SJSXP properties under the META-INF/services directory--for example,,, and is the third step of a lookup operation when an application asks for the factory instance. See the javadoc for the XMLInputFactory.newInstance() method for more information about the lookup mechanism.

However, there may be scenarios when an application would like to know about the factory implementation class name and set the property explicitly. These scenarios could include cases where there are multiple JSR 173 implementations in the classpath and the application wants to choose one, perhaps one that has superior performance, contains a crucial bug fix, or suchlike.

If an application sets the SystemProperty, it is the first step in a lookup operation, and so obtaining the factory instance would be fast compared to other options; for example: --> --> -->