This package provides the core SAX APIs.
See: Description
Interface Summary | |
---|---|
AttributeList | Interface for an element's attribute specifications. |
Attributes | Interface for a list of XML attributes. |
ContentHandler | Receive notification of the logical content of a document. |
DocumentHandler | Receive notification of general document events. |
DTDHandler | Receive notification of basic DTD-related events. |
EntityResolver | Basic interface for resolving entities. |
ErrorHandler | Basic interface for SAX error handlers. |
Locator | Interface for associating a SAX event with a document location. |
Parser | Basic interface for SAX (Simple API for XML) parsers. |
XMLFilter | Interface for an XML filter. |
XMLReader | Interface for reading an XML document using callbacks. |
Class Summary | |
---|---|
HandlerBase | Default base class for handlers. |
InputSource | A single input source for an XML entity. |
SAXException | Encapsulate a general SAX error or warning. |
SAXNotRecognizedException | Exception class for an unrecognized identifier. |
SAXNotSupportedException | Exception class for an unsupported operation. |
SAXParseException | Encapsulate an XML parse error or warning. |
This package provides the core SAX APIs. Some SAX1 APIs are deprecated to encourage integration of namespace-awareness into designs of new applications and into maintainance of existing infrastructure.
See http://www.saxproject.org for more information about SAX.
One of the essential characteristics of SAX2 is that it added
feature flags which can be used to examine and perhaps modify
parser modes, in particular modes such as validation.
Since features are identified by (absolute) URIs, anyone
can define such features.
Currently defined standard feature URIs have the prefix
http://xml.org/sax/features/
before an identifier such as
validation
. Turn features on or off using
setFeature. Those standard identifiers are:
Feature ID | Default | Description |
---|---|---|
external-general-entities | unspecified | Reports whether this parser processes external general entities; always true if validating |
external-parameter-entities | unspecified | Reports whether this parser processes external parameter entities; always true if validating |
is-standalone | none | May be examined only during a parse, after the startDocument() callback has been made; read-only. The value is true if the document specified the "standalone" flag in its XML declaration, and otherwise is false. |
lexical-handler/parameter-entities | unspecified | true indicates that the LexicalHandler will report the beginning and end of parameter entities |
namespaces | true | true indicates namespace URIs and unprefixed local names for element and attribute names will be available |
namespace-prefixes | false | true indicates XML 1.0 names (with prefixes) and attributes (including xmlns* attributes) will be available |
resolve-dtd-uris | true | A value of "true" indicates that system IDs in declarations will
be absolutized (relative to their base URIs) before reporting.
(That is the default behavior for all SAX2 XML parsers.)
A value of "false" indicates those IDs will not be absolutized;
parsers will provide the base URI from
Locator.getSystemId().
This applies to system IDs passed in
|
string-interning | unspecified | true if all XML names (for elements, prefixes, attributes, entities, notations, and local names), as well as Namespace URIs, will have been interned using java.lang.String.intern. This supports fast testing of equality/inequality against string constants. |
use-attributes2 | unspecified | Returns true if the Attributes objects passed by this parser in ContentHandler.startElement() implement the org.xml.sax.ext.Attributes2 interface. That interface exposes additional information, such as whether the attribute was specified in the source text rather than defaulted. |
use-locator2 | unspecified | Returns true if the Locator objects passed by this parser in ContentHandler.setDocumentLocator() implement the org.xml.sax.ext.Locator2 interface. That interface exposes additional entity information, such as the character encoding and XML version used. |
use-entity-resolver2 | true (when recognized) | Returns true if, when setEntityResolver is given an object implementing the org.xml.sax.ext.EntityResolver2 interface, those new methods will be used. Returns false to indicate that those methods will not be used. |
validation | unspecified | controls whether the parser is reporting all validity errors; if true, all external entities will be read. |
Support for the default values of the namespaces and namespace-prefixes properties is required.
For default values not specified by SAX2, each XMLReader implementation specifies its default, or may choose not to expose the feature flag. Unless otherwise specified here, implementations may support changing current values of these standard feature flags, but not while parsing.
For parser interface characteristics that are described
as objects, a separate namespace is defined. The
objects in this namespace are again identified by URI, and
the standard property URIs have the prefix
http://xml.org/sax/properties/
before an identifier such as
lexical-handler
or
dom-node
. Manage those properties using
setProperty(). Those identifiers are:
Property ID | Description |
---|---|
declaration-handler | Used to see most DTD declarations except those treated as lexical ("document element name is ...") or which are mandatory for all SAX parsers (DTDHandler). The Object must implement org.xml.sax.ext.DeclHandler. |
dom-node | For "DOM Walker" style parsers, which ignore their parser.parse() parameters, this is used to specify the DOM (sub)tree being walked by the parser. |
lexical-handler | Used to see some syntax events that are essential in some applications: comments, CDATA delimeters, selected general entity inclusions, and the start and end of the DTD (and declaration of document element name). The Object must implement org.xml.sax.ext.LexicalHandler. |
xml-string | Readable only during a parser callback, this exposes a TBS chunk of characters responsible for the current event. |
All of these standard properties are optional; XMLReader implementations need not support them.
Source code is under GPL (with library exception) in the JAXP project at http://www.gnu.org/software/classpathx/jaxp
This documentation was derived from that source code on 2013-01-12.