XSD Tutorials - Herong's Tutorial Examples - Version 5.10, by Dr. Herong Yang
Verifying Installation of Xerces2
This section describes a tutorial example on how to verify the installation of the Xerces2 Java 2.11.0 XML Schema 1.1 Beta version by running a sample program dom.Counter.
After installing the Xerces2 Java 2.11.0 XML Schema 1.1 Beta version, I want to run some sample programs provided in the xercesSamples.jar file to verify the installation. For example, the dom.Counter sample program uses a DOM parser to count the total number of elements and attributes in an XML file.
dom.Counter is provided as a pre-compiled .class in the xercesSamples.jar. To run dom.Counter, I need to included xercesSamples.jar and other .jar files provided in the installation package in the "-cp" option in the "java" command line.
To avoid repeating this long "-cp" option, I I created as two small .bat files to help me compile and run Java programs:
>type jdk8c.bat C:\Progra~1\Java\jdk1.8.0\bin\javac %1 set "x2path=c:\local\xerces-2_11_0-xml-schema-1.1-beta" C:\Progra~1\Java\jdk1.8.0\bin\java -cp ".;%x2path%\xml-apis.jar; ^^^%x2path%\xercesImpl.jar;%x2path%\cupv10k-runtime.jar; ^^^%x2path%\org.eclipse.wst.xml.xpath2.processor_1.1.0.jar; ^^^%x2path%\xercesSamples.jar;" %1 %2 %3 %4 %5 %6
Note that "^^^" indicates a line break inserted because of the limitation of the book format. You need to remove "^^^" and join the rest of the line with the previous line.
Now let's try to use jdk8x2r.bat to run dom.Counter:
>type hello.xml <?xml version="1.0"?> <p>Hello world!</p> >jdk8x2r dom.Counter hello.xml hello.xml: 64;6;0 ms (1 elems, 0 attrs, 0 spaces, 12 chars)
Okay. The Xerces2 Java 2.11.0 XML Schema 1.1 Beta version seems to be installed correctly. I see the counts in the output: "1 elems, 0 attrs, 0 spaces, 12 chars".
Last update: 2014.
Table of Contents