APIdia Launch Partner
Top Description Methods
javax.xml.transform

public Interface ErrorListener

Known Direct Implementers
com.sun.org.apache.xml.internal.utils.DefaultErrorHandler, com.sun.org.apache.xml.internal.utils.ListingErrorHandler, jdk.xml.internal.TransformErrorListener

The listener interface used by a TransformerFactory or Transformer to notify callers of error messages that occur during a transformation process. An ErrorListener receives three levels of messages: warnings, errors and fatal errors as classified by their severity. Each of them is handled as described in their respective method.

An ErrorListener instance can be registered to a TransformerFactory or Transformer through the TransformerFactory#setErrorListener(ErrorListener) or Transformer#setErrorListener(ErrorListener) method to receive errors and warnings reported by the TransformerFactory or Transformer.

When a listener is registered, the TransformerFactory or Transformer must use this interface to pass on all warnings and errors to the listener and let the application decide how to handle them. Note that the TransformerFactory or Transformer is not required to continue with the transformation after a call to fatalError(TransformerException exception).

If an application does not provide a listener, the TransformerFactory or Transformer shall create one on its own. The default ErrorListener may take no action for warnings and recoverable errors, and allow the transformation to continue. However, the TransformerFactory or Transformer may still throw TransformerException when it decides it can not continue processing.

API Note

It is recommended that applications register and use their own ErrorListener to override the default behavior in order to ensure proper handling of warnings and errors.

Since
1.4

Method Summary

Modifier and TypeMethod and Description
public void
error(TransformerException
The error information encapsulated in a transformer exception.
exception
)

Receive notification of a recoverable error.

public void
fatalError(TransformerException
The error information encapsulated in a TransformerException.
exception
)

Receive notification of a non-recoverable error.

public void
warning(TransformerException
The warning information encapsulated in a transformer exception.
exception
)

Receive notification of a warning.

Method Detail

errorback to summary
public void error(TransformerException exception) throws TransformerException

Receive notification of a recoverable error.

The transformer must continue to try and provide normal transformation after invoking this method. It should still be possible for the application to process the document through to the end if no other errors are encountered.

Parameters
exception:TransformerException

The error information encapsulated in a transformer exception.

Exceptions
TransformerException:
if the application chooses to discontinue the transformation.
See Also
javax.xml.transform.TransformerException
fatalErrorback to summary
public void fatalError(TransformerException exception) throws TransformerException

Receive notification of a non-recoverable error.

The processor may choose to continue, but will not normally proceed to a successful completion.

The method should throw an exception if it is unable to process the error, or if it wishes execution to terminate immediately. The processor will not necessarily honor this request.

Parameters
exception:TransformerException

The error information encapsulated in a TransformerException.

Exceptions
TransformerException:
if the application chooses to discontinue the transformation.
See Also
javax.xml.transform.TransformerException
warningback to summary
public void warning(TransformerException exception) throws TransformerException

Receive notification of a warning.

javax.xml.transform.Transformer can use this method to report conditions that are not errors or fatal errors. The default behaviour is to take no action.

After invoking this method, the Transformer must continue with the transformation. It should still be possible for the application to process the document through to the end.

Parameters
exception:TransformerException

The warning information encapsulated in a transformer exception.

Exceptions
TransformerException:
if the application chooses to discontinue the transformation.
See Also
javax.xml.transform.TransformerException