- SAX Implementation Class


How to verify the SAX (Simple API for XML) implementation class information?

✍: FYIcenter


If you want to verify the SAX (Simple API for XML) implementation class information, you can try the following example program:

// Copyright (c) 2017
import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.SAXParser;

public class SaxClassInfo {
   public static void main(String[] args) throws Exception {
      SAXParserFactory f = SAXParserFactory.newInstance();
      SAXParser p = f.newSAXParser();
      System.out.println("SAX class info:");
      System.out.println("   Factory: "+f.getClass().getName());
      System.out.println("   Parser: "+p.getClass().getName());

Compile and run it with Java SE 8 SDK:


>\fyicenter\jdk-1.8.0\bin\java SaxClassInfo
SAX class info:

Run it again with Apache Xerces 2.11.0 xercesImpl.jar provided:

   -cp .;\fyicenter\xerces-2_11_0\xercesImpl.jar; SaxClassInfo
SAX class info:
   Factory: org.apache.xerces.jaxp.SAXParserFactoryImpl
   Parser: org.apache.xerces.jaxp.SAXParserImpl

The output tells you that the default implementation of SAX in Java SE 8 JDK is the Apache Xerces 2.7.1 package. And you can override it with Apache Xerces 2.11.0 by specifiying the JAR file to the -cp option.

You can confirm Apache Xerces version numbers as desribed below:


Xerces-J 2.7.1

   -cp .;\fyicenter\xerces-2_11_0\xercesImpl.jar 

Xerces-J 2.11.0


Using XML SAX API with Apache Xerces

⇒⇒FAQ for Apache Xerces XML Parser

2017-12-09, 199👍, 0💬