Multihandler Adapters

The callback interfaces in SAX are reminiscent of the callback interfaces in the AWT, such as ActionListener and MouseListener. There is, however, one crucial difference between the patterns that the two callback interfaces follow. The AWT allows you to register multiple listener objects with any one component, whereas SAX limits you to just one listener of a certain type per parser. Filters allow you to parse a document through several listeners in turn. However, sometimes it's desirable to install multiple handlers that are not filters.

For example, the DocBook XML source for this book is parsed multiple times to produce HTML, XHTML, PDF, and several other output formats. Each time a new output format is required, the ...

Get Processing XML with Java™: A Guide to SAX, DOM, JDOM, JAXP, and TrAX 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.