Java API for XML Processing Specification 1.1: Package org.xml.sax.ext

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES

## Package org.xml.sax.ext

SAX2-ext: SAX2 Extension Handlers 1.0

See:
Description

Interface Summary
DeclHandler | SAX2 extension handler for DTD declaration events.
LexicalHandler | SAX2 extension handler for lexical events.

## Package org.xml.sax.ext Description

# SAX2-ext: SAX2 Extension Handlers 1.0

> This document is in the PUBLIC DOMAIN and comes with NO WARRANTY of any kind.

This package, SAX2-ext, is an extension package for SAX2. It is designed both to allow SAX drivers to pass certain types of none-core information to applications and to serve as a simple model for other SAX2 extension packages.

NOTE: this package alone does add any functionality; it simply provides optional interfaces for SAX2 drivers to use. You must find a SAX2 driver that supports these interfaces if you actually want to have access to lexical and declaration information.

The SAX2-ext package currently contains two extension handlers for SAX2:

1. LexicalHandler, which reports comments, the DOCTYPE declaration, CDATA sections, and (some) entity boundaries; and
2. DeclHandler, which reports element, attribute, and entity declarations.

This package is independent of the SAX2 core, and that independence has several consequences:

- SAX2 drivers are not required to support these handlers, and you cannot assume that the classes will be present in every SAX2 installation.
- This package may be updated independently of SAX2 (i.e. new handlers may be added without updating SAX2 itself).
- The handlers are not supported explicitly by the SAX2 XMLFilter interface (i.e. events are not passed on by default); you can subclass XMLFilter if you need such behaviour.
- The handlers need to be registered differently than regular SAX2 handlers.

To set a LexicalHandler, for example, you need to do something like this:

>     LexicalHandler lh = new MyLexicalHandler();
>     try {
>       xmlReader.setProperty("http://xml.org/sax/properties/lexical-handler",
>                             lh);
>     } catch (SAXException e) {
>       System.out.println("LexicalHandler not supported by this SAX2 driver.");
>     }

## SAX2-ext Properties

Here is a full definition of the two new SAX2 properties introduced in this version of SAX2-ext:

`http://xml.org/sax/properties/lexical-handler`
  data type: `org.xml.sax.ext.LexicalHandler`
  description: An optional extension handler for lexical events like comments.
  access: read/write
`http://xml.org/sax/properties/declaration-handler`
  data type: `org.xml.sax.ext.DeclHandler`
  description: An optional extension handler for DTD-related events other than notations and unparsed entities.
  access: read/write

See also: the package's JavaDoc documentation.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES