














|
| |
Xerces-C comes packaged with nine 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.
Note that runConfigure is just a helper script and you are free to
use ./configure with the correct parameters to make it work
on any platform-compiler combination of your choice. The script needs the following parameters:
 |  |  |  |
Usage: runConfigure "options"
where options may be any of the following:
-p <platform> (accepts 'aix', 'linux', 'solaris', 'hp-10', 'hp-11')
-c <C compiler name> (e.g. gcc, xlc_r, cc or aCC)
-x <C++ compiler name> (e.g. g++, xlC_r, CC or aCC)
-d (specifies that you want to build debug version)
-h (get help on the above commands)
|  |  |  |  |
 | NOTE:The code samples in this section assume that you are are working on the Linux binary drop.
If you are using some other UNIX flavor, please replace '-linux' with the appropriate
platform name in the code samples. |
|
| |
SAXCount is the simplest application that counts the elements and characters of
a given XML file using the (event based) SAX API.
| |
Load the xerces-c-1_0-win32\samples\Projects\Win32\VC6\samples.dsw
Microsoft Visual C++ workspace inside your MSVC IDE. Then
build the project marked SAXCount.
|
|
| |
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.
| |
Load the xerces-c-1_0-win32\samples\Projects\Win32\VC6\samples.dsw
Microsoft Visual C++ workspace inside your MSVC IDE. Then
build the project marked SAXPrint.
|
|
| |
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).
| |
Load the xerces-c-1_0-win32\samples\Projects\Win32\VC6\samples.dsw
Microsoft Visual C++ workspace inside your MSVC IDE. Then
build the project marked DOMCount.
|
|
| |
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).
| |
Load the xerces-c-1_0-win32\samples\Projects\Win32\VC6\samples.dsw
Microsoft Visual C++ workspace inside your MSVC IDE. Then
build the project marked DOMPrint.
|
|
| |
MemParse uses the Validating SAX Parser to parse a memory buffer containing
XML statements, and reports the number of elements and attributes found.
| |
Load the xerces-c-1_0-win32\samples\Projects\Win32\VC6\samples.dsw
Microsoft Visual C++ workspace inside your MSVC IDE. Then
build the project marked MemParse.
|
|
| |
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.
| |
Load the xerces-c-1_0-win32\samples\Projects\Win32\VC6\samples.dsw
Microsoft Visual C++ workspace inside your MSVC IDE. Then
build the project marked Redirect.
|
|
| |
Demonstrates progressive parsing.
In this example, the programmer doesn't have to depend upon throwing
an exception to terminate the parsing operation. Calling parseFirst() will
cause the DTD to be parsed (both internal and external subsets) and any
pre-content, i.e. everything up to but not including the root element.
Subsequent calls to parseNext() will cause one more piece of markup to
be parsed, and spit out from the core scanning code to the parser. You
can quit the parse any time by just not calling parseNext() anymore
and breaking out of the loop. When you call parseNext() and the end
of the root element is the next piece of markup, the parser will
continue on to the end of the file and return false, to let you
know that the parse is done.
| |
Load the xerces-c-1_0win32\samples\Projects\Win32\VC6\samples.dsw
Microsoft Visual C++ workspace inside your MSVC IDE. Then
build the project marked PParse.
|
|
| |
Demonstrates streaming XML data from the standard input.
| |
Load the xerces-c-1_0-win32\samples\Projects\Win32\VC6\samples.dsw
Microsoft Visual C++ workspace inside your MSVC IDE. Then
build the project marked StdInParse.
|
|
| |
Shows how to enumerate the markup decls in a DTD Validator.
| |
Load the xerces-c-1_0-win32\samples\Projects\Win32\VC6\samples.dsw
Microsoft Visual C++ workspace inside your MSVC IDE. Then
build the project marked EnumVal.
|
|
|
|