Module java.xml
Package org.xml.sax

Interface ContentHandler

All Known Subinterfaces:
TemplatesHandler, TransformerHandler
All Known Implementing Classes:
DefaultHandler, DefaultHandler2, ValidatorHandler, XMLFilterImpl, XMLReaderAdapter

public interface ContentHandler
Receive notification of the logical content of a document.

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 setContentHandler method. The parser uses the instance to report basic document-related events like the start and end of elements and character data.

The order of events in this interface is very important, and mirrors the order of information in the document itself. For example, all of an element's content (character data, processing instructions, and/or subelements) will appear, in order, between the startElement event and the corresponding endElement event.

This interface is similar to the now-deprecated SAX 1.0 DocumentHandler interface, but it adds support for Namespaces and for reporting skipped entities (in non-validating XML processors).

Implementors should note that there is also a ContentHandler class in the java.net package; that means that it's probably a bad idea to do

import java.net.*;
 import org.xml.sax.*;
 

In fact, "import ...*" is usually a sign of sloppy programming anyway, so the user should consider this a feature rather than a bug.

Since:
1.4, SAX 2.0
See Also: