Using ErrorHandler Interface Methods
A default error handler is embedded when a filter is constructed. You can retrieve the error handler using a getErrorHandlerResource call in the FilterControl interface.
In the grep filter example, the getErrorHandlerResource call returns the embedded error handler.
SAXParseException ex =
new SAXParseException
(currString.substring(matchStartIndex,
matchEndIndex),
getDocumentLocator());
getErrorHandlerResource().warning(ex);
//Reset the current string to avoid duplicate
//matches in subsequent character method calls.
currString.setLength(0);
}
} // characters(...)
The warning method takes org.xml.sax.SAXParseException as its argument. SAXParseException contains location information for the current document. The location information lets users link from the event log to the string in the document.
Refer to
ErrorHandler Interface for more information on the ErrorHandler interface, and
grep Filter Example for the entire
grep filter example.