# Transformer

public abstract class **Transformer** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  
An instance of this abstract class can transform a
source tree into a result tree.

An instance of this class can be obtained with the
`https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerFactory.html#newTransformer()`
method. This instance may then be used to process XML from a
variety of sources and write the transformation output to a
variety of sinks.

An object of this class may not be used in multiple threads
running concurrently. Different Transformers may be used
concurrently by different threads.

A `Transformer` may be used multiple times. Parameters and
output properties are preserved across transformations.

<br />

### Protected Constructor Summary

|---|---|
|   | [Transformer](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Transformer.html#Transformer())() Default constructor is protected on purpose. |

### Public Method Summary

|---|---|
| abstract void | [clearParameters](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Transformer.html#clearParameters())() Clear all parameters set with setParameter. |
| abstract [ErrorListener](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/ErrorListener.html) | [getErrorListener](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Transformer.html#getErrorListener())() Get the error event handler in effect for the transformation. |
| abstract [Properties](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Properties.html) | [getOutputProperties](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Transformer.html#getOutputProperties())() Get a copy of the output properties for the transformation. |
| abstract [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [getOutputProperty](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Transformer.html#getOutputProperty(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name) Get an output property that is in effect for the transformer. |
| abstract [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [getParameter](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Transformer.html#getParameter(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name) Get a parameter that was explicitly set with setParameter. |
| abstract [URIResolver](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/URIResolver.html) | [getURIResolver](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Transformer.html#getURIResolver())() Get an object that will be used to resolve URIs used in document(). |
| void | [reset](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Transformer.html#reset())() Reset this `Transformer` to its original configuration. |
| abstract void | [setErrorListener](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Transformer.html#setErrorListener(javax.xml.transform.ErrorListener))([ErrorListener](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/ErrorListener.html) listener) Set the error event listener in effect for the transformation. |
| abstract void | [setOutputProperties](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Transformer.html#setOutputProperties(java.util.Properties))([Properties](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Properties.html) oformat) Set the output properties for the transformation. |
| abstract void | [setOutputProperty](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Transformer.html#setOutputProperty(java.lang.String,%20java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) value) Set an output property that will be in effect for the transformation. |
| abstract void | [setParameter](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Transformer.html#setParameter(java.lang.String,%20java.lang.Object))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name, [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) value) Add a parameter for the transformation. |
| abstract void | [setURIResolver](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Transformer.html#setURIResolver(javax.xml.transform.URIResolver))([URIResolver](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/URIResolver.html) resolver) Set an object that will be used to resolve URIs used in document(). |
| abstract void | [transform](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Transformer.html#transform(javax.xml.transform.Source,%20javax.xml.transform.Result))([Source](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Source.html) xmlSource, [Result](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Result.html) outputTarget) Transform the XML `Source` to a `Result`. |

### Inherited Method Summary

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

## Protected Constructors

#### protected
**Transformer**
()

Default constructor is protected on purpose.

## Public Methods

#### public abstract void
**clearParameters**
()

Clear all parameters set with setParameter.

#### public abstract [ErrorListener](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/ErrorListener.html)
**getErrorListener**
()

Get the error event handler in effect for the transformation.
Implementations must provide a default error listener.

##### Returns

- The current error handler, which should never be null.

#### public abstract [Properties](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Properties.html)
**getOutputProperties**
()

<br />

Get a copy of the output properties for the transformation.

The properties returned should contain properties set by the user,
and properties set by the stylesheet, and these properties
are "defaulted" by default properties specified by
[section 16 of the
XSL Transformations (XSLT) W3C Recommendation](http://www.w3.org/TR/xslt#output). The properties that
were specifically set by the user or the stylesheet should be in the base
Properties list, while the XSLT default properties that were not
specifically set should be the default Properties list. Thus,
getOutputProperties().getProperty(String key) will obtain any
property in that was set by `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Transformer.html#setOutputProperty(java.lang.String,%20java.lang.String)`,
`https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Transformer.html#setOutputProperties(java.util.Properties)`, in the stylesheet, *or* the default
properties, while
getOutputProperties().get(String key) will only retrieve properties
that were explicitly set by `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Transformer.html#setOutputProperty(java.lang.String,%20java.lang.String)`,
`https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Transformer.html#setOutputProperties(java.util.Properties)`, or in the stylesheet.

Note that mutation of the Properties object returned will not
effect the properties that the transformer contains.

If any of the argument keys are not recognized and are not
namespace qualified, the property will be ignored and not returned.
In other words the behavior is not orthogonal with
`https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Transformer.html#setOutputProperties(java.util.Properties)`.

<br />

##### Returns

- A copy of the set of output properties in effect for the next transformation.

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/OutputKeys.html`
- `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Properties.html`
- [XSL Transformations (XSLT) Version 1.0](http://www.w3.org/TR/xslt#output)

#### public abstract [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**getOutputProperty**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name)

Get an output property that is in effect for the
transformer. The property specified may be a property
that was set with setOutputProperty, or it may be a
property specified in the stylesheet.

##### Parameters

| name | A non-null String that specifies an output property name, which may be namespace qualified. |
|---|---|

##### Returns

- The string value of the output property, or null if no property was found.

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | If the property is not supported. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/OutputKeys.html`

#### public abstract [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)
**getParameter**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name)

Get a parameter that was explicitly set with setParameter.

This method does not return a default parameter value, which
cannot be determined until the node context is evaluated during
the transformation process.

##### Parameters

| name | of `Object` to get |
|---|---|

##### Returns

- A parameter that has been set with setParameter.

#### public abstract [URIResolver](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/URIResolver.html)
**getURIResolver**
()

Get an object that will be used to resolve URIs used in
document().

##### Returns

- An object that implements the URIResolver interface, or null.

#### public void
**reset**
()

<br />

Reset this `Transformer` to its original configuration.

`Transformer` is reset to the same state as when it was created with
`https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerFactory.html#newTransformer()`,
`https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerFactory.html#newTransformer(javax.xml.transform.Source)` or
`https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Templates.html#newTransformer()`.
`reset()` is designed to allow the reuse of existing `Transformer`s
thus saving resources associated with the creation of new `Transformer`s.

The reset `Transformer` is not guaranteed to have the same `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/URIResolver.html`
or `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/ErrorListener.html` `Object`s, e.g. `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object)`.
It is guaranteed to have a functionally equal `URIResolver`
and `ErrorListener`.

<br />

#### public abstract void
**setErrorListener**
([ErrorListener](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/ErrorListener.html) listener)

Set the error event listener in effect for the transformation.

##### Parameters

| listener | The new error listener. |
|---|---|

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if listener is null. |
|---|---|

#### public abstract void
**setOutputProperties**
([Properties](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Properties.html) oformat)

Set the output properties for the transformation. These
properties will override properties set in the Templates
with xsl:output.

If argument to this function is null, any properties
previously set are removed, and the value will revert to the value
defined in the templates object.

Pass a qualified property key name as a two-part string, the namespace
URI enclosed in curly braces ({}), followed by the local name. If the
name has a null URL, the String only contain the local name. An
application can safely check for a non-null URI by testing to see if the
first character of the name is a '{' character.

For example, if a URI and local name were obtained from an element
defined with \<xyz:foo
xmlns:xyz="http://xyz.foo.com/yada/baz.html"/\>,
then the qualified name would be "{http://xyz.foo.com/yada/baz.html}foo".
Note that no prefix is used.
An `IllegalArgumentException` is thrown if any of the argument keys are not recognized and are not namespace qualified.

<br />

##### Parameters

| oformat | A set of output properties that will be used to override any of the same properties in affect for the transformation. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/OutputKeys.html`
- `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Properties.html`

#### public abstract void
**setOutputProperty**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) value)

Set an output property that will be in effect for the
transformation.

Pass a qualified property name as a two-part string, the namespace URI
enclosed in curly braces ({}), followed by the local name. If the
name has a null URL, the String only contain the local name. An
application can safely check for a non-null URI by testing to see if the
first character of the name is a '{' character.

For example, if a URI and local name were obtained from an element
defined with \<xyz:foo
xmlns:xyz="http://xyz.foo.com/yada/baz.html"/\>,
then the qualified name would be "{http://xyz.foo.com/yada/baz.html}foo".
Note that no prefix is used.

The Properties object that was passed to `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Transformer.html#setOutputProperties(java.util.Properties)`
won't be effected by calling this method.

<br />

##### Parameters

| name | A non-null String that specifies an output property name, which may be namespace qualified. |
| value | The non-null string value of the output property. |
|---|---|

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | If the property is not supported, and is not qualified with a namespace. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/OutputKeys.html`

#### public abstract void
**setParameter**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name, [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) value)

Add a parameter for the transformation.

Pass a qualified name as a two-part string, the namespace URI
enclosed in curly braces ({}), followed by the local name. If the
name has a null URL, the String only contain the local name. An
application can safely check for a non-null URI by testing to see if the
first character of the name is a '{' character.

For example, if a URI and local name were obtained from an element
defined with \<xyz:foo
xmlns:xyz="http://xyz.foo.com/yada/baz.html"/\>,
then the qualified name would be "{http://xyz.foo.com/yada/baz.html}foo".
Note that no prefix is used.

<br />

##### Parameters

| name | The name of the parameter, which may begin with a namespace URI in curly braces ({}). |
| value | The value object. This can be any valid Java object. It is up to the processor to provide the proper object coercion or to simply pass the object on for use in an extension. |
|---|---|

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | If value is null. |
|---|---|

#### public abstract void
**setURIResolver**
([URIResolver](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/URIResolver.html) resolver)

Set an object that will be used to resolve URIs used in
document().

If the resolver argument is null, the URIResolver value will
be cleared and the transformer will no longer have a resolver.

<br />

##### Parameters

| resolver | An object that implements the URIResolver interface, or null. |
|---|---|

#### public abstract void
**transform**
([Source](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Source.html) xmlSource, [Result](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Result.html) outputTarget)

<br />

Transform the XML `Source` to a `Result`.
Specific transformation behavior is determined by the settings of the
`TransformerFactory` in effect when the
`Transformer` was instantiated and any modifications made to
the `Transformer` instance.

An empty `Source` is represented as an empty document
as constructed by `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/parsers/DocumentBuilder.html#newDocument()`.
The result of transforming an empty `Source` depends on
the transformation behavior; it is not always an empty
`Result`.

<br />

##### Parameters

| xmlSource | The XML input to transform. |
| outputTarget | The `Result` of transforming the `xmlSource`. |
|---|---|

##### Throws

| [TransformerException](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerException.html) | If an unrecoverable error occurs during the course of the transformation. |
|---|---|