# TransformerFactory

public abstract class **TransformerFactory** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  

|---|---|---|
| Known Direct Subclasses [SAXTransformerFactory](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/sax/SAXTransformerFactory.html) |---|---| | [SAXTransformerFactory](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/sax/SAXTransformerFactory.html) | This class extends TransformerFactory to provide SAX-specific factory methods. | |||

<br />

A TransformerFactory instance can be used to create
`https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Transformer.html` and
`https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Templates.html` objects.

The system property that determines which Factory implementation
to create is named `"javax.xml.transform.TransformerFactory"`.
This property names a concrete subclass of the
`TransformerFactory` abstract class. If the property is not
defined, a platform default is be used.

<br />

### Protected Constructor Summary

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

### Public Method Summary

|---|---|
| abstract [Source](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Source.html) | [getAssociatedStylesheet](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerFactory.html#getAssociatedStylesheet(javax.xml.transform.Source,%20java.lang.String,%20java.lang.String,%20java.lang.String))([Source](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Source.html) source, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) media, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) title, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) charset) Get the stylesheet specification(s) associated with the XML `Source` document via the [xml-stylesheet processing instruction](http://www.w3.org/TR/xml-stylesheet/) that match the given criteria. |
| abstract [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [getAttribute](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerFactory.html#getAttribute(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name) Allows the user to retrieve specific attributes on the underlying implementation. |
| 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/TransformerFactory.html#getErrorListener())() Get the error event handler for the TransformerFactory. |
| abstract boolean | [getFeature](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerFactory.html#getFeature(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name) Look up the value of a feature. |
| 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/TransformerFactory.html#getURIResolver())() Get the object that is used by default during the transformation to resolve URIs used in document(), xsl:import, or xsl:include. |
| static [TransformerFactory](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerFactory.html) | [newInstance](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerFactory.html#newInstance(java.lang.String,%20java.lang.ClassLoader))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) factoryClassName, [ClassLoader](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/ClassLoader.html) classLoader) Returns an instance of the named implementation of `TransformerFactory`. |
| static [TransformerFactory](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerFactory.html) | [newInstance](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerFactory.html#newInstance())() Returns Android's implementation of `TransformerFactory`. |
| abstract [Templates](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Templates.html) | [newTemplates](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerFactory.html#newTemplates(javax.xml.transform.Source))([Source](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Source.html) source) Process the Source into a Templates object, which is a a compiled representation of the source. |
| abstract [Transformer](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Transformer.html) | [newTransformer](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerFactory.html#newTransformer(javax.xml.transform.Source))([Source](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Source.html) source) Process the `Source` into a `Transformer` `Object`. |
| abstract [Transformer](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Transformer.html) | [newTransformer](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerFactory.html#newTransformer())() Create a new `Transformer` that performs a copy of the `Source` to the `Result`. |
| abstract void | [setAttribute](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerFactory.html#setAttribute(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) Allows the user to set specific attributes on the underlying implementation. |
| abstract void | [setErrorListener](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerFactory.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 for the TransformerFactory, which is used for the processing of transformation instructions, and not for the transformation itself. |
| abstract void | [setFeature](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerFactory.html#setFeature(java.lang.String,%20boolean))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) name, boolean value) Set a feature for this `TransformerFactory` and `Transformer`s or `Template`s created by this factory. |
| abstract void | [setURIResolver](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerFactory.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 is used by default during the transformation to resolve URIs used in document(), xsl:import, or xsl:include. |

### 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
**TransformerFactory**
()

Default constructor is protected on purpose.

## Public Methods

#### public abstract [Source](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Source.html)
**getAssociatedStylesheet**
([Source](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Source.html) source, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) media, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) title, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) charset)

<br />

Get the stylesheet specification(s) associated with the
XML `Source` document via the
[xml-stylesheet processing instruction](http://www.w3.org/TR/xml-stylesheet/) that match the given criteria.
Note that it is possible to return several stylesheets, in which case
they are applied as if they were a list of imports or cascades in a
single stylesheet.

<br />

##### Parameters

| source | The XML source document. |
| media | The media attribute to be matched. May be null, in which case the preferred templates will be used (i.e. alternate = no). |
| title | The value of the title attribute to match. May be null. |
| charset | The value of the charset attribute to match. May be null. |
|---|---|

##### Returns

- A `Source` `Object` suitable for passing to the `TransformerFactory`.

##### Throws

| [TransformerConfigurationException](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerConfigurationException.html) | An `Exception` is thrown if an error occurs during parsing of the `source`. |
|---|---|

##### See Also

- [Associating Style Sheets with XML documents Version 1.0](http://www.w3.org/TR/xml-stylesheet/)

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

Allows the user to retrieve specific attributes on the underlying
implementation.
An `IllegalArgumentException` is thrown if the underlying
implementation doesn't recognize the attribute.

##### Parameters

| name | The name of the attribute. |
|---|---|

##### Returns

- value The value of the attribute.

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

Get the error event handler for the TransformerFactory.

##### Returns

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

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

Look up the value of a feature.


Feature names are fully qualified `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/URI.html`s.
Implementations may define their own features.
`false` is returned if this `TransformerFactory` or the
`Transformer`s or `Template`s it creates cannot support the feature.
It is possible for an `TransformerFactory` to expose a feature value but be unable to change its state.

<br />

##### Parameters

| name | Feature name. |
|---|---|

##### Returns

- The current state of the feature, `true` or `false`.

##### Throws

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

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

Get the object that is used by default during the transformation
to resolve URIs used in document(), xsl:import, or xsl:include.

##### Returns

- The URIResolver that was set with setURIResolver.

#### public static [TransformerFactory](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerFactory.html)
**newInstance**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) factoryClassName, [ClassLoader](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/ClassLoader.html) classLoader)

Returns an instance of the named implementation of `TransformerFactory`.

##### Parameters

| factoryClassName |   |
| classLoader |   |
|---|---|

##### Throws

| [TransformerFactoryConfigurationError](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerFactoryConfigurationError.html) | if `factoryClassName` is not available or cannot be instantiated. |
|---|---|

#### public static [TransformerFactory](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerFactory.html)
**newInstance**
()

Returns Android's implementation of `TransformerFactory`. Unlike
other Java implementations, this method does not consult system
properties, properties files, or the services API.

##### Throws

| [TransformerFactoryConfigurationError](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerFactoryConfigurationError.html) | never. Included for API compatibility with other Java implementations. |
|---|---|

#### public abstract [Templates](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Templates.html)
**newTemplates**
([Source](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Source.html) source)

Process the Source into a Templates object, which is a
a compiled representation of the source. This Templates object
may then be used concurrently across multiple threads. Creating
a Templates object allows the TransformerFactory to do detailed
performance optimization of transformation instructions, without
penalizing runtime transformation.

##### Parameters

| source | An object that holds a URL, input stream, etc. |
|---|---|

##### Returns

- A Templates object capable of being used for transformation purposes, never null.

##### Throws

| [TransformerConfigurationException](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerConfigurationException.html) | May throw this during the parse when it is constructing the Templates object and fails. |
|---|---|

#### public abstract [Transformer](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Transformer.html)
**newTransformer**
([Source](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/Source.html) source)

<br />

Process the `Source` into a `Transformer`
`Object`. The `Source` is an XSLT document that
conforms to [XSL Transformations (XSLT) Version 1.0](http://www.w3.org/TR/xslt). Care must
be taken not to use this `Transformer` in multiple
`Thread`s running concurrently.
Different `TransformerFactories` can be used concurrently by
different `Thread`s.

<br />

##### Parameters

| source | `Source ` of XSLT document used to create `Transformer`. Examples of XML `Source`s include `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/stream/StreamSource.html`, `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/sax/SAXSource.html` and `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/dom/DOMSource.html`. |
|---|---|

##### Returns

- A `Transformer` object that may be used to perform a transformation in a single `Thread`, never `null`.

##### Throws

| [TransformerConfigurationException](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerConfigurationException.html) | Thrown if there are errors when parsing the `Source` or it is not possible to create a `Transformer` instance. |
|---|---|

##### See Also

- [XSL Transformations (XSLT) Version 1.0](http://www.w3.org/TR/xslt)

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

<br />

Create a new `Transformer` that performs a copy
of the `Source` to the `Result`.
i.e. the "*identity transform*".

<br />

##### Returns

- A Transformer object that may be used to perform a transformation in a single thread, never null.

##### Throws

| [TransformerConfigurationException](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerConfigurationException.html) | Thrown if it is not possible to create a `Transformer` instance. |
|---|---|

#### public abstract void
**setAttribute**
([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)

Allows the user to set specific attributes on the underlying
implementation. An attribute in this context is defined to
be an option that the implementation provides.
An `IllegalArgumentException` is thrown if the underlying
implementation doesn't recognize the attribute.

##### Parameters

| name | The name of the attribute. |
| value | The value of the attribute. |
|---|---|

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

Set the error event listener for the TransformerFactory, which
is used for the processing of transformation instructions,
and not for the transformation itself.
An `IllegalArgumentException` is thrown if the
`ErrorListener` listener is `null`.

##### Parameters

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

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

<br />

Set a feature for this `TransformerFactory` and `Transformer`s
or `Template`s created by this factory.


Feature names are fully qualified `https://developers.google.com/j2objc/javadoc/jre/reference/java/net/URI.html`s.
Implementations may define their own features.
An `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerConfigurationException.html` is thrown if this `TransformerFactory` or the
`Transformer`s or `Template`s it creates cannot support the feature.
It is possible for an `TransformerFactory` to expose a feature value but be unable to change its state.

All implementations are required to support the `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/XMLConstants.html#FEATURE_SECURE_PROCESSING` feature.
When the feature is:

- `true`: the implementation will limit XML processing to conform to implementation limits and behave in a secure fashion as defined by the implementation. Examples include resolving user defined style sheets and functions. If XML processing is limited for security reasons, it will be reported via a call to the registered `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/ErrorListener.html#fatalError(javax.xml.transform.TransformerException)`. See `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerFactory.html#setErrorListener(javax.xml.transform.ErrorListener)`.
- `false`: the implementation will processing XML according to the XML specifications without regard to possible implementation limits.

<br />

##### Parameters

| name | Feature name. |
| value | Is feature state `true` or `false`. |
|---|---|

##### Throws

| [TransformerConfigurationException](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/transform/TransformerConfigurationException.html) | if this `TransformerFactory` or the `Transformer`s or `Template`s it creates cannot support this feature. |
| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | If the `name` parameter 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 is used by default during the transformation
to resolve URIs used in document(), xsl:import, or xsl:include.

##### Parameters

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