Source for javax.xml.transform.Transformer

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