| PParse |
| PParse demonstrates progressive parsing. In this example, the application doesn't have to depend upon throwing an exception to terminate the parsing operation. Calling parseFirst() will cause the DTD to be parsed (both internal and external subsets) and any pre-content, i.e. everything up to but not including the root element. Subsequent calls to parseNext() will cause one more piece of markup to be parsed, and propagated from the core scanning code to the parser. You can quit the parse any time by just not calling parseNext() anymore and breaking out of the loop. When you call parseNext() and the end of the root element is the next piece of markup, the parser will continue on to the end of the file and return false, to let you know that the parse is done.
| Running PParse |
| PParse parses an XML file and prints out the number of elements in the file.
    Usage:
        PParse [options] <XML file>

    This program demonstrates the progressive parse capabilities of
    the parser system. It allows you to do a scanFirst() call followed by
    a loop which calls scanNext(). You can drop out when you've found what
    ever it is you want. In our little test, our event handler looks for
    16 new elements then sets a flag to indicate its found what it wants.
    At that point, our progressive parse loop exits.

    Options:
          -v=xxx        - Validation scheme [always | never | auto*].
          -n            - Enable namespace processing [default is off].
          -s            - Enable schema processing [default is off].
          -f            - Enable full schema constraint checking [default is off].
          -?            - Show this help.

      * = Default if not provided explicitly.
-v=always will force validation -v=never will not use any validation -v=auto will validate if a DOCTYPE declaration or a schema declaration is present in the XML document Here is a sample output from PParse
    cd xerces-c-3.3.0/samples/data
    PParse -v=always personal.xml
    personal.xml: 60 ms (37 elems, 12 attrs, 134 spaces, 134 chars)
Running PParse with the validating parser gives a different result because ignorable white-space is counted separately from regular characters.
    PParse -v=never personal.xml
    personal.xml: 10 ms (37 elems, 12 attrs, 0 spaces, 268 chars)
Note that the sum of spaces and characters in both versions is the same.
| The time reported by the program may be different depending on your processor speed.

Copyright © 1999-2017 The Apache Software Foundation. All Rights Reserved.