http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Xerces Project

Overview
Charter
Release Info
Advisories
Download

Xerces-C++ 3.1.2
Installation
Build Instructions

Programming
Samples
FAQs

API Reference
DOM C++ Binding
Migration Guide

Feedback
Bug-Reporting
Mailing Lists

Source Repository
Applications

DOMPrint
 

DOMPrint parses an XML file, constructs the DOM tree, and invokes DOMLSSerializer::write() to serialize the resultant DOM tree back to XML stream.

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 invokes DOMLSSerializer::write() to serialize the resultant DOM tree. To run DOMPrint, enter the following:

DOMPrint <XML file>

The following parameters may be set from the command line

Usage:
 DOMPrint [options] <XML file>

This program invokes the DOM parser, and builds the DOM tree
It then asks the DOMLSSerializer to serialize the DOM tree.

Options:
    -e          create entity reference nodes. Default is no expansion.
    -v=xxx      Validation scheme [always | never | auto*].
    -n          Enable namespace processing. Default is off.
    -s          Enable schema processing. Default is off.
    -f          Enable full schema constraint checking. Defaults is off.
    -wenc=XXX   Use a particular encoding for output. Default is
                the same encoding as the input XML file. UTF-8 if
                input XML file has not XML declaration.
    -wfile=xxx  Write to a file instead of stdout.
    -wscs=xxx   Enable/Disable split-cdata-sections.      Default on.
    -wddc=xxx   Enable/Disable discard-default-content.   Default on.
    -wflt=xxx   Enable/Disable filtering.                 Default off.
    -wfpp=xxx   Enable/Disable format-pretty-print.       Default off.
    -wbom=xxx   Enable/Disable write Byte-Order-Mark      Default off.
    -?          Show this help
  * = Default if not provided explicitly.

The parser has intrinsic support for the following encodings:\n"
    UTF-8, US-ASCII, ISO8859-1, UTF-16[BL]E, UCS-4[BL]E,\n"
    WINDOWS-1252, IBM1140, IBM037, IBM1047.\n"

-v=always will force validation
-v=never will not use any validation
-v=auto will validate if a DOCTYPE declaration or a schema declaration is present in the XML document

Here is a sample output from DOMPrint

cd xerces-c-3.1.2/samples/data
DOMPrint -v=always personal.xml

<?xml version="1.0" encoding="iso-8859-1"?>

<!DOCTYPE personnel SYSTEM "personal.dtd">
<!-- @version: -->
<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. DOMPrint and SAXPrint produce different results because of the way the two APIs store data and capture events.

Application needs to provide its own implementation of DOMErrorHandler (in this sample, the DOMPrintErrorHandler), if it would like to receive notification from the serializer in the case any error occurs during the serialization.

Application needs to provide its own implementation of DOMLSSerializerFilter (in this sample, the DOMPrintFilter), if it would like to filter out certain part of the DOM representation, but must be aware that thus may render the resultant XML stream invalid.

Application may choose any combination of characters as the end of line sequence to be used in the resultant XML stream, but must be aware that this may render the resultant XML stream ill formed.

Application may choose a particular encoding name in which the output XML stream should be, but must be aware that if unrepresentable in the encoding specified characters appear in the markup, it may force the serializer to terminate serialization prematurely, and thus no complete serialization would be done.

Application shall query the serializer first, before set any feature/mode(true, false), or be ready to catch exception if this feature/mode is not supported by the serializer.

Application needs to release the filter, error handler and format target objects created for the serialization.




Copyright © 1999-2015 The Apache Software Foundation. All Rights Reserved.