The SAXParser class is a wrapper around an org.xml.sax.XMLReader class and is used to parse XML documents using the SAX version 2 API. Obtain a SAXParser from a SAXParserFactory . Call setProperty( ) if desired to set a property on the underlying parser. (See www.saxproject.org for a description of standard SAX properties and their values. Finally, call one of the parse( ) methods to parse an XML document from a stream, file, URL, or org.xml.sax.InputSource . The SAX API is an event-driven one. A SAX parser does not build a document tree to describe an XML document like a DOM parser does. Instead, it describes the XML document to your application by invoking methods on an object the application provides. This is the purpose of the org.xml.sax.helpers.DefaultHandler object that is passed to the parse( ) method: you subclass this class to implement the methods you care about, and the parser will invoke those methods at appropriate times. For example, when the parser encounters an XML tag in a document, it parses the tag, and calls the startElement( ) method to tell you about it. And when it finds a run of plain text, it passes that text to the characters ( ) method. In Java 5.0, the reset( ) method restores a SAXParser to its original state so that it can be reused. Instead of using one of the parse( ) methods of this class, you can also call getXMLReader( ) to obtain the underlying XMLReader object and work with it directly to parse the desired document. SAXParser objects are not typically threadsafe. Note that the getParser( ) method as well as the parse( ) methods that take an org.xml.sax.HandlerBase object are based on the SAX version 1 API, and should be avoided. public abstract class SAXParser { // Protected Constructors protected SAXParser ( ); // Public Instance Methods public abstract org.xml.sax.Parser getParser ( ) throws org.xml.sax.SAXException; public abstract Object getProperty (String name ) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException; 5.0 public javax.xml.validation.Schema getSchema ( ); public abstract org.xml.sax.XMLReader getXMLReader ( ) throws org.xml.sax.SAXException; public abstract boolean isNamespaceAware ( ); public abstract boolean isValidating ( ); 5.0 public boolean isXIncludeAware ( ); public void parse (org.xml.sax.InputSource is , org.xml.sax.HandlerBase hb ) throws org.xml.sax.SAXException, java.io.IOException; public void parse (org.xml.sax.InputSource is , org.xml.sax.helpers.DefaultHandler dh ) throws org.xml.sax.SAXException, java.io.IOException; public void parse (java.io.File f , org.xml.sax.helpers.DefaultHandler dh ) throws org.xml.sax.SAXException, java.io.IOException; public void parse (java.io.InputStream is , org.xml.sax.helpers.DefaultHandler dh ) throws org.xml.sax.SAXException, java.io.IOException; public void parse (java.io.InputStream is , org.xml.sax.HandlerBase hb ) throws org.xml.sax.SAXException, java.io.IOException; public void parse (String uri , org.xml.sax.HandlerBase hb ) throws org.xml.sax.SAXException, java.io.IOException; public void parse (String uri , org.xml.sax.helpers.DefaultHandler dh ) throws org.xml.sax.SAXException, java.io.IOException; public void parse (java.io.File f , org.xml.sax.HandlerBase hb ) throws org.xml.sax.SAXException, java.io.IOException; public void parse (java.io.InputStream is , org.xml.sax.HandlerBase hb , String systemId ) throws org.xml.sax.SAXException, java.io.IOException; public void parse (java.io.InputStream is , org.xml.sax.helpers.DefaultHandler dh , String systemId ) throws org.xml.sax.SAXException, java.io.IOException; 5.0 public void reset ( ); public abstract void setProperty (String name , Object value ) throws org.xml.sax.SAXNotRecognizedException, org.xml.sax.SAXNotSupportedException; } Returned BySAXParserFactory.newSAXParser( ) |