Core Features
The core set of features supported by SAX 2.0 XMLReader implementations is listed here. These features can be set through setFeature( ), and the value of a feature can be obtained through getFeature( ). Any feature can be read-only or read/write; features also may be modifiable only when parsing is occurring, or only when parsing is not occurring. For more information on SAX features and properties, refer to Chapter 4.
A.1.1. External General Entity Processing
This feature tells a parser whether or not to process external general entities, such as:
<!ENTITY copyright SYSTEM "legal/copyright.xml">
- URI: http://xml.org/sax/features/external-general-entities
- Access: read/write
- Default: unspecified; always TRue if the parser is validating (see the "Validation" section)
- Access: read/write
A.1.2. External Parameter Entity Processing
This feature tells a parser whether or not to process external parameter entities, used to define DTDs by a system and/or public ID (rather than directly in an XML document by location):
<!DOCTYPE tutorial [ <!ENTITY % tutorial SYSTEM "http://www.newInstance.com/dtd/book.dtd"> %book; ]>
- URI: http://xml.org/sax/features/external-parameter-entities
- Access: read/write
- Default: unspecified; always true if the parser is validating (see the "Validation" section)
- Access: read/write
A.1.3. Standalone
This feature reports whether a document is standalone, declared via the standalone attribute in the XML declaration:
<?xml version="1.0" standalone="yes"?>
- URI: http://xml.org/sax/features/is-standalone
- Access: read-only during parsing; not available otherwise
- Default: not applicable
- Access: read-only during parsing; not available otherwise
|
A.1.4. Parameter Entity Reporting
This features lets a parser know that parameter entity reporting (when they start, and when they stop) should be handled by a LexicalHandler (for more on LexicalHandlers, see Chapter 4, and the "Lexical Handler" property section).
- URI: http://xml.org/sax/features/lexical-handler/parameter-entities
- Access: read/write
- Default: unspecified
- Access: read/write
A.1.5. Namespace Processing
This feature instructs a parser to perform namespace processing, which causes namespace prefixes, namespace URIs, and element local names to be available through the SAX namespace callbacks (startPrefixMapping( ) and endPrefixMapping( ), as well as certain parameters supplied to startElement( ) and endElement( )). When this feature is true, the processing will occur. When false, namespace processing will not occur (this implies that "Namespace Prefix Reporting" is on).
- URI: http://xml.org/sax/features/namespaces
- Access: read/write
- Default: true
- Access: read/write
A.1.6. Namespace Prefix Reporting
This feature instructs a parser to report the attributes used in namespace declarations, such as the xmlns:[namespace URI] attributes. When this feature is not on (false), namespace-related attributes are not reported, as the parser consumes them in order to discover a namespace prefix to URI mappings, and they are generally not of value to the wrapping app in that context. In addition, when namespace processing is turned on, generally namespace prefix mapping is turned off.
- URI: http://xml.org/sax/features/namespace-prefixes
- Access: read-only when parsing, read/write when not parsing
- Default: false
- Access: read-only when parsing, read/write when not parsing
A.1.7. Absolute URI Declaration Resolution
If this feature is TRue, absolute paths are returned from the following methods (all on the DTDHandler interface, detailed in Chapter 4):
- notationDecl( )
- unparsedEntityDecl( )
- externalEntityDecl( )
|
- URI: http://xml.org/sax/features/resolve-dtd-uris
- Access: read/write
- Default: true
- Access: read/write
A.1.8. String Interning
This feature dictates that all element raw and local names, namespace prefixes, and namespace URIs are interned using java.lang. String.intern( ). When not on (false), all XML components are left as is.
- URI: http://xml.org/sax/features/string-interning
- Access: read-only when parsing, read/write when not parsing
- Default: unspecified; newer, high-performance parsers usually have this set to false by default, so they can perform their own optimizations for dealing with character data
- Access: read-only when parsing, read/write when not parsing
A.1.9. Unicode Normalization Checking
Related largely to XML 1.1, this feature indicates whether a parser should report Unicode normalization errors (defined in section 2.13 and Appendix B of the XML 1.1 specification). If set to true, these errors are made visible via the error( ) callback on ErrorHandler.
- URI: http://xml.org/sax/features/validation
- Access: read-write
- Default: false
- Access: read-write
A.1.10. Attributes2 Usage
SAX 2 defines an "enhanced" version of several core SAX interfaces in org.xml.sax.ext; the Attributes2 interface is one of those (it exposes extra constraint-related information, particularly about attributes). You can check to see if your parser is returning an implementation of this interfaceand not of the normal Attributes interfacewith this feature.
- URI: http://xml.org/sax/features/use-attributes2
- Access: read-only
- Default: not applicable
- Access: read-only
A.1.11. Locator2 Usage
Like the Attributes2 interface (see the previoius section, "Attributes2 Usage"), Locator2 is an enhanced version of Locator. Located in the org.xml.sax.ext package, this interface provides information about entity character encoding (and in some cases, the XML version of parameter entities). You can check to see if your parser is returning an implementation of this interfaceand not of the normal Locator interfacewith this feature.
- URI: http://xml.org/sax/features/use-locator2
- Access: read-only
- Default: not applicable
- Access: read-only
A.1.12. EntityResolver2 Usage
EntityResolver2 is another of the enhanced interfaces defined in org.xml.sax.ext. You can determine if your parser is returning an implementation of this interfaceand not of EntityResolverwith this feature. This feature can also be set, specifying that the extra methods defined by EntityResolver2 should be used (assuming your parser supports them).
- URI: http://xml.org/sax/features/use-entity-resolver2
- Access: read/write
- Default: true
- Access: read/write
A.1.13. Validation
This feature requests that validation occur and that any errors as a result of broken constraints be reported through the SAX ErrorHandler interface (if an implementation is registered). When set to false, no validation occurs, which is generally the default setting. You'll need to check your parser vendor's documentation to determine if this feature applies to both DTD and XML Schema validation.
- URI: http://xml.org/sax/features/validation
- Access: read-only when parsing; read/write when not parsing
- Default: unspecified
- Access: read-only when parsing; read/write when not parsing
A.1.14. Report Namespace on xmlns Attributes
If this feature is true, xmlns attributes are reported as being in http://www.w3.org/2000/xmlns/namespace. The namespaces in the XML recommendation specified that these attributes are not in a namespace, but an earlier version of that specification defined them as in the above namespace.
|
- URI: http://xml.org/sax/features/xmlns-uris
- Access: read/write
- Default: false
- Access: read/write
A.1.15. XML 1.1 Support
This feature will return true if the parser supports XML 1.1 (and XML 1.0, obviously); otherwise, if only XML 1.0 is supported, it returns false.
- URI: http://xml.org/sax/features/xml-1.1
- Access: read-only
- Default: not applicable
- Access: read-only