:mod:`xml.sax.handler` --- Base classes for SAX handlers
The SAX API defines four kinds of handlers: content handlers, DTD handlers, error handlers, and entity resolvers. Applications normally only need to implement those interfaces whose events they are interested in; they can implement the interfaces in a single object or in multiple objects. Handler implementations should inherit from the base classes provided in the module :mod:`xml.sax.handler`, so that all methods get default implementations.
This is the main callback interface in SAX, and the one most important to applications. The order of events in this interface mirrors the order of the information in the document.
Handle DTD events.
This interface specifies only those DTD events required for basic parsing (unparsed entities and attributes).
Basic interface for resolving entities. If you create an object implementing this interface, then register the object with your Parser, the parser will call the method in your object to resolve all external entities.
Interface used by the parser to present error and warning messages to the application. The methods of this object control whether errors are immediately converted to exceptions or are handled in some other way.
In addition to these classes, :mod:`xml.sax.handler` provides symbolic constants for the feature and property names.
ContentHandler Objects
Users are expected to subclass :class:`ContentHandler` to support their application. The following methods are called by the parser on the appropriate events in the input document:
DTDHandler Objects
:class:`DTDHandler` instances provide the following methods:
EntityResolver Objects
ErrorHandler Objects
Objects with this interface are used to receive error and warning information from the :class:`~xml.sax.xmlreader.XMLReader`. If you create an object that implements this interface, then register the object with your :class:`~xml.sax.xmlreader.XMLReader`, the parser will call the methods in your object to report all warnings and errors. There are three levels of errors available: warnings, (possibly) recoverable errors, and unrecoverable errors. All methods take a :exc:`SAXParseException` as the only parameter. Errors and warnings may be converted to an exception by raising the passed-in exception object.