Sun’s Streaming XML Parser Implementation (original) (raw)
2. Using the Tutorial Examples
3. Getting Started with Web Applications
5. JavaServer Pages Technology
7. JavaServer Pages Standard Tag Library
10. JavaServer Faces Technology
11. Using JavaServer Faces Technology in JSP Pages
12. Developing with JavaServer Faces Technology
13. Creating Custom UI Components
14. Configuring JavaServer Faces Applications
15. Internationalizing and Localizing Web Applications
16. Building Web Services with JAX-WS
17. Binding between XML Schema and Java Classes
Pull Parsing versus Push Parsing
Comparing StAX to Other JAXP APIs
Choosing between Cursor and Iterator APIs
Comparing Cursor and Iterator APIs
Resources, Namespaces, and Errors
Error Reporting and Exception Handling
Returning String Representations
Building and Running the Cursor Example Using NetBeans IDE
Building and Running the Cursor Example Using Ant
Instantiating an XMLEventAllocator
Building and Running the Cursor-to-Event Example Using NetBeans IDE
Building and Running the Cursor-to-Event Example Using Ant
Building and Running the Event Example Using NetBeans IDE
Building and Running the Event Example Using Ant
Implementing the StreamFilter Class
Building and Running the Filter Example Using NetBeans IDE
Building and Running the Filter Example Using Ant
Creating an Event Producer/Consumer
Building and Running the Read-and-Write Example Using NetBeans IDE
Building and Running the Read-and-Write Example Using Ant
Building and Running the Writer Example Using NetBeans IDE
Building and Running the Writer Example Using Ant
Further Information about StAX
19. SOAP with Attachments API for Java
21. Getting Started with Enterprise Beans
23. A Message-Driven Bean Example
24. Introduction to the Java Persistence API
25. Persistence in the Web Tier
26. Persistence in the EJB Tier
27. The Java Persistence Query Language
28. Introduction to Security in the Java EE Platform
29. Securing Java EE Applications
31. The Java Message Service API
32. Java EE Examples Using the JMS API
36. The Coffee Break Application
37. The Duke's Bank Application
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.
Before you proceed with the example code, there are two aspects of the Streaming XML Parser of which you should be aware:
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 theXMLInputFactory 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).
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:
javax.xml.stream.XMLInputFactory --> com.sun.xml.stream.ZephyrParserFactory javax.xml.stream.XMLOutputFactory --> com.sun.xml.stream.ZephyrWriterFactor javax.xml.stream.XMLEventFactory --> com.sun.xml.stream.events.ZephyrEventFactory
Copyright © 2010, Oracle and/or its affiliates. All rights reserved. Legal Notices