| |
org.xml.sax |
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 maintenance of existing infrastructure.
See http://www.saxproject.org
for more information about SAX.
SAX2 Standard Feature Flags
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 |
Access |
Default |
Description |
external-general-entities |
read/write |
unspecified |
Reports whether this parser processes external
general entities; always true if validating.
|
external-parameter-entities |
read/write |
unspecified |
Reports whether this parser processes external
parameter entities; always true if validating.
|
is-standalone |
(parsing) read-only, (not parsing) none |
not applicable |
May be examined only during a parse, after the
startDocument() callback has been completed; read-only.
The value is true if the document specified standalone="yes" in
its XML declaration, and otherwise is false.
|
lexical-handler/parameter-entities |
read/write |
unspecified |
A value of "true" indicates that the LexicalHandler will report
the beginning and end of parameter entities.
|
namespaces |
read/write |
true |
A value of "true" indicates namespace URIs and unprefixed local names
for element and attribute names will be available.
|
namespace-prefixes |
read/write |
false |
A value of "true" indicates that XML qualified names (with prefixes) and
attributes (including xmlns* attributes) will be available.
|
resolve-dtd-uris |
read/write |
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
- DTDHandler.notationDecl(),
- DTDHandler.unparsedEntityDecl(), and
- DeclHandler.externalEntityDecl().
It does not apply to EntityResolver.resolveEntity(),
which is not used to report declarations, or to
LexicalHandler.startDTD(), which already provides
the non-absolutized URI.
|
string-interning |
read/write |
unspecified |
Has a value of "true" if all XML names (for elements, prefixes,
attributes, entities, notations, and local names),
as well as Namespace URIs, will have been interned
using j2me.lang.String.intern. This supports fast
testing of equality/inequality against string constants,
rather than forcing slower calls to String.equals().
|
unicode-normalization-checking |
read/write |
false |
Controls whether the parser reports Unicode normalization
errors as described in section 2.13 and Appendix B of the
XML 1.1 Recommendation. If true, Unicode normalization
errors are reported using the ErrorHandler.error() callback.
Such errors are not fatal in themselves (though, obviously,
other Unicode-related encoding errors may be).
|
use-attributes2 |
read-only |
not applicable |
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 DTD-related information,
such as whether the attribute was specified in the
source text rather than defaulted.
|
use-locator2 |
read-only |
not applicable |
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 |
read/write |
true |
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 |
read/write |
unspecified |
Controls whether the parser is reporting all validity
errors; if true, all external entities will be read.
|
xmlns-uris |
read/write |
false |
Controls whether, when the namespace-prefixes feature
is set, the parser treats namespace declaration attributes as
being in the http://www.w3.org/2000/xmlns/ namespace.
By default, SAX2 conforms to the original "Namespaces in XML"
Recommendation, which explicitly states that such attributes are
not in any namespace.
Setting this optional flag to "true" makes the SAX2 events conform to
a later backwards-incompatible revision of that recommendation,
placing those attributes in a namespace.
|
xml-1.1 |
read-only |
not applicable |
Returns "true" if the parser supports both XML 1.1 and XML 1.0.
Returns "false" if the parser supports only XML 1.0.
|
Support for the default values of the
namespaces and namespace-prefixes
properties is required.
Support for any other feature flags is entirely optional.
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.
SAX2 Standard Handler and Property IDs
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.
|
document-xml-version |
May be examined only during a parse, after the startDocument()
callback has been completed; read-only. This property is a
literal string describing the actual XML version of the document,
such as "1.0" or "1.1".
|
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.
The Object must implement the
org.w3c.dom.Node interface.
|
lexical-handler |
Used to see some syntax events that are essential in some
applications: comments, CDATA delimiters, 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.
| Java Source File Name | Type | Comment | AttributeList.java | Interface | Interface for an element's attribute specifications.
This module, both source code and documentation, is in the
Public Domain, and comes with NO WARRANTY.
See http://www.saxproject.org
for further information.
This is the original SAX1 interface for reporting an element's
attributes. | Attributes.java | Interface | Interface for a list of XML attributes.
This module, both source code and documentation, is in the
Public Domain, and comes with NO WARRANTY.
See http://www.saxproject.org
for further information.
This interface allows access to a list of attributes in
three different ways:
- by attribute index;
- by Namespace-qualified name; or
- by qualified (prefixed) name.
The list will not contain attributes that were declared
#IMPLIED but not specified in the start tag. | ContentHandler.java | Interface | Receive notification of the logical content of a document.
This module, both source code and documentation, is in the
Public Domain, and comes with NO WARRANTY.
See http://www.saxproject.org
for further information.
This is the main interface that most SAX applications
implement: if the application needs to be informed of basic parsing
events, it implements this interface and registers an instance with
the SAX parser using the
org.xml.sax.XMLReader.setContentHandler setContentHandler method. | DocumentHandler.java | Interface | Receive notification of general document events.
This module, both source code and documentation, is in the
Public Domain, and comes with NO WARRANTY.
See http://www.saxproject.org
for further information.
This was the main event-handling interface for SAX1; in
SAX2, it has been replaced by
org.xml.sax.ContentHandlerContentHandler , which provides Namespace support and reporting
of skipped entities. | DTDHandler.java | Interface | Receive notification of basic DTD-related events.
This module, both source code and documentation, is in the
Public Domain, and comes with NO WARRANTY.
See http://www.saxproject.org
for further information.
If a SAX application needs information about notations and
unparsed entities, then the application implements this
interface and registers an instance with the SAX parser using
the parser's setDTDHandler method. | EntityResolver.java | Interface | Basic interface for resolving entities. | ErrorHandler.java | Interface | Basic interface for SAX error handlers.
This module, both source code and documentation, is in the
Public Domain, and comes with NO WARRANTY.
See http://www.saxproject.org
for further information.
If a SAX application needs to implement customized error
handling, it must implement this interface and then register an
instance with the XML reader using the
org.xml.sax.XMLReader.setErrorHandler setErrorHandler method. | HandlerBase.java | Class | Default base class for handlers.
This module, both source code and documentation, is in the
Public Domain, and comes with NO WARRANTY.
See http://www.saxproject.org
for further information.
This class implements the default behaviour for four SAX1
interfaces: EntityResolver, DTDHandler, DocumentHandler,
and ErrorHandler. | InputSource.java | Class | A single input source for an XML entity.
This module, both source code and documentation, is in the
Public Domain, and comes with NO WARRANTY.
See http://www.saxproject.org
for further information.
This class allows a SAX application to encapsulate information
about an input source in a single object, which may include
a public identifier, a system identifier, a byte stream (possibly
with a specified encoding), and/or a character stream.
There are two places that the application can deliver an
input source to the parser: as the argument to the Parser.parse
method, or as the return value of the EntityResolver.resolveEntity
method.
The SAX parser will use the InputSource object to determine how
to read XML input. | Locator.java | Interface | Interface for associating a SAX event with a document location.
This module, both source code and documentation, is in the
Public Domain, and comes with NO WARRANTY.
See http://www.saxproject.org
for further information.
If a SAX parser provides location information to the SAX
application, it does so by implementing this interface and then
passing an instance to the application using the content
handler's
org.xml.sax.ContentHandler.setDocumentLocatorsetDocumentLocator method. | Parser.java | Interface | Basic interface for SAX (Simple API for XML) parsers. | SAXException.java | Class | Encapsulate a general SAX error or warning.
This module, both source code and documentation, is in the
Public Domain, and comes with NO WARRANTY.
See http://www.saxproject.org
for further information.
This class can contain basic error or warning information from
either the XML parser or the application: a parser writer or
application writer can subclass it to provide additional
functionality. | SAXNotRecognizedException.java | Class | Exception class for an unrecognized identifier. | SAXNotSupportedException.java | Class | Exception class for an unsupported operation.
This module, both source code and documentation, is in the
Public Domain, and comes with NO WARRANTY.
See http://www.saxproject.org
for further information.
An XMLReader will throw this exception when it recognizes a
feature or property identifier, but cannot perform the requested
operation (setting a state or value). | SAXParseException.java | Class | Encapsulate an XML parse error or warning.
This module, both source code and documentation, is in the
Public Domain, and comes with NO WARRANTY.
See http://www.saxproject.org
for further information.
This exception may include information for locating the error
in the original XML document, as if it came from a
Locator object. | XMLFilter.java | Interface | Interface for an XML filter.
This module, both source code and documentation, is in the
Public Domain, and comes with NO WARRANTY.
See http://www.saxproject.org
for further information.
An XML filter is like an XML reader, except that it obtains its
events from another XML reader rather than a primary source like
an XML document or database. | XMLReader.java | Interface | Interface for reading an XML document using callbacks.
This module, both source code and documentation, is in the
Public Domain, and comes with NO WARRANTY.
See http://www.saxproject.org
for further information.
Note: despite its name, this interface does
not extend the standard Java
j2me.io.Reader Reader
interface, because reading XML is a fundamentally different activity
than reading character data.
XMLReader is the interface that an XML parser's SAX2 driver must
implement. |
|