001 /* Transformer.java -- 002 Copyright (C) 2004, 2005 Free Software Foundation, Inc. 003 004 This file is part of GNU Classpath. 005 006 GNU Classpath is free software; you can redistribute it and/or modify 007 it under the terms of the GNU General Public License as published by 008 the Free Software Foundation; either version 2, or (at your option) 009 any later version. 010 011 GNU Classpath is distributed in the hope that it will be useful, but 012 WITHOUT ANY WARRANTY; without even the implied warranty of 013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 General Public License for more details. 015 016 You should have received a copy of the GNU General Public License 017 along with GNU Classpath; see the file COPYING. If not, write to the 018 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 019 02110-1301 USA. 020 021 Linking this library statically or dynamically with other modules is 022 making a combined work based on this library. Thus, the terms and 023 conditions of the GNU General Public License cover the whole 024 combination. 025 026 As a special exception, the copyright holders of this library give you 027 permission to link this library with independent modules to produce an 028 executable, regardless of the license terms of these independent 029 modules, and to copy and distribute the resulting executable under 030 terms of your choice, provided that you also meet, for each linked 031 independent module, the terms and conditions of the license of that 032 module. An independent module is a module which is not derived from 033 or based on this library. If you modify this library, you may extend 034 this exception to your version of the library, but you are not 035 obligated to do so. If you do not wish to do so, delete this 036 exception statement from your version. */ 037 038 package javax.xml.transform; 039 040 import java.util.Properties; 041 042 /** 043 * An XSL transformation. 044 * Instances of this class may be reused, but the same instance may not be 045 * used concurrently by different threads. 046 * 047 * @author (a href='mailto:dog@gnu.org'>Chris Burdess</a) 048 */ 049 public abstract class Transformer 050 { 051 052 protected Transformer() 053 { 054 } 055 056 /** 057 * Transforms the source XML to a result tree. 058 * @param xmlSource the XML source 059 * @param outputTarget the result of the transformation 060 */ 061 public abstract void transform(Source xmlSource, Result outputTarget) 062 throws TransformerException; 063 064 /** 065 * Sets a parameter value for the transformation. 066 * Parameters may be referenced in the XSLT stylesheet. 067 * @param name the parameter name (an XML Name, or a namespace-prefixed 068 * XML Name of the form <code>{<i>namespaceURI</i>}<i>localName</i></code> 069 * @param value the value to assign 070 */ 071 public abstract void setParameter(String name, Object value); 072 073 /** 074 * Returns the specified parameter value. 075 * @param name the parameter name (an XML Name, or a namespace-prefixed 076 * XML Name of the form <code>{<i>namespaceURI</i>}<i>localName</i></code> 077 */ 078 public abstract Object getParameter(String name); 079 080 /** 081 * Clears all parameter values. 082 */ 083 public abstract void clearParameters(); 084 085 /** 086 * Sets the callback used to resolve entities referenced by 087 * <code>xsl:include</code>, <code>xsl:import</code>, or the XPath 088 * <code>document()</code> function. 089 */ 090 public abstract void setURIResolver(URIResolver resolver); 091 092 /** 093 * Returns the callback used to resolve entities referenced by 094 * <code>xsl:include</code>, <code>xsl:import</code>, or the XPath 095 * <code>document()</code> function. 096 */ 097 public abstract URIResolver getURIResolver(); 098 099 /** 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 }