All Packages  Class Hierarchy  This Package  Previous  Next  Index

Interface org.xml.sax.Parser

public interface Parser
A standard interface for event-driven XML parsers.

This interface is part of the Java implementation of SAX, the Simple API for XML. It is free for both commercial and non-commercial use, and is distributed with no warrantee, real or implied.

All SAX-conformant XML parsers (or their front-end SAX drivers) must implement this interface, together with a zero-argument constructor.

You can plug three different kinds of callback interfaces into a basic SAX parser: one for entity handling, one for basic document events, and one for error reporting. It is not an error to start a parse without setting any handlers.

Author:
David Megginson, Microstar Software Ltd.

Method Index

 o parse(String, String)
Parse an XML document.
 o setDocumentHandler(DocumentHandler)
Register the handler for basic document events.
 o setEntityHandler(EntityHandler)
Register the handler for basic entity events.
 o setErrorHandler(ErrorHandler)
Register the handler for errors and warnings.

Methods

 o setEntityHandler
 public abstract void setEntityHandler(EntityHandler handler)
Register the handler for basic entity events.

If you begin a parse without setting an entity handler, the parser will by default resolve all entities to their default system IDs.

Parameters:
handler - An object to receive callbacks for events.
See Also:
EntityHandler
 o setDocumentHandler
 public abstract void setDocumentHandler(DocumentHandler handler)
Register the handler for basic document events.

You may begin the parse without setting a handler, but in that case no document events will be reported.

Parameters:
handler - An object to receive callbacks for events.
See Also:
DocumentHandler
 o setErrorHandler
 public abstract void setErrorHandler(ErrorHandler handler)
Register the handler for errors and warnings.

If you begin a parse without setting an error handlers, warnings will be printed to System.err, and errors will throw an unspecified exception.

Parameters:
handler - An object to receive callbacks for errors.
See Also:
ErrorHandler
 o parse
 public abstract void parse(String publicID,
                            String systemID) throws Exception
Parse an XML document.

Nothing exciting will happen unless you have set handlers.

Parameters:
publicID - The public identifier for the document, or null if none is available.
systemID - The system identifier (URI) for the document.
Throws: Exception
This method may throw any exception, but the parser itself will throw only exceptions derived from java.io.IOException; anything else will come from your handlers.
See Also:
setEntityHandler, setDocumentHandler, setErrorHandler

All Packages  Class Hierarchy  This Package  Previous  Next  Index