ErrorHandler (interface)

The parser reports all error messages through this interface, you can choose to ignore exceptions by not throwing them or to stop processing by throwing them.

  • Reports a Warning while parsing the XML.

    warning( SAXParseException exception)

    Note

    The only warnings I'm aware of is the re-declaration of an entity.
  • Reports an Error while parsing the XML.

    error( SAXParseException exception)

    Note

    Reports mainly validating errors.
  • Reports a Fatal Error while parsing the XML.

    fatal-error( SAXParseException exception)

    Note

    Reports mainly well-formedness errors.
  • Example: Error Handler that forces the underlying parser to stop processing when an error or warning has been reported.

    import org.xml.sax.SAXParseException;
    import org.xml.sax.ErrorHandler;
    
    public class DefaultErrorHandler implements ErrorHandler {
      public void error( SAXParseException e) throws SAXParseException {
        throw e;
      }
      
      public void warning( SAXParseException e) throws SAXParseException {
        throw e;
      }
      
      public void fatalError( SAXParseException e) throws SAXParseException {
        throw e; 
      }
    }
    					

Note

Other error messages (application/contenthandler implementation specific) can be reported as well using this interface.