View RSS Feed

Java XML

Java SAX DefaultHandler Exceptions

Rate this Entry
by , 04-27-2012 at 05:16 PM (1017 Views)
The DefaultHandler class has three methods you can override to handle exceptions encountered during the XML parsing. Here they are:
Java Code:
public void warning(SAXParseException e) throws SAXException {
}

public void error(SAXParseException e) throws SAXException {
}

public void fatalError(SAXParseException e) throws SAXException {
}
Let's say that the parser encounters an illegal XML entity (like &notLegal;). The SAXParser will then call the fatalError() method, before breaking the parsing.
If a less dangerous error occurs, the SAXParser may just call the error() or warning() method. That way you can collect all the errors in a list, and return them all at once, instead of one by one, as they are met.

Submit "Java SAX DefaultHandler Exceptions" to Facebook Submit "Java SAX DefaultHandler Exceptions" to Digg Submit "Java SAX DefaultHandler Exceptions" to del.icio.us Submit "Java SAX DefaultHandler Exceptions" to StumbleUpon Submit "Java SAX DefaultHandler Exceptions" to Google

Categories
SAX.

Comments