Summary

SAX filters sit between a client application and a parser (XMLReader) and intercept calls from the client application to the parser. SAX filters are instances of implementations of the org.xml.sax.XMLFilter interface, a subinterface of XMLReader. Thus a SAX filter is also a parser, albeit one that receives its data from another XML parser rather than by directly reading an XML document.

The easiest way to write a SAX filter is to subclass org.xml.sax.helpers. XMLfilterImpl, which implements several interfaces including XMLFilter, ContentHandler, DTDHandler, and ErrorHandler. org.xml.sax.helpers.XMLFilterImpl intercepts calls in both directions, from the client to the parser and from the parser to the client. The default behavior of this ...

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.