DTDHandler

SAX is mostly about the instance document, not the DTD or schema. However, given a validating parser, or at least an internal DTD subset, the DTD can affect the contents of the instance document in six ways:

1. It can provide default values for attributes.

2. It can assign types to attributes which affects their normalized value.

3. It can distinguish between ignorable and non-ignorable white space.

4. It can declare general entities.

5. It can declare unparsed entities.

6. It can declare notations.

The first four are resolved silently. For instance, when applying a default value for an attribute to an element, the parser simply adds that attribute to the Attributes object it passes to startElement(). It doesn't tell you that it's done it. It just does it.

The DTDHandler interface covers the last two. Since notations and unparsed entities are so infrequently used, they're not made a part of the main ContentHandler interface. Instead they're given their own callback interface that's just for working with notations and unparsed entities, DTDHandler. This is summarized in Example 7.16 Those few programmers who need this functionality can use it. Everyone else can ignore it.

0 0

Post a comment

  • Receive news updates via email from this site