Samples

XML4C2 comes packaged with six sample applications that demonstrate salient features of the parser using simple applications written on top of the SAX and DOM APIs provided by the parser.

Once you have set up your PATH variable, you can run the samples by opening a command window (or your shell prompt for UNIX environments). Sample XML data files are provided in the samples\data directory.

The installation process for the samples is same on all UNIX platforms. But we do have separate directories for each platform. In subsequent discussions the generic symbol <platform> is used. You have to substitute <platform> with 'AIX', 'SOLARIS', HPaCC, HPCC, Linux,  or whatever your platform is. A quick look at the Projects directory will tell you the platforms supported.

SAXCount

SAXCount is the simplest application that counts the elements and characters of a given XML file using the (event based) SAX API.

SAXPrint

SAXPrint uses the SAX APIs to parse an XML file and print it back. Notice that the output of this file is not exactly the same as the input (in terms of white spaces), but the output has the same information content as the input.

DOMCount

DOMCount uses the provided DOM API to parse an XML file, constructs the DOM tree and walks through the tree counting the elements (using just one API call).

DOMPrint

DOMPrint parses an XML file, constructs the DOM tree, and walks through the tree printing each element. It thus dumps the XML back (output same as SAXPrint).

Redirect

Redirect uses the SAX EntityResolver handler to redirect the input stream for external entities. It installs an entity resolver, traps the call to the external DTD file and redirects it to another specific file which contains the actual DTD.

MemParse

MemParse uses the Validating SAX Parser to parse a memory buffer containing XML statements, and reports the number of elements and attributes found.

Copyright (c) IBM Corp. 1999, Center for Java Technology, Cupertino, USA