Running SAXCount and DOMCount

 

SAXCount and DOMCount are sample programs that can be used to invoke the parser on an XML document, and to print out interesting information about the XML document.. By default, invoking SAXCount will create a non-validating SAX parser, and will count the number of elements, attributes, text characters, and ignorable whitespace characters in the document. SAXCount also displays the amount of time it took to complete its entire task. The command lines below expect the current directory to be the directory containing the JAR file.

Requirements:

  • XML4J is loaded on your computer
  • JDK is loaded on your computer.

Source code:

SAXCount

 

To run SAXCount:

  1. open up a msdos command line window
  2. set the path to the jdk\bin directory
  3. change directory to the latest xml4j directory
  4. invoke the SAXCount parser

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 xml4j directories are located directly below the c: dirve.

set path=c:\jdk1.1.8\bin;%PATH%
set classpath=c:\xml4j_2_0_13\xml4j.jar;%CLASSPATH%
set classpath=c:\xml4j_2_0_13\xml4jSamples;%CLASSPATH%
cd c:\xml4j_2_0_13
java sax.SAXCount data\personal.xml

Switches:

SAXCount 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:
              com.ibm.xml.parsers.SAXParser [default parser]
              com.ibm.xml.parsers.ValidatingSAXParser
  • -h Print SAXCount help information. [default is no help]

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 com.ibm.xml.parsers.SAXParser
        data\personal.xml

Bringing up the help information:

    java sax.SAXCount -h

Note: Parse your own XML file instead of data\personal.xml

DOMCount

 

To run DOMCount:

  1. open up a msdos command line window
  2. set the path to the jdk\bin directory
  3. change directory to the latest xml4j directory
  4. invoke the DOMCount parser

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 xml4j directories are located directly below the c: dirve.

set path=c:\jdk1.1.8\bin;%PATH%
set classpath=c:\xml4j_2_0_13\xml4j.jar;%CLASSPATH%
set classpath=c:\xml4j_2_0_13\xml4jSamples;%CLASSPATH%
cd c:\xml4j_2_0_13
java dom.DOMCount data\personal.xml

Switches:

DOMCount also allows you to change the default behavior via the following command line flags (type this in as one long command line):

  • -p Specify the parser class to be used. The available parsers are:
              dom.wrappers.NonValidatingDOMParser
              dom.wrappers.DOMParser [default parser]
              dom.wrappers.TXParser
  • -h Print DOMCount help information. [default is no help]

Running DOMCount with the default settings is equivalent to running DOMCount like this:

    java dom.DOMCount -p dom.wrappers.DOMParser
        data\personal.xml

Bringing up the help information:

    java dom.DOMCount -h

Note: Parse your own XML file instead of data\personal.xml

Return to Parsers