You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
4.7 KiB

  1. <?xml version="1.0" standalone="no"?>
  2. <!--
  3. * Licensed to the Apache Software Foundation (ASF) under one or more
  4. * contributor license agreements. See the NOTICE file distributed with
  5. * this work for additional information regarding copyright ownership.
  6. * The ASF licenses this file to You under the Apache License, Version 2.0
  7. * (the "License"); you may not use this file except in compliance with
  8. * the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. -->
  18. <!DOCTYPE s1 SYSTEM "sbk:/style/dtd/document.dtd">
  19. <s1 title="Sample: SAXPrint">
  20. <s2 title="SAXPrint">
  21. <p>SAXPrint uses the SAX APIs to parse an XML file and print
  22. it back. Do note that the output of this sample is not
  23. exactly the same as the input (in terms of whitespaces, first
  24. line), but the output has the same information content as the
  25. input.</p>
  26. <s3 title="Running SAXPrint">
  27. <p>The SAXPrint sample parses an XML file and prints out the
  28. contents again in XML (some loss occurs). To run SAXPrint,
  29. enter the following </p>
  30. <source>SAXPrint &lt;XML file&gt;</source>
  31. <p>The following parameters may be set from the command line </p>
  32. <source>
  33. Usage:
  34. SAXPrint [options] &lt;XML file&gt;
  35. This program invokes the SAX Parser, and then prints the
  36. data returned by the various SAX handlers for the specified
  37. XML file.
  38. Options:
  39. -u=xxx Handle unrepresentable chars [fail | rep | ref*].
  40. -v=xxx Validation scheme [always | never | auto*].
  41. -n Enable namespace processing.
  42. -s Enable schema processing.
  43. -f Enable full schema constraint checking.
  44. -x=XXX Use a particular encoding for output (LATIN1*).
  45. -? Show this help.
  46. * = Default if not provided explicitly.
  47. The parser has intrinsic support for the following encodings:
  48. UTF-8, US-ASCII, ISO8859-1, UTF-16[BL]E, UCS-4[BL]E,
  49. WINDOWS-1252, IBM1140, IBM037, IBM1047.
  50. </source>
  51. <p><em>-u=fail</em> will fail when unrepresentable characters are encountered<br/>
  52. <em>-u=rep</em> will replace with the substitution character for that codepage<br/>
  53. <em>-u=ref</em> will report the character as a reference</p>
  54. <p><em>-v=always</em> will force validation<br/>
  55. <em>-v=never</em> will not use any validation<br/>
  56. <em>-v=auto</em> will validate if a DOCTYPE declaration or a schema declaration is present in the XML document</p>
  57. <p>Here is a sample output from SAXPrint</p>
  58. <source>cd &XercesC3InstallDir;/samples/data
  59. SAXPrint -v=always personal.xml
  60. &lt;?xml version="1.0" encoding="LATIN1"?&gt;
  61. &lt;personnel&gt;
  62. &lt;person id="Big.Boss"&gt;
  63. &lt;name&gt;&lt;family&gt;Boss&lt;/family&gt; &lt;given&gt;Big&lt;/given&gt;&lt;/name&gt;
  64. &lt;email&gt;chief@foo.com&lt;/email&gt;
  65. &lt;link subordinates="one.worker two.worker three.worker
  66. four.worker five.worker"&gt;&lt;/link&gt;
  67. &lt;/person&gt;
  68. &lt;person id="one.worker"&gt;
  69. &lt;name&gt;&lt;family&gt;Worker&lt;/family&gt; &lt;given&gt;One&lt;/given&gt;&lt;/name&gt;
  70. &lt;email&gt;one@foo.com&lt;/email&gt;
  71. &lt;link manager="Big.Boss"&gt;&lt;/link&gt;
  72. &lt;/person&gt;
  73. &lt;person id="two.worker"&gt;
  74. &lt;name&gt;&lt;family&gt;Worker&lt;/family&gt; &lt;given&gt;Two&lt;/given&gt;&lt;/name&gt;
  75. &lt;email&gt;two@foo.com&lt;/email&gt;
  76. &lt;link manager="Big.Boss"&gt;&lt;/link&gt;
  77. &lt;/person&gt;
  78. &lt;person id="three.worker"&gt;
  79. &lt;name&gt;&lt;family&gt;Worker&lt;/family&gt; &lt;given&gt;Three&lt;/given&gt;&lt;/name&gt;
  80. &lt;email&gt;three@foo.com&lt;/email&gt;
  81. &lt;link manager="Big.Boss"&gt;&lt;/link&gt;
  82. &lt;/person&gt;
  83. &lt;person id="four.worker"&gt;
  84. &lt;name&gt;&lt;family&gt;Worker&lt;/family&gt; &lt;given&gt;Four&lt;/given&gt;&lt;/name&gt;
  85. &lt;email&gt;four@foo.com&lt;/email&gt;
  86. &lt;link manager="Big.Boss"&gt;&lt;/link&gt;
  87. &lt;/person&gt;
  88. &lt;person id="five.worker"&gt;
  89. &lt;name&gt;&lt;family&gt;Worker&lt;/family&gt; &lt;given&gt;Five&lt;/given&gt;&lt;/name&gt;
  90. &lt;email&gt;five@foo.com&lt;/email&gt;
  91. &lt;link manager="Big.Boss"&gt;&lt;/link&gt;
  92. &lt;/person&gt;
  93. &lt;/personnel&gt;</source>
  94. <note>SAXPrint does not reproduce the original XML file.
  95. SAXPrint and DOMPrint produce different results because of
  96. the way the two APIs store data and capture events.</note>
  97. </s3>
  98. </s2>
  99. </s1>