Building the Samples
Xerces-C comes packaged with ten sample applications that
demonstrate salient features of the parser using simple
applications written on top of the SAX and DOM APIs provided by
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
The installation process for the samples is same on all UNIX
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.
Building the Samples for OS2
Building the Xerces-C samples using IBM Visual Age C++ Professional 4.0
for OS/2 (VAC++).
- In the
find and edit the VAC++ configuration file
- All of the directories used to build the samples are defined in
basedir.icc. You need to edit the directories to match your system.
Here are the directories you need to assign:
This is where VAC++ should look to find the samples
directories containing the source files.
BASE_DIR -- The install directory
VAC++ will store the compiled samples in the
directory under BASE_DIR. It will also look for the
xerces-c.lib file in the
lib directory under BASE_DIR.
Other directories are set based on these two. You can choose to override them
if you wish.
- Start the Command Line in the VAC++ folder.
- Navigate to the
build.cmd finishes, review the file
This file should contain only informational messages, almost all complaining about constant
values in comparisons.
- You should now have several executable files.
Rebuilding the Configuration Files
Although it shouldn't be necessary, if you want to rebuild the VAC++
configuration files, you'll need to have Object Rexx running on your system:
- If you are not currently running Object Rexx, run the SWITCHRX command from
a command line, answer "yes" to switching to Object Rexx, and follow the
instructions to reboot. (Note: You can switch back to "Classic Rexx" by
running SWITCHRX again. But you probably won't need to switch back since
Object Rexx runs almost 100% of Classic Rexx programs.)
- In the Projects\OS2\VACPP40 directory, run genICC.cmd. This builds the VAC++
configuration files for the samples you have on your system.
- Go to the first step above in the "Building asmples for OS/2" section.
Running the Samples
The sample applications are dependent on the Xerces-C shared library
(and could also depend on the ICU library if you built Xerces-C with ICU).
Therefore, on Windows platforms you must make sure that your
environment variable is set properly to pick up these shared libraries at
On UNIX platforms you must ensure that LIBPATH
environment variable is set properly to pick up the shared libraries at
runtime. (UNIX gurus will understand here that LIBPATH actually
translates to LD_LIBRARY_PATH on Solaris and Linux, SHLIB_PATH on HP-UX
and stays as LIBPATH on AIX).
To set you LIBPATH (on AIX for example), you would type:
SAXCount counts the elements, attributes, spaces and
characters in an XML file.
SAXPrint parses an XML file and prints it out.
DOMCount counts the elements in a XML file.
DOMPrint parses an XML file and prints it out.
MemParse parses XML in a memory buffer, outputing the number of elements and attributes.
Redirect redirects the input stream for external entities.
PParse demonstrates progressive parsing.
StdInParse demonstrates streaming XML data from standard input.
EnumVal shows how to enumerate the markup decls in a DTD Validator.
CreateDOMDocument creates a DOM tree in memory from scratch.
Copyright © 2000 The Apache Software Foundation.All Rights Reserved.