1. /*
  2. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  3. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  4. */
  5. package javax.xml.transform;
  6. /**
  7. * <p>To provide customized error handling, implement this interface and
  8. * use the setErrorListener method to register an instance of the implmentation
  9. * with the {@link javax.xml.transform.Transformer}. The Transformer then reports
  10. * all errors and warnings through this interface.</p>
  11. *
  12. * <p>If an application does <em>not</em>
  13. * register an ErrorListener, errors are reported to System.err.</p>
  14. *
  15. * <p>For transformation errors, a Transformer must use this interface
  16. * instead of throwing an exception: it is up to the application
  17. * to decide whether to throw an exception for different types of
  18. * errors and warnings. Note however that the Transformer is not required
  19. * to continue with the transformation after a call to fatalError.</p>
  20. *
  21. * <p>Transformers may use this mechanism to report XML parsing errors
  22. * as well as transformation errors.</p>
  23. */
  24. public interface ErrorListener {
  25. /**
  26. * Receive notification of a warning.
  27. *
  28. * <p>{@link javax.xml.transform.Transformer} can use this method to report
  29. * conditions that are not errors or fatal errors. The default behaviour
  30. * is to take no action.</p>
  31. *
  32. * <p>After invoking this method, the Transformer must continue with
  33. * the transformation. It should still be possible for the
  34. * application to process the document through to the end.</p>
  35. *
  36. * @param exception The warning information encapsulated in a
  37. * transformer exception.
  38. *
  39. * @throws javax.xml.transform.TransformerException if the application
  40. * chooses to discontinue the transformation.
  41. *
  42. * @see javax.xml.transform.TransformerException
  43. */
  44. public abstract void warning(TransformerException exception)
  45. throws TransformerException;
  46. /**
  47. * Receive notification of a recoverable error.
  48. *
  49. * <p>The transformer must continue to try and provide normal transformation
  50. * after invoking this method. It should still be possible for the
  51. * application to process the document through to the end if no other errors
  52. * are encountered.</p>
  53. *
  54. * @param exception The error information encapsulated in a
  55. * transformer exception.
  56. *
  57. * @throws javax.xml.transform.TransformerException if the application
  58. * chooses to discontinue the transformation.
  59. *
  60. * @see javax.xml.transform.TransformerException
  61. */
  62. public abstract void error(TransformerException exception)
  63. throws TransformerException;
  64. /**
  65. * Receive notification of a non-recoverable error.
  66. *
  67. * <p>The transformer must continue to try and provide normal transformation
  68. * after invoking this method. It should still be possible for the
  69. * application to process the document through to the end if no other errors
  70. * are encountered, but there is no guarantee that the output will be
  71. * useable.</p>
  72. *
  73. * @param exception The error information encapsulated in a
  74. * transformer exception.
  75. *
  76. * @throws javax.xml.transform.TransformerException if the application
  77. * chooses to discontinue the transformation.
  78. *
  79. * @see javax.xml.transform.TransformerException
  80. */
  81. public abstract void fatalError(TransformerException exception)
  82. throws TransformerException;
  83. }