| <?xml version="1.0" standalone="no"?> |
| <!DOCTYPE s1 SYSTEM "./dtd/document.dtd"> |
| |
| <s1 title="&XercesCName; Sample 7: PParse"> |
| |
| <s2 title="PParse"> |
| <p>PParse demonstrates progressive parsing.</p> |
| <p>In this example, the programmer 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 spit out 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.</p> |
| |
| <s3 title="Building on Windows"> |
| <p>Load the &XercesCInstallDir;win32\samples\Projects\Win32\VC6\samples.dsw |
| Microsoft Visual C++ workspace inside your MSVC IDE. Then |
| build the project marked PParse.</p> |
| </s3> |
| |
| <s3 title="Building on UNIX"> |
| <source>cd &XercesCInstallDir;-linux/samples |
| ./runConfigure -p<platform> -c<C_compiler> -x<C++_compiler> |
| cd PParse |
| gmake</source> |
| <p>This will create the object files in the current directory |
| and the executable named PParse in ' &XercesCInstallDir;-linux/bin' |
| directory.</p> |
| |
| <p>To delete all the generated object files and executables, type:</p> |
| <source>gmake clean</source> |
| </s3> |
| |
| <s3 title="Running PParse"> |
| <p>The program looks for the first 16 elements of the XML file, |
| and reports if successful.</p> |
| <source>PParse <XML file></source> |
| |
| <source> |
| Usage: PParse [options] <file> |
| |
| This sample 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 - Do validation [default is off] |
| -n - Enable namespace processing [default is off] |
| -? - Show this help (must be the only parameter)</source> |
| <p>The output is the following:</p> |
| <source>cd &XercesCInstallDir;-linux/samples/data |
| PParse personal.xml |
| |
| Got the required 16 elements.</source> |
| </s3> |
| </s2> |
| </s1> |