XML-Xerces

 view release on metacpan or  search on metacpan

docs/forrest-docs/src/documentation/content/xdocs/samples/domprint.xml  view on Meta::CPAN

 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
-->

<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd"
[
<!ENTITY % PROJECT-ENTITIES PUBLIC
   "-//Xerces-P//Xerces-P ENTITIES V1.0//EN//XML"
   "project-entities.ent">
%PROJECT-ENTITIES;
]>
<document> 
  <header> 
    <title>&PROJECT_NAME; Sample: DOMPrint</title> 
  </header> 
  <body> 


<section>
<title>Sample: DOMPrint</title>

    <section>
<title>DOMPrint</title>
        <p>DOMPrint parses an XML file, constructs the DOM tree, and
		   invokes DOMWriter::writeNode() to serialize the resultant 
		   DOM tree back to XML stream.
		</p>

        <section>
<title>Running DOMPrint</title>

          <p>The DOMPrint sample parses an XML file, using either a validating
		  or non-validating DOM parser configuration, builds a DOM tree,
		  and then invokes DOMWriter::writeNode() to serialize the
		  resultant DOM tree. To run DOMPrint, enter the following:</p>
<source>perl DOMPrint.pl &lt;XML file&gt;</source>
          <p>The following parameters may be set from the command line </p>
<source>
Usage:
 perl DOMPrint.pl [options] &lt;XML file&gt;

This program invokes the DOM parser, and builds the DOM tree
It then asks the DOMWriter 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.
-->
    -h          Show this help
  * = Default if not provided explicitly.

The parser has intrinsic support for the following encodings:\n"
    UTF-8, USASCII, ISO8859-1, UTF-16[BL]E, UCS-4[BL]E,\n"
    WINDOWS-1252, IBM1140, IBM037, IBM1047.\n"
</source>
          <p><em>-v=always</em> will force validation<br/>
             <em>-v=never</em>  will not use any validation<br/>
             <em>-v=auto</em>   will validate if a DOCTYPE declaration or a schema declaration is present in the XML document</p>
          <p>Here is a sample output from DOMPrint</p>
<source>cd samples
perl DOMPrint.pl -v=always personal.xml

&lt;?xml version="1.0" encoding="iso-8859-1"?&gt;

&lt;!DOCTYPE personnel SYSTEM "personal.dtd"&gt;
&lt;!-- @version: --&gt;
&lt;personnel&gt;

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

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

&lt;person id="two.worker"&gt;
  &lt;name&gt;&lt;family&gt;Worker&lt;/family&gt; &lt;given&gt;Two&lt;/given&gt;&lt;/name&gt;
  &lt;email&gt;two@foo.com&lt;/email&gt;
  &lt;link manager="Big.Boss"&gt;&lt;/link&gt;
&lt;/person&gt;

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

&lt;person id="four.worker"&gt;
  &lt;name&gt;&lt;family&gt;Worker&lt;/family&gt; &lt;given&gt;Four&lt;/given&gt;&lt;/name&gt;
  &lt;email&gt;four@foo.com&lt;/email&gt;
  &lt;link manager="Big.Boss"&gt;&lt;/link&gt;
&lt;/person&gt;

&lt;person id="five.worker"&gt;
  &lt;name&gt;&lt;family&gt;Worker&lt;/family&gt; &lt;given&gt;Five&lt;/given&gt;&lt;/name&gt;
  &lt;email&gt;five@foo.com&lt;/email&gt;
  &lt;link manager="Big.Boss"&gt;&lt;/link&gt;



( run in 1.588 second using v1.01-cache-2.11-cpan-39bf76dae61 )