10.4. The HandlerBase Class

Four of the seven SAX interfaces are concerned with document handling:

  • DocumentHandler

  • ErrorHandler

  • DTDHandler

  • EntityResolver

We will take a close look at the first two of these later on. Together, these four interfaces comprise 14 different methods for handling aspects of document processing. The HandlerBase class implements default methods for all four interfaces. That is, all 14 methods required by the interfaces are defined, but they do not do anything.

Why is this useful? It is useful because it makes writing SAX applications very easy—simply make your class inherit from HandlerBase and you have implemented all four interfaces. You can simply override the methods that you actually need rather than provide stub implementions ...

Get XML Processing with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.