blob: 28634de06c6097d4ebb934cebea2346504dcae72 [file] [log] [blame]
<?xml version="1.0" standalone="no"?>
<!DOCTYPE s1 SYSTEM "./dtd/document.dtd">
<s1 title="SAX/DOMWriter Samples">
<s2 title="Running SAXWriter and DOMWriter">
<p><code>SAXWriter</code> and <code>DOMWriter</code> parse your input file,
and print it out in XML format. A command line option can be used to
print in a "canonical" XML format so the output can be used to compare
XML documents. SAXWriter and DOMWriter also display any errors or
warnings that occurred during the parse.</p>
<p><code>DOMWriter</code> provides a -e switch to set the output
Java encoding. </p>
<p>The command lines below expect the current directory to be the
directory containing the JAR file.</p>
<p>Requirements:</p>
<ul>
<li>&javaparsername; is loaded on your computer.</li>
<li>JDK is loaded on your computer.</li>
</ul>
<p>Source code: </p>
<ul>
<li>SAXWriter.java</li>
<li>DOMWriter.java</li>
</ul>
</s2>
<s2 title="SAXWriter">
<p><em>To run SAXWriter:</em></p>
<ol>
<li>open up a MS-DOS command line window</li>
<li>set the path to the jdk\bin directory</li>
<li>change directory to the latest &javaparserdirectory; directory</li>
<li>invoke the <code>SAXWriter</code> sample</li>
</ol>
<p><em>On Windows:</em></p>
<p>The easiest way to do this is to create a .bat file using the
Notepad editor. Then the <code>SAXWriter</code> can be invoked by double clicking
on the file name or icon. The following command lines assume that
both the jdk and the &javaparserdirectory; directories are located directly below
the c: drive.</p>
<source>set PATH=%PATH%;c:\jdk1.1.8\bin
set CLASSPATH=%CLASSPATH%;c:\&javaparserdirectory;\xerces.jar;c:\&javaparserdirectory;\xercesSamples.jar
cd c:\&javaparserdirectory;
java sax.SAXWriter data/personal.xml</source>
<p><em>Switches:</em></p>
<p>SAXCount also allows you to change the default behavior using the
following command line flags: </p>
<ul>
<li>-p Specify the parser class to be used.
<br/>The available parsers are:</li>
<ul>
<li>org.apache.xerces.parsers.SAXParser [default parser]</li>
</ul>
<li>-h Print SAXWriter help information. [default is no help]</li>
<li>-c Output in canonical format. [default is normal format] </li>
</ul>
<p>Running <code>SAXWriter</code> with the default settings is equivalent to
running <code>SAXWriter</code> like this (type this in as one long command line): </p>
<source>java sax.SAXWriter -p org.apache.xerces.parsers.SAXParser
data/personal.xml </source>
<p>Bringing up the help information: </p>
<source>java sax.SAXWriter -h </source>
<p>Print in canonical format: </p>
<source>java sax.SAXWriter -c data/personal.xml</source>
<note>Parse your own XML file instead of data/personal.xml</note>
</s2>
<s2 title="DOMWriter">
<p><em>To run DOMWriter:</em></p>
<ol>
<li>open up a MS-DOS command line window</li>
<li>set the path to the jdk\bin directory</li>
<li>change directory to the latest &javaparserdirectory; directory</li>
<li>invoke the <code>DOMWriter</code> sample</li>
</ol>
<p><em>On Windows:</em></p>
<p>The easiest way to do this is to create a .bat file using the
Notepad editor. Then the <code>DOMWriter</code> can be invoked by double clicking
on the file name or icon. The following command lines assume that
both the jdk and the &javaparserdirectory; directories are located directly below
the c: dirve.</p>
<source>set PATH=%PATH%;c:\jdk1.1.8\bin
set CLASSPATH=%CLASSPATH%;c:\&javaparserdirectory;\xerces.jar;c:\&javaparserdirectory;\xercesSamples.jar
cd c:\&javaparserdirectory;
java dom.DOMWriter data/personal.xml</source>
<p><em>Switches:</em></p>
<p>DOMCount also allows you to change the default behavior via the
following command line flags (type this in as one long command line): </p>
<ul>
<li>-p Specify the parser class to be used.
<br/>The available parsers are:</li>
<ul>
<li>dom.wrappers.DOMParser [default parser]</li>
</ul>
<li>-h Print DOMWriter help information. [default is no help]</li>
<li>-c Output in canonical format. [default is normal format]</li>
<li>-e encodingName Output using the specified encoding. [default is UTF8]</li>
</ul>
<p>Running <code>DOMWriter</code> with the default settings is equivalent to running
<code>DOMWriter</code> like this: </p>
<source>java dom.DOMWriter -p dom.wrappers.DOMParser
data/personal.xml </source>
<p>Bringing up the help information: </p>
<source>java dom.DOMWriter -h</source>
<p>Searching for elements: </p>
<source>java dom.DOMWriter -c data/personal.xml</source>
<p>Running DOMWriter with the -e switch and no encoding specified
will print out a list of valid encoding names: </p>
<source>java dom.DOMWriter -e</source>
<p>Prints the following: </p>
<source>Java Encoding one of (case sensitive):
Default
8859_1 8859_2 8859_3 8859_4 8859_5 8859_6 8859_7
8859_8 8859_9 Cp037 Cp273 Cp277 Cp278 Cp280
Cp284 Cp285 Cp297 Cp420 Cp424 Cp437 Cp500
Cp737 Cp775 Cp838 Cp850 Cp852 Cp855 Cp856
Cp857 Cp860 Cp861 Cp862 Cp863 Cp864 Cp865
Cp866 Cp868 Cp869 Cp870 Cp871 Cp874 Cp875
Cp918 Cp921 Cp922 Cp930 Cp933 Cp935 Cp937
Cp939 Cp942 Cp948 Cp949 Cp950 Cp964 Cp970
Cp1006 Cp1025 Cp1026 Cp1046 Cp1097 Cp1098 Cp1112
Cp1122 Cp1123 Cp1124 Cp1250 Cp1251 Cp1252 Cp1253
Cp1254 Cp1255 Cp1256 Cp1257 Cp1258 Cp1381 Cp1383
Cp33722 MS874 DBCS_ASCII DBCS_EBCDIC EUC EUCJIS GB2312
GBK ISO2022CN_CNS ISO2022CN_GB JIS JIS0208 KOI8_R KSC5601
MS874 SJIS SingleByte Big5 CNS11643 MacArabic
MacCentralEurope MacCroatian MacCyrillic MacDingbat
MacGreek MacHebrew MacIceland MacRoman MacRomania
MacSymbol MacThai MacTurkish MacUkraine SJIS Unicode
UnicodeBig UnicodeLittle UTF8</source>
<note>Parse your own XML file instead of data/personal.xml</note>
</s2>
</s1>