SAX/DOMCount Samples

| Running SAXCount and DOMCount |
| SAXCount and DOMCount invoke the parser on an XML document, and print out information about the document. By default, SAXCount creates a non-validating SAX parser and DOMCount creates a validating DOM parser. They both count the number of elements, attributes, text characters, and ignorable whitespace characters in the document and display the amount of time it takes to complete the task. The command lines below expect the current directory to be the directory containing the JAR file. Requirements: Xerces-J is loaded on your computer. JDK is loaded on your computer. Source code: SAXCount.java DOMCount.java
| SAXCount |
| To run SAXCount: open up a MS-DOS command line window set the path to the jdk\bin directory change directory to the latest xerces-1_4_4 directory invoke the `SAXCount` sample On Windows: The easiest way to do this is to create a .bat file using the Notepad editor. Then the `SAXCount` can be invoked by double clicking on the file name or icon. The following command lines assume that both the jdk and the xerces-1_4_4 directories are located directly below the c: drive.
    set PATH=%PATH%;c:\jdk1.1.8\bin
    set CLASSPATH=%CLASSPATH%;c:\xerces-1_4_4\xerces.jar;c:\xerces-1_4_4\xercesSamples.jar
    cd c:\xerces-1_4_4
    java sax.SAXCount data/personal.xml
Switches: SAXCount also allows you to change the default behavior using the following command line flags: -p Specify the parser class to be used. The available parsers are: org.apache.xerces.parsers.SAXParser [default parser] -h Print SAXCount help information. [default is no help] -v Turn on validation Running SAXCount with the default settings is equivalent to running SAXCount like this (type this in as one long command line):
    java sax.SAXCount -p org.apache.xerces.parsers.SAXParser
        data/personal.xml
Bringing up the help information:
    java sax.SAXCount -h
| Parse your own XML file instead of data/personal.xml
| DOMCount |
| To run DOMCount: open up a MS-DOS command line window set the path to the jdk\bin directory change directory to the latest xerces-1_4_4 directory invoke the `DOMCount` sample On Windows: The easiest way to do this is to create a .bat file using the Notepad editor. Then the `DOMCount` can be invoked by double clicking on the file name or icon. The following command lines assume that both the jdk and the xerces-1_4_4 directories are located directly below the c: dirve.
    set PATH=%PATH%;c:\jdk1.1.8\bin
    set CLASSPATH=%CLASSPATH%;c:\xerces-1_4_4\xerces.jar;c:\xerces-1_4_4\xercesSamples.jar
    cd c:\xerces-1_4_4
    java dom.DOMCount data/personal.xml
Switches: DOMCount also allows you to change the default behavior via the following command line flags: -p Specify the parser class to be used. The available parsers are: dom.wrappers.DOMParser [default parser] -h Print DOMCount help information. [default is no help] Running DOMCount with the default settings is equivalent to running `DOMCount` like this (type this in as one long command line):
    java dom.DOMCount -p dom.wrappers.DOMParser
        data/personal.xml
Bringing up the help information:
    java dom.DOMCount -h
| Parse your own XML file instead of data/personal.xml

Copyright © 1999, 2000 The Apache Software Foundation. All Rights Reserved.