25.3. SAX Features and Properties
URIs are used to
name a SAX parser's
properties and features. Features have a boolean value; that is, for
each parser, a recognized feature is either true or false. Properties
have object values. SAX defines six core features and two core
properties that parsers should recognize. In addition, parsers can
add features and properties to this list, and most do.
All SAX parsers
should recognize six core features. Of these six, two
must be implemented by all conformant processors. The other four are
optional and may not be implemented by all parsers:
this feature indicates that the
startElement( ) and endElement(
) methods provide namespace URIs and local names for
elements and attributes. When false, the parser provides prefixed
element and attribute names to the startElement( )
and endElement( ) methods. If a parser does not
provide something it is not required to provide, then that value will
be set to the empty string. However, most parsers provide all three
(URI, local name, and prefixed name) regardless of the value of this
feature. This feature is true by default.
When true, this feature indicates that xmlns and
will be included in the attributes list passed to
startElement( ). When false, these attributes are
omitted. Furthermore, if this feature is true, then the parser will
provide the prefixed names for elements and attributes. The default
is false unless
http://xml.org/sax/features/namespaces is false,
in which case this feature defaults to true. You can set both
to true to guarantee that local names, namespace URIs, and prefixed
names are all available.
When this feature is true, all
element names, prefixes, attribute names, namespace URIs, and local
names are internalized using the intern( ) method
of java.lang.String; that is, equal names compare
equally when using ==.
When true, the parser validates. When false, it
doesn't. The default is false for most parsers. If
you turn on this feature, you'll probably also want
to register an ErrorHandler with the
XMLReader to receive notice of any validity
When true, the parser resolves external
parsed general entities. When false, it doesn't. The
default is true for most parsers that can resolve external entities.
Turning on validation automatically activates this feature because
validation requires resolving external entities.
When true, the parser resolves external parameter
entities. When false, it doesn't. Turning on
validation automatically activates this feature because validation
requires resolving external entities.
two core properties, though implementations are not required to
This property's value is an
org.w3c.dom.Node object that represents the
current node the parser is visiting.
This property's value is a
java.lang.String object containing the characters
that were the source for the current event. As of mid-2001, no Java
parsers are known to implement this property.
Copyright © 2002 O'Reilly & Associates. All rights reserved.