Access features of the SAX parser implementation in Java

Description

The following code shows how to access features of the SAX parser implementation.

Example


   //www .  j a  v a  2  s .c o  m

 
import javax.xml.parsers.SAXParserFactory;

public class Main {
  public static void main(String[] argv) throws Exception {
    SAXParserFactory factory = SAXParserFactory.newInstance();
    String features[] = { "http://xml.org/sax/features/namespaces",
        "http://xml.org/sax/features/namespace-prefixes",
        "http://xml.org/sax/features/string-interning", 
        "http://xml.org/sax/features/validation",
        "http://xml.org/sax/features/external-general-entities",
        "http://xml.org/sax/features/external-parameter-entities",
        "http://xml.org/sax/features/lexical-handler/parameter-entities", };
    for (int i = 0; i < features.length; i++) {
      System.out.print("\t- '" + features[i] + "' is ");
      System.out.println("'" + factory.getFeature(features[i]) + "'");
    }
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    XML »




DOM
SAX