This is just a short description on the various classes & interfaces that help you write an application, which can parse an XML document. The SAX API consists of the foll. packages :-
org.xml.sax - This package contains the basic interfaces of the SAX API. Some of the interfaces that allow a Java application to receive notification when a SAX parser parses an XML document are :-
1) ContentHandler Interface - It provides various call back methods that are invoked when a SAX parser parses an XML document. The various methods declared in ContentHandler interface are - startDocument(), endDocument(), startElement(), endElement(), ignorableWhitespace().
2)ErrorHandler Interface - It defines the various callback methods to handle any error that might occur during parsing. The various methods defined by the ErrorHandler interface are - warning(), error(), fatalError().
3)DTDHandler Interface - It defines methods to receive notification when a parser processesth Document Type Definition(DTD) of an XML document. These methods identify the declarations for those entities that are marked as notations, such as graphics & image files. Notations represent the binary data entities in an XML document that cannot be parsed. Various methods defined are :- notationDecl(), unparsedEntityDecl().
The org.xml.sax.ext package defines the various SAX extensions that you can use in a Java program to perform advanced SAX processing. The interfaces defined in the org.xml.sax.ext package enables you to perform tasks, such as to access the lexical & DTD declaration information of an XML document. Two of the interfaces defined in this package are :-
1) DeclHandler - Declares the method that provide notification about the DTD declarations in an XML document.
2) LexicalHandler - Declares the methods that provide notification about the lexical events in an XML document.
The org.xml.sax.helpers package defines the various helper classes of SAX API. For example, the DefaultHandler class of the org.xml.sax.helper package implements the ContentHandler, DTDHandler, EntityResolver & ErrorHandler interfaces. You can extend the DefaultHandler class when you want to overide only the required methods of the interfaces in your Java application.
The javax.xml.parsers package is a collection of classes that enable Java applications to process XML documents by using either SAX or DOM parsers. Some of the classes of the javax.xml.parsers package specific to SAX are :-
1) SAXParser - It allows parsing of XML documents.
2) SAXParserFactory - Enables you to retreive an object of SAXParsers.