| <?xml version="1.0" standalone="no"?> |
| <!DOCTYPE s1 SYSTEM "sbk:/style/dtd/document.dtd"> |
| |
| <s1 title="Sample: SAX2Print"> |
| |
| <s2 title="SAX2Print"> |
| <p>SAX2Print uses the SAX2 APIs to parse an XML file and print |
| it back. Do note that the output of this sample is not |
| exactly the same as the input (in terms of whitespaces, first |
| line), but the output has the same information content as the |
| input.</p> |
| |
| <s3 title="Running SAX2Print"> |
| |
| <p>The SAX2Print sample parses an XML file and prints out the |
| contents again in XML (some loss occurs). To run SAX2Print, |
| enter the following </p> |
| |
| <source>SAX2Print <XML file></source> |
| <p>The following parameters may be set from the command line </p> |
| <source> |
| Usage: |
| SAX2Print [options] <XML file> |
| |
| This program invokes the SAX2XMLReader, and then prints the |
| data returned by the various SAX2 handlers for the specified |
| XML file. |
| |
| Options: |
| -u=xxx Handle unrepresentable chars [fail | rep | ref*]. |
| -v=xxx Validation scheme [always | never | auto*]. |
| -e Expand Namespace Alias with URI's. |
| -x=XXX Use a particular encoding for output (LATIN1*). |
| -f Enable full schema constraint checking processing. Defaults to off. |
| -s Disable schema processing. Defaults to on. |
| NOTE: THIS IS OPPOSITE FROM OTHER SAMPLES. |
| -? Show this help. |
| |
| * = Default if not provided explicitly. |
| |
| The parser has intrinsic support for the following encodings: |
| UTF-8, USASCII, ISO8859-1, UTF-16[BL]E, UCS-4[BL]E, |
| WINDOWS-1252, IBM1140, IBM037. |
| </source> |
| |
| <p><em>-u=fail</em> will fail when unrepresentable characters are encountered<br/> |
| <em>-u=rep</em> will replace with the substitution character for that codepage<br/> |
| <em>-u=ref</em> will report the character as a reference</p> |
| <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 SAX2Print</p> |
| <source>cd &XercesCInstallDir;-linux/samples/data |
| SAX2Print -v=always personal.xml |
| |
| <?xml version="1.0" encoding="LATIN1"?> |
| <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></source> |
| <note>SAX2Print does not reproduce the original XML file. |
| SAX2Print and DOMPrint produce different results because of |
| the way the two APIs store data and capture events.</note> |
| </s3> |
| |
| </s2> |
| </s1> |