Objects of
this type are used to transform a Source document
into a Result document. Obtain a
transformer object from a
TRansformerFactory object, from a
Templates object created by a
transformerFactory, or from a
transformerHandler object created by a
SAXTransformerFactory (these last two types are
from the javax.xml.transform.sax package).
Once you have a transformer object, you may need
to configure it before using it to transform documents.
setErrorListener(
)
and setURIResolver(
) allow you to specify ErrorListener and
URLResolver object that the
transformer can use. setOutputProperty(
) and setOutputProperties(
) allow you to specify name/value pairs that affect the
text formatting of the Result document (if that
document is written out in text format).
OutputKeys defines constants that represent the
set of standard output property names. The output properties you
specify with these methods override any output properties specified
(with an
<xsl:output> tag) in the Templates
object. Use setParameter(
)
to supply values for any top-level
parameters defined (with <xsl:param> tags)
in the stylesheet. Note that if the name of any such parameter is a
qualified name, then it appears in the stylesheet with a namespace
prefix. You can't use the prefix with the
setParameter( ) method, however, and you must
instead specify the parameter name using the URI of the namespace
within curly braces followed by the local name. If no namespace is
involved, then you can just use the simple name of the parameter with
no curly braces or URIs.
Once you have created and configured a TRansformer
object, use the TRansform(
)
method to perform a document transformation. This method transforms
the specified Source document and creates the
transformed document specified by the Result
object. In Java 5.0, you can reset(
) a
transformer to restore it to its original state
and prepare it for reuse.
transformer implementations are not typically
threadsafe. You can reuse a transformer object and
call transform( ) any number of times (just not
concurrently). The output properties and parameters you specify are
not changed by calling the transform( ) method,
and can be reused.
public abstract class
Transformer {
// Protected Constructors
protected
Transformer ( );
// Public Instance Methods
public abstract void
clearParameters ( );
public abstract ErrorListener
getErrorListener ( );
public abstract java.util.Properties
getOutputProperties ( );
public abstract String
getOutputProperty (String
name )
throws IllegalArgumentException;
public abstract Object
getParameter (String
name );
public abstract URIResolver
getURIResolver ( );
5.0 public void
reset ( );
public abstract void
setErrorListener (ErrorListener
listener )
throws IllegalArgumentException;
public abstract void
setOutputProperties (java.util.Properties
oformat );
public abstract void
setOutputProperty (String
name , String
value )
throws IllegalArgumentException;
public abstract void
setParameter (String
name , Object
value );
public abstract void
setURIResolver (URIResolver
resolver );
public abstract void
transform (Source
xmlSource , Result
outputTarget )
throws TransformerException;
}
Templates.newTransformer( ),
TRansformerFactory.newTransformer( ),
javax.xml.transform.sax.TransformerHandler.getTransformer(
)