Transformer.java 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /* Transformer.java --
  2. Copyright (C) 2004, 2005 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package javax.xml.transform;
  32. import java.util.Properties;
  33. /**
  34. * An XSL transformation.
  35. * Instances of this class may be reused, but the same instance may not be
  36. * used concurrently by different threads.
  37. *
  38. * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a)
  39. */
  40. public abstract class Transformer
  41. {
  42. protected Transformer()
  43. {
  44. }
  45. /**
  46. * Transforms the source XML to a result tree.
  47. * @param xmlSource the XML source
  48. * @param outputTarget the result of the transformation
  49. */
  50. public abstract void transform(Source xmlSource, Result outputTarget)
  51. throws TransformerException;
  52. /**
  53. * Sets a parameter value for the transformation.
  54. * Parameters may be referenced in the XSLT stylesheet.
  55. * @param name the parameter name (an XML Name, or a namespace-prefixed
  56. * XML Name of the form <code>{<i>namespaceURI</i>}<i>localName</i></code>
  57. * @param value the value to assign
  58. */
  59. public abstract void setParameter(String name, Object value);
  60. /**
  61. * Returns the specified parameter value.
  62. * @param name the parameter name (an XML Name, or a namespace-prefixed
  63. * XML Name of the form <code>{<i>namespaceURI</i>}<i>localName</i></code>
  64. */
  65. public abstract Object getParameter(String name);
  66. /**
  67. * Clears all parameter values.
  68. */
  69. public abstract void clearParameters();
  70. /**
  71. * Sets the callback used to resolve entities referenced by
  72. * <code>xsl:include</code>, <code>xsl:import</code>, or the XPath
  73. * <code>document()</code> function.
  74. */
  75. public abstract void setURIResolver(URIResolver resolver);
  76. /**
  77. * Returns the callback used to resolve entities referenced by
  78. * <code>xsl:include</code>, <code>xsl:import</code>, or the XPath
  79. * <code>document()</code> function.
  80. */
  81. public abstract URIResolver getURIResolver();
  82. /**
  83. * Sets the output properties for the transformation, overriding any
  84. * properties defined in the stylesheet.
  85. * The format of property keys is as in the
  86. * {@link #setOutputProperty(java.lang.String,java.lang.String)} method.
  87. * @param oformat a set of output properties, or null to reset all the
  88. * properties to their default values
  89. */
  90. public abstract void setOutputProperties(Properties oformat)
  91. throws IllegalArgumentException;
  92. /**
  93. * Returns a copy of the output properties for the transformation.
  94. * Missing properties are defaulted according the
  95. * <a href='http://www.w3.org/TR/xslt#output'>XSLT Recommendation, section
  96. * 16</a>: <code>getProperty(String)</code> returns all properties
  97. * including defaulted ones, and <code>get(Object)</code> returns only the
  98. * properties explicitly set in the stylesheet.
  99. */
  100. public abstract Properties getOutputProperties();
  101. /**
  102. * Sets an output property for the transformation, overriding any property
  103. * of the same name defined in the stylesheet.
  104. * @param name the property name (an XML Name, or a namespace-prefixed
  105. * XML Name of the form <code>{<i>namespaceURI</i>}<i>localName</i></code>
  106. * @param value the string value of the property
  107. * @exception IllegalArgumentException if the property is not supported
  108. */
  109. public abstract void setOutputProperty(String name, String value)
  110. throws IllegalArgumentException;
  111. /**
  112. * Returns the value of an output property for the transformation.
  113. * Only explicit properties set programmatically or defined in the
  114. * stylesheet, not defaulted properties, are returned by this method.
  115. * @param name the property name (an XML Name, or a namespace-prefixed
  116. * XML Name of the form <code>{<i>namespaceURI</i>}<i>localName</i></code>
  117. * @exception IllegalArgumentException if the property is not supported
  118. */
  119. public abstract String getOutputProperty(String name)
  120. throws IllegalArgumentException;
  121. /**
  122. * Sets the callback used to report errors during the transformation.
  123. * @exception IllegalArgumentException if the listener is null
  124. */
  125. public abstract void setErrorListener(ErrorListener listener)
  126. throws IllegalArgumentException;
  127. /**
  128. * Returns the callback used to report errors during the transformation.
  129. */
  130. public abstract ErrorListener getErrorListener();
  131. // -- JAXP 1.3 methods --
  132. /**
  133. * Reset this Transformer to its original configuration.
  134. * @since 1.3
  135. */
  136. public void reset()
  137. {
  138. }
  139. }