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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.