An XMLFilter extends XMLReader and behaves like an XMLReader except that instead of parsing a document itself, it filters the SAX events provided by a "parent" XMLReader object. Use the setParent( ) method to link an XMLFilter object to the XMLReader that it is to serve as a filter for. An XMLFilter serves as both a source of SAX events, and also as a receipient of those events, so an implementation must implement ContentHandler and related interfaces so that it can obtain events from the parent object, filter them, and then pass the filtered events on to the ContentHandler object that was registered on the filter. See the helper class org.xml.sax.helpers.XMLFilterImpl for a bare-bones implementation of an XMLFilter that implements the XMLReader interface and the ContentHandler and related handler interfaces. XMLFilterImpl does no filteringit simply passes passes all of its method invocations through. You can subclass it and override only the methods that need filtering. Figure 22-6. org.xml.sax.XMLFilterpublic interface XMLFilter extends XMLReader { // Public Instance Methods XMLReader getParent ( ); void setParent (XMLReader parent ); } Implementationsorg.xml.sax.helpers.XMLFilterImpl Returned Byjavax.xml.transform.sax.SAXTransformerFactory.newXMLFilter( ) |