Listing 1. A Useful Subset of Methods in ContentHandler /** * Receive notification of the beginning of a document. * *

The SAX parser will invoke this method only once, before any * other methods in this interface or in * {@link org.xml.sax.DTDHandler DTDHandler} * (except for {@link #setDocumentLocator * setDocumentLocator}).

*/ public void startDocument () throws SAXException; /** * Receive notification of the end of a document. * *

The SAX parser will invoke this method only once, and it * will be the last method invoked during the parse. * The parser shall not invoke this method until it has either * abandoned parsing (because of an unrecoverable error) or * reached the end of input.

*/ public void endDocument() throws SAXException; /** * Receive notification of the beginning of an element. * *

The Parser will invoke this method at the beginning of every * element in the XML document; there will be a corresponding * {@link #endElement endElement} event for every startElement event * (even when the element is empty). All of the element's content * will be reported, in order, before the corresponding endElement * event.

*/ public void startElement (String namespaceURI, String localName, String qName, Attributes atts)throws SAXException; /** * Receive notification of the end of an element. * *

The SAX parser will invoke this method at the end of every * element in the XML document; there will be a corresponding * {@link #startElement startElement} event for every endElement * event (even when the element is empty).

*/ public void endElement (String namespaceURI, String localName, String qName) throws SAXException; /** * Receive notification of character data. * *

The Parser will call this method to report each chunk of * character data. SAX parsers may return all contiguous character * data in a single chunk, or they may split it into several * chunks; however, all of the characters in any single event * must come from the same external entity so that the Locator * provides useful information.

*/ public void characters (char ch[], int start, int length) throws SAXException;