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.

123 lines
5.0 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: SAX2Print">
  20. <s2 title="SAX2Print">
  21. <p>SAX2Print uses the SAX2 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 SAX2Print">
  27. <p>The SAX2Print sample parses an XML file and prints out the
  28. contents again in XML (some loss occurs). To run SAX2Print,
  29. enter the following </p>
  30. <source>SAX2Print &lt;XML file&gt;</source>
  31. <p>The following parameters may be set from the command line </p>
  32. <source>
  33. Usage:
  34. SAX2Print [options] &lt;XML file&gt;
  35. This program invokes the SAX2XMLReader, and then prints the
  36. data returned by the various SAX2 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. -e Expand Namespace Alias with URI's.
  42. -x=XXX Use a particular encoding for output (LATIN1*).
  43. -f Enable full schema constraint checking processing. Defaults to off.
  44. -p Enable namespace-prefixes feature. Defaults to off.\n"
  45. -n Disable namespace processing. Defaults to on.\n"
  46. NOTE: THIS IS OPPOSITE FROM OTHER SAMPLES.\n"
  47. -s Disable schema processing. Defaults to on.
  48. NOTE: THIS IS OPPOSITE FROM OTHER SAMPLES.
  49. -? Show this help.
  50. * = Default if not provided explicitly.
  51. The parser has intrinsic support for the following encodings:
  52. UTF-8, US-ASCII, ISO8859-1, UTF-16[BL]E, UCS-4[BL]E,
  53. WINDOWS-1252, IBM1140, IBM037, IBM1047.
  54. </source>
  55. <p><em>-u=fail</em> will fail when unrepresentable characters are encountered<br/>
  56. <em>-u=rep</em> will replace with the substitution character for that codepage<br/>
  57. <em>-u=ref</em> will report the character as a reference</p>
  58. <p><em>-v=always</em> will force validation<br/>
  59. <em>-v=never</em> will not use any validation<br/>
  60. <em>-v=auto</em> will validate if a DOCTYPE declaration or a schema declaration is present in the XML document</p>
  61. <p>Here is a sample output from SAX2Print</p>
  62. <source>cd &XercesC3InstallDir;/samples/data
  63. SAX2Print -v=always personal.xml
  64. &lt;?xml version="1.0" encoding="LATIN1"?&gt;
  65. &lt;personnel&gt;
  66. &lt;person id="Big.Boss"&gt;
  67. &lt;name&gt;&lt;family&gt;Boss&lt;/family&gt; &lt;given&gt;Big&lt;/given&gt;&lt;/name&gt;
  68. &lt;email&gt;chief@foo.com&lt;/email&gt;
  69. &lt;link subordinates="one.worker two.worker three.worker
  70. four.worker five.worker"&gt;&lt;/link&gt;
  71. &lt;/person&gt;
  72. &lt;person id="one.worker"&gt;
  73. &lt;name&gt;&lt;family&gt;Worker&lt;/family&gt; &lt;given&gt;One&lt;/given&gt;&lt;/name&gt;
  74. &lt;email&gt;one@foo.com&lt;/email&gt;
  75. &lt;link manager="Big.Boss"&gt;&lt;/link&gt;
  76. &lt;/person&gt;
  77. &lt;person id="two.worker"&gt;
  78. &lt;name&gt;&lt;family&gt;Worker&lt;/family&gt; &lt;given&gt;Two&lt;/given&gt;&lt;/name&gt;
  79. &lt;email&gt;two@foo.com&lt;/email&gt;
  80. &lt;link manager="Big.Boss"&gt;&lt;/link&gt;
  81. &lt;/person&gt;
  82. &lt;person id="three.worker"&gt;
  83. &lt;name&gt;&lt;family&gt;Worker&lt;/family&gt; &lt;given&gt;Three&lt;/given&gt;&lt;/name&gt;
  84. &lt;email&gt;three@foo.com&lt;/email&gt;
  85. &lt;link manager="Big.Boss"&gt;&lt;/link&gt;
  86. &lt;/person&gt;
  87. &lt;person id="four.worker"&gt;
  88. &lt;name&gt;&lt;family&gt;Worker&lt;/family&gt; &lt;given&gt;Four&lt;/given&gt;&lt;/name&gt;
  89. &lt;email&gt;four@foo.com&lt;/email&gt;
  90. &lt;link manager="Big.Boss"&gt;&lt;/link&gt;
  91. &lt;/person&gt;
  92. &lt;person id="five.worker"&gt;
  93. &lt;name&gt;&lt;family&gt;Worker&lt;/family&gt; &lt;given&gt;Five&lt;/given&gt;&lt;/name&gt;
  94. &lt;email&gt;five@foo.com&lt;/email&gt;
  95. &lt;link manager="Big.Boss"&gt;&lt;/link&gt;
  96. &lt;/person&gt;
  97. &lt;/personnel&gt;</source>
  98. <note>SAX2Print does not reproduce the original XML file.
  99. SAX2Print and DOMPrint produce different results because of
  100. the way the two APIs store data and capture events.</note>
  101. </s3>
  102. </s2>
  103. </s1>