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.

76 lines
3.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: PParse">
  20. <s2 title="PParse">
  21. <p>PParse demonstrates progressive parsing.</p>
  22. <p>In this example, the application doesn't have to depend upon throwing
  23. an exception to terminate the parsing operation. Calling parseFirst() will
  24. cause the DTD to be parsed (both internal and external subsets) and any
  25. pre-content, i.e. everything up to but not including the root element.
  26. Subsequent calls to parseNext() will cause one more piece of markup to
  27. be parsed, and propagated from the core scanning code to the parser. You
  28. can quit the parse any time by just not calling parseNext() anymore
  29. and breaking out of the loop. When you call parseNext() and the end
  30. of the root element is the next piece of markup, the parser will
  31. continue on to the end of the file and return false, to let you
  32. know that the parse is done.</p>
  33. <s3 title="Running PParse">
  34. <p>PParse parses an XML file and prints out the number of
  35. elements in the file.</p>
  36. <source>Usage:
  37. PParse [options] &lt;XML file&gt;
  38. This program demonstrates the progressive parse capabilities of
  39. the parser system. It allows you to do a scanFirst() call followed by
  40. a loop which calls scanNext(). You can drop out when you've found what
  41. ever it is you want. In our little test, our event handler looks for
  42. 16 new elements then sets a flag to indicate its found what it wants.
  43. At that point, our progressive parse loop exits.
  44. Options:
  45. -v=xxx - Validation scheme [always | never | auto*].
  46. -n - Enable namespace processing [default is off].
  47. -s - Enable schema processing [default is off].
  48. -f - Enable full schema constraint checking [default is off].
  49. -? - Show this help.
  50. * = Default if not provided explicitly.
  51. </source>
  52. <p><em>-v=always</em> will force validation<br/>
  53. <em>-v=never</em> will not use any validation<br/>
  54. <em>-v=auto</em> will validate if a DOCTYPE declaration or a schema declaration is present in the XML document</p>
  55. <p>Here is a sample output from PParse</p>
  56. <source>cd &XercesC3InstallDir;/samples/data
  57. PParse -v=always personal.xml
  58. personal.xml: 60 ms (37 elems, 12 attrs, 134 spaces, 134 chars)</source>
  59. <p>Running PParse with the validating parser gives a different result because
  60. ignorable white-space is counted separately from regular characters.</p>
  61. <source>PParse -v=never personal.xml
  62. personal.xml: 10 ms (37 elems, 12 attrs, 0 spaces, 268 chars)</source>
  63. <p>Note that the sum of spaces and characters in both versions is the same.</p>
  64. <note>The time reported by the program may be different depending on your
  65. processor speed.</note>
  66. </s3>
  67. </s2>
  68. </s1>