Online Documentation Server
Net technology
Web technology
Data bases
Other docs



Вся предоставленная на этом сервере информация собрана нами из разных источников. Если Вам кажется, что публикация каких-то документов нарушает чьи-либо авторские права, сообщите нам об этом.

Xerces-C Samples

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 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.

Building the Samples for OS2

Building the Xerces-C samples using IBM Visual Age C++ Professional 4.0 for OS/2 (VAC++).

  • In the XercesCSrcInstallDir;\samples\Projects\OS2\VACPP40 directory, find and edit the VAC++ configuration file basedir.icc.
  • 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: SRC_DIR -- XercesCSrcInstallDir; This is where VAC++ should look to find the samples directories containing the source files. BASE_DIR -- The install directory XercesCSrcInstallDir;. VAC++ will store the compiled samples in the bin 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.
  • Save basedir.icc
  • Start the Command Line in the VAC++ folder.
  • Navigate to the XercesCSrcInstallDir;\samples\Projects\OS2\VACPP40 directory.
  • Run bldsamples.cmd
  • When build.cmd finishes, review the file compiler.errors. 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 PATH environment variable is set properly to pick up these shared libraries at runtime.

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:

export LIBPATH=xerces-c1_4_0/lib:$LIBPATH

Xerces-C Samples

  • SAXCount
    SAXCount counts the elements, attributes, spaces and characters in an XML file.
  • SAXPrint
    SAXPrint parses an XML file and prints it out.
  • DOMCount
    DOMCount counts the elements in a XML file.
  • DOMPrint
    DOMPrint parses an XML file and prints it out.
  • MemParse
    MemParse parses XML in a memory buffer, outputing the number of elements and attributes.
  • Redirect
    Redirect redirects the input stream for external entities.
  • PParse
    PParse demonstrates progressive parsing.
  • StdInParse
    StdInParse demonstrates streaming XML data from standard input.
  • EnumVal
    EnumVal shows how to enumerate the markup decls in a DTD Validator.
  • CreateDOMDocument
    CreateDOMDocument creates a DOM tree in memory from scratch.

Copyright © 2000 The Apache Software Foundation.All Rights Reserved.

With any suggestions or questions please feel free to contact us