| Method from org.apache.xerces.util.ErrorHandlerWrapper Detail: |
protected static SAXParseException createSAXParseException(XMLParseException exception) {
return new SAXParseException(exception.getMessage(),
exception.getPublicId(),
exception.getExpandedSystemId(),
exception.getLineNumber(),
exception.getColumnNumber(),
exception.getException());
}
Creates a SAXParseException from an XMLParseException. |
protected static XMLParseException createXMLParseException(SAXParseException exception) {
final String fPublicId = exception.getPublicId();
final String fExpandedSystemId = exception.getSystemId();
final int fLineNumber = exception.getLineNumber();
final int fColumnNumber = exception.getColumnNumber();
XMLLocator location = new XMLLocator() {
public String getPublicId() { return fPublicId; }
public String getExpandedSystemId() { return fExpandedSystemId; }
public String getBaseSystemId() { return null; }
public String getLiteralSystemId() { return null; }
public int getColumnNumber() { return fColumnNumber; }
public int getLineNumber() { return fLineNumber; }
public int getCharacterOffset() { return -1; }
public String getEncoding() { return null; }
public String getXMLVersion() { return null; }
};
return new XMLParseException(location, exception.getMessage(),exception);
}
Creates an XMLParseException from a SAXParseException. |
protected static XNIException createXNIException(SAXException exception) {
return new XNIException(exception.getMessage(),exception);
}
Creates an XNIException from a SAXException.
NOTE: care should be taken *not* to call this with a SAXParseException; this will
lose information!!! |
public void error(String domain,
String key,
XMLParseException exception) throws XNIException {
if (fErrorHandler != null) {
SAXParseException saxException = createSAXParseException(exception);
try {
fErrorHandler.error(saxException);
}
catch (SAXParseException e) {
throw createXMLParseException(e);
}
catch (SAXException e) {
throw createXNIException(e);
}
}
}
Reports an error. Errors are non-fatal and usually signify that the
document is invalid with respect to its grammar(s). |
public void fatalError(String domain,
String key,
XMLParseException exception) throws XNIException {
if (fErrorHandler != null) {
SAXParseException saxException = createSAXParseException(exception);
try {
fErrorHandler.fatalError(saxException);
}
catch (SAXParseException e) {
throw createXMLParseException(e);
}
catch (SAXException e) {
throw createXNIException(e);
}
}
}
Report a fatal error. Fatal errors usually occur when the document
is not well-formed and signifies that the parser cannot continue
normal operation.
Note: The error handler should always
throw an XNIException from this method. This exception
can either be the same exception that is passed as a parameter to
the method or a new XNI exception object. If the registered error
handler fails to throw an exception, the continuing operation of
the parser is undetermined. |
public ErrorHandler getErrorHandler() {
return fErrorHandler;
}
Returns the SAX error handler. |
public void setErrorHandler(ErrorHandler errorHandler) {
fErrorHandler = errorHandler;
}
Sets the SAX error handler. |
public void warning(String domain,
String key,
XMLParseException exception) throws XNIException {
if (fErrorHandler != null) {
SAXParseException saxException = createSAXParseException(exception);
try {
fErrorHandler.warning(saxException);
}
catch (SAXParseException e) {
throw createXMLParseException(e);
}
catch (SAXException e) {
throw createXNIException(e);
}
}
}
Reports a warning. Warnings are non-fatal and can be safely ignored
by most applications. |