Performance of XML Parsers with jaxp\SourceValidator.java

Q

How to compare performances of various XML parsers with the jaxp\SourceValidator.java provided in the Apache Xerces package?

✍: FYIcenter

A

If you have XML file with an XML schema, you can use the jaxp\SourceValidator.java provided in the Apache Xerces package to compare performances of various XML parsers.

Compile and run jaxp\SourceValidator.java, if you have Apache Xerces 2.11.0 installed:

\fyicenter\xerces-2_11_0\samples>\fyicenter\jdk-1.8.0\bin\java 
   -cp .;..\xercesImpl.jar;..\xml-apis.jar 
   jaxp.SourceValidator -a User.xsd -i UserXSD.xml -vs dom
UserXSD.xml: 15 ms

\fyicenter\xerces-2_11_0\samples>\fyicenter\jdk-1.8.0\bin\java 
   -cp .;..\xercesImpl.jar;..\xml-apis.jar 
   jaxp.SourceValidator -a User.xsd -i UserXSD.xml -vs sax
UserXSD.xml: 12 ms

\fyicenter\xerces-2_11_0\samples>\fyicenter\jdk-1.8.0\bin\java 
   -cp .;..\xercesImpl.jar;..\xml-apis.jar 
   jaxp.SourceValidator -a User.xsd -i UserXSD.xml -vs stream
UserXSD.xml: 18 ms

\fyicenter\xerces-2_11_0\samples>\fyicenter\jdk-1.8.0\bin\java 
   -cp .;..\xercesImpl.jar;..\xml-apis.jar 
   jaxp.SourceValidator -a User.xsd -i UserXSD.xml -vs stax
UserXSD.xml: 17 ms

The output shows the SAX parser is faster than DOM, StAX and Stream parsers.

 

Using Apache Xerces JAXP Sample Programs

⇒⇒FAQ for Apache Xerces XML Parser

2017-07-30, 261👍, 0💬