<?xml version="1.0" standalone="no"?>
<!DOCTYPE s1 SYSTEM "./dtd/document.dtd">

<s1 title="Samples">

	<s2 title="Building the Samples">
	<p>&XercesPName; comes packaged with three sample applications that
	demonstrate salient features of the parser.</p>

	<p>You must build and install &XercesPName; before you can run the samples.
  	Also make sure that Perl, &XercesPName; and &XercesCName; are in your PATH.
	Sample XML data files that are used by the samples are provided in the samples
	directory.  It is recommended that you run the samples from this directory.</p>
	</s2>

	<s2 title="DOMCount">
		<s3 title="What it does">
		<p>DOMCount uses the DOM API to parse an XML file, constructs the
                  DOM tree and walks through the tree counting the elements (using just one API
                  call).</p>
		</s3>

		<s3 title="Running DOMCount">

		  <p>The DOMCount sample parses an XML file and prints out a count of the number of
		  elements in the file. To run DOMCount, enter the following </p>

<source>perl DOMCount.pl &lt;filename&gt;</source>

		  <p>To use the validating parser, use </p>

<source>perl DOMCount.pl -v &lt;filename&gt;</source>

		  <p>Here is a sample output from DOMCount</p>

<source>
cd &XercesPInstallDir;/samples
perl DOMCount.pl -v personal.xml
personal.xml: (37 elems)
</source>

		  <p>The output of both versions should be same.</p>

		</s3>

	</s2>




	<s2 title="DOMPrint">
		<s3 title="What it does">
		<p>DOMPrint parses an XML file, constructs the DOM tree, and walks through the
        	tree printing each element (back in the original XML syntax!).  DOMPrint uses
		DOM APIs and also uses additional Perl DOMPARSE utilities for walking parsed
		DOM trees.</p>
		</s3>


		<s3 title="Running DOMPrint">

		  <p>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:</p>

<source>
perl DOMPrint.pl [-v] &lt;filename&gt;
</source>

		  <p>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: </p>

<source>
cd &XercesPInstallDir;/samples
perl DOMPrint.pl -v personal.xml
</source>

		  <p>Here is a sample output from DOMPrint</p>

<source>
cd &XercesPInstallDir;/samples/data
DOMPrint -v personal.xml

&lt;?xml version='1.0' encoding='UTF-8' ?&gt;
&lt;!-- Revision: 63 1.7 samples/data/personal.xml, xml4c2Docs, xml4c2, xml4c2_3_2  --&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;/person&gt;
	&lt;person id="one.worker"&gt;
		&lt;name&gt;
			&lt;family&gt;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;/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>
		&lt;link manager="Big.Boss"/&gt;
	&lt;/person&gt;
	&lt;person id="three.worker"&gt;
		&lt;name&gt;
			&lt;family&gt;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;/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;/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;/person&gt;
 &lt;/personnel&gt;

  </source>
		  <p>Note that DOMPrint does not reproduce the original XML file.</p>

		</s3>

	</s2>







	<s2 title="DOMCreate">
		<s3 title="What it does">
		<p>DOMCreate creates a DOM tree in memory and then prints it.  It
		illustrates how you can programmatically create an XML document using
		DOM APIs.</p>
		</s3>

		<s3 title="Running DOMCreate">

<source>
perl DOMCreate.pl
</source>

		  <p>When invoked: </p>

<source>
cd &XercesPInstallDir;/samples
perl DOMParse.pl
</source>

		  <p>The output is the following:</p>

<source>
&lt;?xml version='1.0' encoding='utf-8' ?&gt;
&lt;contributors&gt;
  	&lt;person Role="manager"&gt;
    		&lt;name&gt;Mike Pogue&lt;/name&gt;
   		&lt;email&gt;mpogue@us.ibm.com&lt;/email&gt;
  	&lt;/person&gt;
  	&lt;person Role="developer"&gt;
    		&lt;name&gt;Tom Watson&lt;/name&gt;
    		&lt;email&gt;rtwatson@us.ibm.com&lt;/email&gt;
  	&lt;/person&gt;
  	&lt;person Role="tech writer"&gt;
   		&lt;name&gt;Susan Hardenbrook&lt;/name&gt;
    		&lt;email&gt;susanhar@us.ibm.com&lt;/email&gt;
  	&lt;/person&gt;
&lt;/contributors&gt;
</source>

		</s3>

	</s2>


</s1>
