http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Home

Readme
Charter
Release Info

Installation
Download

FAQs
Samples
API Docs

Features
Properties

XML Schema
Caveats
Feedback
Y2K Compliance

Source Repository
User Mail Archive
Dev Mail Archive

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:

  1. open up a MS-DOS command line window
  2. set the path to the jdk\bin directory
  3. change directory to the latest xerces-1_4_4 directory
  4. 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 
NoteParse your own XML file instead of data/personal.xml

DOMCount
 

To run DOMCount:

  1. open up a MS-DOS command line window
  2. set the path to the jdk\bin directory
  3. change directory to the latest xerces-1_4_4 directory
  4. 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
NoteParse your own XML file instead of data/personal.xml


Copyright © 1999-2005 The Apache Software Foundation. All Rights Reserved.