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.

158 lines
6.5 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: DOMPrint">
  20. <s2 title="DOMPrint">
  21. <p>DOMPrint parses an XML file, constructs the DOM tree, and
  22. invokes DOMLSSerializer::write() to serialize the resultant
  23. DOM tree back to XML stream.
  24. </p>
  25. <s3 title="Running DOMPrint">
  26. <p>The DOMPrint sample parses an XML file, using either a validating
  27. or non-validating DOM parser configuration, builds a DOM tree,
  28. and then invokes DOMLSSerializer::write() to serialize the
  29. resultant DOM tree. To run DOMPrint, enter the following:</p>
  30. <source>DOMPrint &lt;XML file&gt;</source>
  31. <p>The following parameters may be set from the command line </p>
  32. <source>
  33. Usage:
  34. DOMPrint [options] &lt;XML file&gt;
  35. This program invokes the DOM parser, and builds the DOM tree
  36. It then asks the DOMLSSerializer to serialize the DOM tree.
  37. Options:
  38. -e create entity reference nodes. Default is no expansion.
  39. -v=xxx Validation scheme [always | never | auto*].
  40. -n Enable namespace processing. Default is off.
  41. -s Enable schema processing. Default is off.
  42. -f Enable full schema constraint checking. Defaults is off.
  43. -wenc=XXX Use a particular encoding for output. Default is
  44. the same encoding as the input XML file. UTF-8 if
  45. input XML file has not XML declaration.
  46. -wfile=xxx Write to a file instead of stdout.
  47. -wscs=xxx Enable/Disable split-cdata-sections. Default on.
  48. -wddc=xxx Enable/Disable discard-default-content. Default on.
  49. -wflt=xxx Enable/Disable filtering. Default off.
  50. -wfpp=xxx Enable/Disable format-pretty-print. Default off.
  51. -wbom=xxx Enable/Disable write Byte-Order-Mark Default off.
  52. -? Show this help
  53. * = Default if not provided explicitly.
  54. The parser has intrinsic support for the following encodings:\n"
  55. UTF-8, US-ASCII, ISO8859-1, UTF-16[BL]E, UCS-4[BL]E,\n"
  56. WINDOWS-1252, IBM1140, IBM037, IBM1047.\n"
  57. </source>
  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 DOMPrint</p>
  62. <source>cd &XercesC3InstallDir;/samples/data
  63. DOMPrint -v=always personal.xml
  64. &lt;?xml version="1.0" encoding="iso-8859-1"?&gt;
  65. &lt;!DOCTYPE personnel SYSTEM "personal.dtd"&gt;
  66. &lt;!-- @version: --&gt;
  67. &lt;personnel&gt;
  68. &lt;person id="Big.Boss"&gt;
  69. &lt;name&gt;&lt;family&gt;Boss&lt;/family&gt; &lt;given&gt;Big&lt;/given&gt;&lt;/name&gt;
  70. &lt;email&gt;chief@foo.com&lt;/email&gt;
  71. &lt;link subordinates="one.worker two.worker three.worker
  72. four.worker five.worker"&gt;&lt;/link&gt;
  73. &lt;/person&gt;
  74. &lt;person id="one.worker"&gt;
  75. &lt;name&gt;&lt;family>Worker&lt;/family&gt; &lt;given&gt;One&lt;/given&gt;&lt;/name&gt;
  76. &lt;email&gt;one@foo.com&lt;/email&gt;
  77. &lt;link manager="Big.Boss"&gt;&lt;/link&gt;
  78. &lt;/person&gt;
  79. &lt;person id="two.worker"&gt;
  80. &lt;name&gt;&lt;family&gt;Worker&lt;/family&gt; &lt;given&gt;Two&lt;/given&gt;&lt;/name&gt;
  81. &lt;email&gt;two@foo.com&lt;/email&gt;
  82. &lt;link manager="Big.Boss"&gt;&lt;/link&gt;
  83. &lt;/person&gt;
  84. &lt;person id="three.worker"&gt;
  85. &lt;name&gt;&lt;family>Worker&lt;/family&gt; &lt;given&gt;Three&lt;/given&gt;&lt;/name&gt;
  86. &lt;email&gt;three@foo.com&lt;/email&gt;
  87. &lt;link manager="Big.Boss"&gt;&lt;/link&gt;
  88. &lt;/person&gt;
  89. &lt;person id="four.worker"&gt;
  90. &lt;name&gt;&lt;family&gt;Worker&lt;/family&gt; &lt;given&gt;Four&lt;/given&gt;&lt;/name&gt;
  91. &lt;email&gt;four@foo.com&lt;/email&gt;
  92. &lt;link manager="Big.Boss"&gt;&lt;/link&gt;
  93. &lt;/person&gt;
  94. &lt;person id="five.worker"&gt;
  95. &lt;name&gt;&lt;family&gt;Worker&lt;/family&gt; &lt;given&gt;Five&lt;/given&gt;&lt;/name&gt;
  96. &lt;email&gt;five@foo.com&lt;/email&gt;
  97. &lt;link manager="Big.Boss"&gt;&lt;/link&gt;
  98. &lt;/person&gt;
  99. &lt;/personnel&gt;</source>
  100. <p>Note that DOMPrint does not reproduce the original XML file. DOMPrint and
  101. SAXPrint produce different results because of the way the two APIs store data
  102. and capture events.</p>
  103. <p>Application needs to provide its own implementation of
  104. DOMErrorHandler (in this sample, the DOMPrintErrorHandler),
  105. if it would like to receive notification from the serializer
  106. in the case any error occurs during the serialization.
  107. </p>
  108. <p>Application needs to provide its own implementation of
  109. DOMLSSerializerFilter (in this sample, the DOMPrintFilter),
  110. if it would like to filter out certain part of the DOM
  111. representation, but must be aware that thus may render the
  112. resultant XML stream invalid.
  113. </p>
  114. <p>Application may choose any combination of characters as the
  115. end of line sequence to be used in the resultant XML stream,
  116. but must be aware that this may render the resultant XML
  117. stream ill formed.
  118. </p>
  119. <p>Application may choose a particular encoding name in which
  120. the output XML stream should be, but must be aware that if
  121. unrepresentable in the encoding specified characters appear
  122. in the markup, it may force the serializer to terminate serialization
  123. prematurely, and thus no complete serialization would be done.
  124. </p>
  125. <p>Application shall query the serializer first, before set any
  126. feature/mode(true, false), or be ready to catch exception if this
  127. feature/mode is not supported by the serializer.
  128. </p>
  129. <p>Application needs to release the filter, error handler and
  130. format target objects created for the serialization.
  131. </p>
  132. </s3>
  133. </s2>
  134. </s1>