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.

Source code:

 

To run SAXCount with the default settings, use the following command line (all on one line):

    jre -cp xml4j.jar;xml4jSamples.jar
    sax.SAXCount data\personal.xml

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):

    jre -cp xml4j.jar;xml4jSamples.jar
        sax.SAXCount
        -p com.ibm.xml.parsers.SAXParser
        data\personal.xml

 

To run DOMCount with the default settings, use the following command line (all on one line):

    jre -cp xml4j.jar;xml4jSamples.jar
    dom.DOMCount data\personal.xml

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.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 (type this in as one long command line):

    jre -cp xml4j.jar;xml4jSamples.jar
        dom.DOMCount
        -p dom.wrappers.DOMParser
        data\personal.xml

Return to Samples