
implements the ContentHandler interface. To use DefaultHandler, create a subclass and override the methods that interest you. The other methods can safely be ignored, since they are just empty methods.
The ParserAdapter class makes a SAX1 Parser behave as a SAX2 XMLReader. The XMLReaderAdapter class makes a SAX2 XML reader behave as a SAX1 parser. The two classes should ease the transition from SAX1 to SAX2 by allowing SAX1 drivers and clients to
XML namespace support
SAX2 adds XML namespace support. Every implementation of the SAX2 XMLReader interface is required to support namespace processing in its default state. Additionally, many XML readers allow namespace processing to be modified or disabled. Namespace processing changes only element and attribute naming, although it places restrictions on some other names. Each XML element and attribute has a single name called the qName which may contain colons. With namespaces, elements and attributes have
SAX2 is capable of supporting either of these views or both simultaneously. Similarly, documents may use both views simultaneously. SAX2 XMLReader implementations are required to report the namespace style names when documents use them.
Namespace support affects the ContentHandler and Attributes interfaces. In SAX2, the startElement and endElement callbacks in a content handler look like Example
Example 3-3 SAX2 callback methods
public void startElement (String uri, String localName,String qName, Attributes atts) throws SAXException;
public void endElement (String uri, String localName, String qName) throws SAXException;
By default, an XML reader will report a namespace URI and a local name for every element that belongs to a namespace, in both the start and end handler. Consider Example
Example 3-4 Sample namespace
<html:hr xmlns:html="http://www.ibm.com"/>
Chapter 3. Processing XML 61