This interface is the key one for XML parsing with the SAX API. An XMLReader tells your application about the content of the XML document it is parsing by invoking the various methods of the ContentHandler interface. In order to parse documents with SAX, you must implement this interface to define methods that take whatever actions are necessary when they are invoked by the parser. Because this interface is so critical to the SAX API, the methods are explained individually below:
DTDHandler is another interface like ContentHandler . An application can implement this interface to receive notification of DTD- related events from the parser. Similarly, the org.xml.sax.ext package defines two "extension" interfaces that can be used (if the parser supports these extensions) to obtain even more information about the document (such as comments and CDATA sections) and about the DTD (including the full set of element, attribute and entity declarations). The org.xml.sax.helpers.DefaultHandler class is a useful one. It implements ContentHandler and three other interfaces that are commonly used with the XMLReader class and provides empty implementations of all their methods. Applications can subclass DefaultHandler only need to override the methods they care about. This is usually more convenient that implementing the interfaces directly. public interface ContentHandler { // Public Instance Methods void characters (char[ ] ch , int start , int length ) throws SAXException; void endDocument ( ) throws SAXException; void endElement (String uri , String localName , String qName ) throws SAXException; void endPrefixMapping (String prefix ) throws SAXException; void ignorableWhitespace (char[ ] ch , int start , int length ) throws SAXException; void processingInstruction (String target , String data ) throws SAXException; void setDocumentLocator (Locator locator ); void skippedEntity (String name ) throws SAXException; void startDocument ( ) throws SAXException; void startElement (String uri , String localName , String qName , org.xml.sax.Attributes atts ) throws SAXException; void startPrefixMapping (String prefix , String uri ) throws SAXException; } Implementationsjavax.xml.transform.sax.TemplatesHandler , javax.xml.transform.sax.TransformerHandler , javax.xml.validation.ValidatorHandler , org.xml.sax.helpers.DefaultHandler , org.xml.sax.helpers.XMLFilterImpl , org.xml.sax.helpers.XMLReaderAdapter Passed Tojavax.xml.transform.sax.SAXResult.{SAXResult( ) , setHandler( )} , javax.xml.validation.ValidatorHandler.setContentHandler( ) , XMLReader.setContentHandler( ) , org.xml.sax.helpers.ParserAdapter.setContentHandler( ) , org.xml.sax.helpers.XMLFilterImpl.setContentHandler( ) Returned Byjavax.xml.transform.sax.SAXResult.getHandler( ) , javax.xml.validation.ValidatorHandler.getContentHandler( ) , XMLReader.getContentHandler( ) , org.xml.sax.helpers.ParserAdapter.getContentHandler( ) , org.xml.sax.helpers.XMLFilterImpl.getContentHandler( ) |