DOMPrint

Building DOMPrint

On Windows Platforms:

Load the <xml4c2InstallDir>\ samples\Projects\Win32\VC6\samples.dsw Microsoft Visual C++ workspace inside your MSVC IDE. Then build the project marked DOMPrint.

On UNIX (AIX, Solaris, HP-UX, Linux):

Make sure you have set your environment variable ROOTDIR to point to the top-most directory where you installed XML4C.

cd <xml4c2InstallDir>/samples/Projects/ <platform>
make -f DOMPrint.mak COMPILESWITCH="-w -O"

where <platform> is the platform you are working on.This will create the object files in the <xml4c2InstallDir>/bin/obj/DOMPrint directory and the executable named DOMPrint in '<xml4c2InstallDir>/bin' directory. If the 'bin' or 'obj/DOMPrint' directories do not exist then the build will fail. In that case you need to create the missing directory(s) under '<xml4c2InstallDir>' directory.

To delete the object and executable files of DOMPrint:

    cd <xml4c2InstallDir>/samples/Projects/<platform>
    make clean -f DOMPrint.mak

This would delete all the object files (.o files) from your 'obj/DOMPrint' sample directory and the executable from '<xml4c2InstallDir>/bin' directory.

Running DOMPrint

The DOMPrint sample parses an XML file, using either a validating or non-validating DOM parser configuration, builds a DOM tree, and then walks the tree and outputs the contents of the nodes in 'a' canonical format. To run DOMPrint, enter the following:

    domprint [-v] <filename>

The -v option is used when you wish to use a validating parser. Here is a sample output for DOMPrint when the validating parser is used:

    cd <xml4c2InstallDir>/samples/data
    domprint -v personal.xml

 

<?xml version='1.0' encoding='utf-8?>
<!-- Revision: 63 1.7 samples/data/personal.xml, xml4c2Docs, xml4c2, xml4c2_1_0_d2 -->
<personnel>

  <person id="Big.Boss">
    <name><family>Boss</family> <given>Big</given></name>
    <email>chief@foo.com</email>
    <link subordinates="one.worker two.worker three.worker four.worker five.worker"></link>
  </person>

  <person id="one.worker">
    <name><family>Worker</family> <given>One</given></name>
    <email>one@foo.com</email>
    <link manager="Big.Boss"></link>
  </person>

  <person id="two.worker">
    <name><family>Worker</family> <given>Two</given></name>
    <email>two@foo.com</email>
    <link manager="Big.Boss"></link>
  </person>

  <person id="three.worker">
    <name><family>Worker</family> <given>Three</given></name>
    <email>three@foo.com</email>
    <link manager="Big.Boss"></link>
  </person>

  <person id="four.worker">
    <name><family>Worker</family> <given>Four</given></name>
    <email>four@foo.com</email>
    <link manager="Big.Boss"></link>
  </person>

  <person id="five.worker">
    <name><family>Worker</family> <given>Five</given></name>
    <email>five@foo.com</email>
    <link manager="Big.Boss"></link>
  </person>

</personnel>

Note that DOMPrint does not reproduce the original XML file. Also DOMPrint and SAXPrint produce different results because of the way the two APIs store data and capture events.

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