Installing a SAX Parser

To run a Java SAX-capable parser, you need the following installed on your computer:

  • A Java Software Development Kit, version 1.1 or higher.

  • A SAX2-compatible XML parser installed on your Java CLASSPATH.

  • A SAX2 distribution on your Java CLASSPATH. This would likely be included with the SAX2-compatible XML parser.

Installing the JSDK

You might already have a JSDK installed. If not, you can download a JSDK from http://java.sun.com/j2se/. The URL gives you access to information about the Standard Edition of Java—j2se.

You can check if you have a JSDK installed by searching for a file named javac.exe. If javac.exe is present, you have a JSDK (formerly called a JDK) installed. Up to Java version 1.3, you might find javac.exe in a directory named something like c:jdk1.3.1in. In Java 2 version 1.4, you will find it in a directory named something like c:j2sdk1.4in.

Download the JSDK appropriate to your operating system and install it according to the instructions supplied by Sun.

Take note of the exact name of the directory that you install the JSDK into. You will add that to your computer’s path environment variable in a moment.

Installing the Xerces Parser

Information about the Java version of the Xerces 2 XML parser is located at http://xml.apache.org/xerces2-j/index.html. From the Downloads link, select the latest stable version of the Xerces-J parser appropriate to your operating system.

When the download has completed, install the Xerces-J parser to a directory. We installed Xerces-J in c:Xerces-J2.0.2.

Setting path and CLASSPATH Environment Variables

Your computer needs to be capable of locating the Java programs and the Xerces parser.

The directory into which you installed the JSDK must be added to the path environment variable. In Windows 2000, go to the Control Panel and select the System option. The System Properties window should open. Select the Advanced tab. Click the Environment Variables button halfway down the page. Scroll down the list of System Variables until the path variable is highlighted. Click the Edit button. A window will open with the current value of the path variable.

Your current path might be something like this:

c:WINNTsystem32;c:WINNT 

You need to add the directory where the JSDK is installed. In my case, the JSDK is in c:j2sdk1.4.0in, so that is added to the existing value of the path variable, separated by a semicolon from the existing value.

						c:WINNTsystem32;c:WINNT;c:j2sdk1.4.0in 

Caution

Check if another Java installation already exists in the path variable. If so, you might want to simply use that. Having more than one Java installation specified in the path environment variable is a recipe for problems.



If you have done no Java programming on your computer, you will likely have to create a new CLASSPATH environment variable. Otherwise, edit the existing CLASSPATH environment variable to add c:Xerces-J2.0.2 (or the directory you installed Xerces in) to it, separated by a semicolon from any existing paths.

Tip

If you don’t want to permanently change environment variables, create a short batch file that will set the path and CLASSPATH variables from the command line.



You also need to add the Xerces-J version 2 jar files to the CLASSPATH— xercesImpl.jar and xmlParserAPIs.jar.

Now that we’ve discussed a number of issues about how to use SAX, let’s move on and use a Java example to illustrate the basics of how SAX can be used.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset