About SAX
 Copyright Status
 Events vs. Trees

Java API
 Features and Properties

SAX Evolution
 SAX 1.0 Overview
 SAX 2.0 Changes
 SAX 2.0 Extensions
 Other Languages

SourceForge Services
 Project Page

SourceForge Logo

Features and Properties

WARNING: the properties listed on this page are out of date. Please use the JavaDoc documentation until this page can be updated.

SAX2 defines standard methods to query and set feature flags and property values in an XMLReader. It is possible to change parser behaviors, such as requesting that an XML reader to validate (or not validate) a document, and register new types of event handlers using the getFeature, setFeature, getProperty, and setProperty methods:

try {
  String id = "";
  if (xmlReader.getFeature(id)) {
    System.out.println("Parser is validating.");
  } else {
    System.out.println("Parser is not validating.");
} catch (SAXNotRecognizedException e) {
  System.out.println("Can't tell.");
} catch (SAXNotSupportedException e) {
  System.out.println("Wrong time to ask.");

While feature flags are always boolean, property values are arbitrary objects. All feature and property names are fully-qualified URIs (often URLs), such as ""; as with Namespace URIs, people should only define feature and property names based on URIs that they control.

Exceptions for Features and Properties

If an application attempts to query or set a feature flag that the XML reader does not recognize (can't get or set the value for), the XML reader throws a SAXNotRecognizedException. (That might indicate an application provided the wrong URI.) If the application attempts to set a feature state or property value that the XML reader cannot support at that time, or attempts to modify a feature or property when it is read-only, the XML reader throws a SAXNotSupportedException.

One important application for properties is getting and setting extension event handlers, for event types not supported by the four core SAX2 handlers, EntityResolver, DTDHandler, ContentHandler, and ErrorHandler. Outside parties are free to define handlers for any kinds of events, and to create properties for setting and querying them.

URIs for Identifying Feature Flags and Properties

There is no fixed set of features or properties available for SAX2, except for two features that all XML parsers must support. Implementors are free to define new features and properties as needed, using URIs to identify them.

All XML readers are required to recognize the "" and the "" features (at least to get the feature values, if not set them) and to support a true value for the namespaces property and a false value for the namespace-prefixes property. These requirements ensure that all SAX2 XML readers can provide the minimal required Namespace support for higher-level specs such as RDF, XSL, XML Schemas, and XLink. XML readers are not required to recognize or support any other features or any properties.

For the complete list of standard SAX2 features and properties, see the org.xml.sax Package Description.