1.7. Installing a SAX2 ParserUnless you use JDK 1.4 (which bundles SAX2 and the Crimson parser) or some other environment that's already set up with SAX2 support (such as any up-to-date web application server), you will need to update your Java programming environment so that you can use SAX. Consult the documentation that comes with your parser and Java Virtual Machine for specific details. Assuming the SAX interfaces and your SAX parser are distributed in a single JAR file called xml.jar (you'll need to know and use the correct full pathname, including the directory), you'll probably use one of these approaches shown in the following list.
You may end up with a variety of SAX2 parsers in your environment. Sometimes which parser you use will be important, but you should avoid creating such problems. See Section 3.2, "Bootstrapping an XMLReader" in Chapter 3, "Producing SAX2 Events" for information about making sure you're using a particular parser; there are several mechanisms, including setting system properties and adding META-INF/services/ resources to your class path. If you work within some application environment (perhaps a web server), you may want to look for specialized configuration mechanisms. Also, if you have SAX1 support in your environment, you can easily upgrade it; see Section 5.2, "SAX1 Support " in Chapter 5, "Other SAX Classes". Note that because SAX lets applications hand character streams to parsers with java.io.Reader, you can't use JDK 1.0 with SAX. You need JDK 1.1, which is a more complete and stable release in any case. Since the Java environments that aren't based on Sun's code generally treat JDK 1.1 as the conformance target,[7] that should cause no real trouble. SAX itself doesn't require more recent APIs, but some of the tools you use with SAX might have such requirements. For portability, the example code in this book avoids use of APIs added in JDK 1.2 and later. The main impact of this restriction is that in a few cases you'll be able to get minor performance improvements by using the collections APIs.
Copyright © 2002 O'Reilly & Associates. All rights reserved. |
|