org.apache.xalan.xsltc.trax

## Class TransformerImpl

- java.lang.Object
- - javax.xml.transform.Transformer
  - - org.apache.xalan.xsltc.trax.TransformerImpl

All Implemented Interfaces:
  ErrorListener, DOMCache

    public final class TransformerImpl
    extends Transformer
    implements DOMCache, ErrorListener

Author:
  Morten Jorgensen, G. Todd Miller, Santiago Pericas-Geertsen

### Method Summary

Methods
`void` `clearParameters()` Implements JAXP's Transformer.clearParameters() Clear all parameters set with setParameter.
`void` `error(TransformerException e)` Receive notification of a recoverable error.
`void` `fatalError(TransformerException e)` Receive notification of a non-recoverable error.
`ErrorListener` `getErrorListener()` Implements JAXP's Transformer.getErrorListener() Get the error event handler in effect for the transformation.
`SerializationHandler` `getOutputHandler(Result result)` Create an output handler for the transformation output based on the type and contents of the TrAX Result object passed to the transform() method.
`java.util.Properties` `getOutputProperties()` Implements JAXP's Transformer.getOutputProperties().
`java.lang.String` `getOutputProperty(java.lang.String name)` Implements JAXP's Transformer.getOutputProperty().
`java.lang.Object` `getParameter(java.lang.String name)` Implements JAXP's Transformer.getParameter() Returns the value of a given parameter.
`URIResolver` `getURIResolver()` Implements JAXP's Transformer.getURIResolver() Set the object currently used to resolve URIs used in document().
`boolean` `isIdentity()`
`boolean` `isSecureProcessing()` Return the state of the secure processing feature.
`void` `reset()` This method resets the Transformer to its original configuration Transformer code is reset to the same state it was when it was created
`DOM` `retrieveDocument(java.lang.String baseURI, java.lang.String href, Translet translet)` This class should only be used as a DOMCache for the translet if the URIResolver has been set.
`void` `setErrorListener(ErrorListener listener)` Implements JAXP's Transformer.setErrorListener() Set the error event listener in effect for the transformation.
`void` `setOutputProperties(java.util.Properties properties)` Implements JAXP's Transformer.setOutputProperties().
`void` `setOutputProperty(java.lang.String name, java.lang.String value)` Implements JAXP's Transformer.setOutputProperty().
`void` `setParameter(java.lang.String name, java.lang.Object value)` Implements JAXP's Transformer.setParameter() Add a parameter for the transformation.
`void` `setSecureProcessing(boolean flag)` Set the state of the secure processing feature.
`void` `setURIResolver(URIResolver resolver)` Implements JAXP's Transformer.setURIResolver() Set an object that will be used to resolve URIs used in document().
`void` `transferOutputProperties(SerializationHandler handler)` This method is used to pass any properties to the output handler when running the identity transform.
`void` `transform(Source source, Result result)` Implements JAXP's Transformer.transform()
`void` `warning(TransformerException e)` Receive notification of a warning.

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### isSecureProcessing

    public boolean isSecureProcessing()

Return the state of the secure processing feature.

#### setSecureProcessing

    public void setSecureProcessing(boolean flag)

Set the state of the secure processing feature.

#### isIdentity

    public boolean isIdentity()

#### transform

    public void transform(Source source,
                 Result result)
                   throws TransformerException

Implements JAXP's Transformer.transform()

Specified by:
  `transform` in class `Transformer`
Parameters:
  `source` - Contains the input XML document
  `result` - Will contain the output from the transformation
Throws:
  `TransformerException`

#### getOutputHandler

    public SerializationHandler getOutputHandler(Result result)
                                          throws TransformerException

Create an output handler for the transformation output based on the type and contents of the TrAX Result object passed to the transform() method.

Throws:
  `TransformerException`

#### getErrorListener

    public ErrorListener getErrorListener()

Implements JAXP's Transformer.getErrorListener() Get the error event handler in effect for the transformation.

Specified by:
  `getErrorListener` in class `Transformer`
Returns:
  The error event handler currently in effect

#### setErrorListener

    public void setErrorListener(ErrorListener listener)
                          throws java.lang.IllegalArgumentException

Implements JAXP's Transformer.setErrorListener() Set the error event listener in effect for the transformation. Register a message handler in the translet in order to forward xsl:messages to error listener.

Specified by:
  `setErrorListener` in class `Transformer`
Parameters:
  `listener` - The error event listener to use
Throws:
  `java.lang.IllegalArgumentException`

#### getOutputProperties

    public java.util.Properties getOutputProperties()

Implements JAXP's Transformer.getOutputProperties(). Returns a copy of the output properties for the transformation. This is a set of layered properties. The first layer contains properties set by calls to setOutputProperty() and setOutputProperties() on this class, and the output settings defined in the stylesheet's element makes up the second level, while the default XSLT output settings are returned on the third level.

Specified by:
  `getOutputProperties` in class `Transformer`
Returns:
  Properties in effect for this Transformer
See Also:
  `OutputKeys`, `Properties`, XSL Transformations (XSLT) Version 1.0

#### getOutputProperty

    public java.lang.String getOutputProperty(java.lang.String name)
                                       throws java.lang.IllegalArgumentException

Implements JAXP's Transformer.getOutputProperty(). Get an output property that is in effect for the transformation. The property specified may be a property that was set with setOutputProperty, or it may be a property specified in the stylesheet.

Specified by:
  `getOutputProperty` in class `Transformer`
Parameters:
  `name` - A non-null string that contains the name of the property
Returns:
  The string value of the output property, or null if no property was found.
Throws:
  `java.lang.IllegalArgumentException` - if the property name is not known
See Also:
  `OutputKeys`

#### setOutputProperties

    public void setOutputProperties(java.util.Properties properties)
                             throws java.lang.IllegalArgumentException

Implements JAXP's Transformer.setOutputProperties(). Set the output properties for the transformation. These properties will override properties set in the Templates with xsl:output. Unrecognised properties will be quitely ignored.

Specified by:
  `setOutputProperties` in class `Transformer`
Parameters:
  `properties` - The properties to use for the Transformer
Throws:
  `java.lang.IllegalArgumentException` - Never, errors are ignored
See Also:
  `OutputKeys`, `Properties`

#### setOutputProperty

    public void setOutputProperty(java.lang.String name,
                         java.lang.String value)
                           throws java.lang.IllegalArgumentException

Implements JAXP's Transformer.setOutputProperty(). Get an output property that is in effect for the transformation. The property specified may be a property that was set with setOutputProperty(), or it may be a property specified in the stylesheet.

Specified by:
  `setOutputProperty` in class `Transformer`
Parameters:
  `name` - The name of the property to set
  `value` - The value to assign to the property
Throws:
  `java.lang.IllegalArgumentException` - Never, errors are ignored
See Also:
  `OutputKeys`

#### transferOutputProperties

    public void transferOutputProperties(SerializationHandler handler)

This method is used to pass any properties to the output handler when running the identity transform.

#### setParameter

    public void setParameter(java.lang.String name,
                    java.lang.Object value)

Implements JAXP's Transformer.setParameter() Add a parameter for the transformation. The parameter is simply passed on to the translet - no validation is performed - so any unused parameters are quitely ignored by the translet.

Specified by:
  `setParameter` in class `Transformer`
Parameters:
  `name` - The name of the parameter
  `value` - The value to assign to the parameter

#### clearParameters

    public void clearParameters()

Implements JAXP's Transformer.clearParameters() Clear all parameters set with setParameter. Clears the translet's parameter stack.

Specified by:
  `clearParameters` in class `Transformer`

#### getParameter

    public final java.lang.Object getParameter(java.lang.String name)

Implements JAXP's Transformer.getParameter() Returns the value of a given parameter. Note that the translet will not keep values for parameters that were not defined in the stylesheet.

Specified by:
  `getParameter` in class `Transformer`
Parameters:
  `name` - The name of the parameter
Returns:
  An object that contains the value assigned to the parameter

#### getURIResolver

    public URIResolver getURIResolver()

Implements JAXP's Transformer.getURIResolver() Set the object currently used to resolve URIs used in document().

Specified by:
  `getURIResolver` in class `Transformer`
Returns:
  The URLResolver object currently in use

#### setURIResolver

    public void setURIResolver(URIResolver resolver)

Implements JAXP's Transformer.setURIResolver() Set an object that will be used to resolve URIs used in document().

Specified by:
  `setURIResolver` in class `Transformer`
Parameters:
  `resolver` - The URIResolver to use in document()

#### retrieveDocument

    public DOM retrieveDocument(java.lang.String baseURI,
                       java.lang.String href,
                       Translet translet)

This class should only be used as a DOMCache for the translet if the URIResolver has been set. The method implements XSLTC's DOMCache interface, which is used to plug in an external document loader into a translet. This method acts as an adapter between TrAX's URIResolver interface and XSLTC's DOMCache interface. This approach is simple, but removes the possibility of using external document caches with XSLTC.

Specified by:
  `retrieveDocument` in interface `DOMCache`
Parameters:
  `baseURI` - The base URI used by the document call.
  `href` - The href argument passed to the document function.
  `translet` - A reference to the translet requesting the document

#### error

    public void error(TransformerException e)
               throws TransformerException

Receive notification of a recoverable error. The transformer must continue to provide normal parsing events after invoking this method. It should still be possible for the application to process the document through to the end.

Specified by:
  `error` in interface `ErrorListener`
Parameters:
  `e` - The warning information encapsulated in a transformer exception.
Throws:
  `TransformerException` - if the application chooses to discontinue the transformation (always does in our case).
See Also:
  `TransformerException`

#### fatalError

    public void fatalError(TransformerException e)
                    throws TransformerException

Receive notification of a non-recoverable error. The application must assume that the transformation cannot continue after the Transformer has invoked this method, and should continue (if at all) only to collect addition error messages. In fact, Transformers are free to stop reporting events once this method has been invoked.

Specified by:
  `fatalError` in interface `ErrorListener`
Parameters:
  `e` - The warning information encapsulated in a transformer exception.
Throws:
  `TransformerException` - if the application chooses to discontinue the transformation (always does in our case).
See Also:
  `TransformerException`

#### warning

    public void warning(TransformerException e)
                 throws TransformerException

Receive notification of a warning. Transformers can use this method to report conditions that are not errors or fatal errors. The default behaviour is to take no action. After invoking this method, the Transformer must continue with the transformation. It should still be possible for the application to process the document through to the end.

Specified by:
  `warning` in interface `ErrorListener`
Parameters:
  `e` - The warning information encapsulated in a transformer exception.
Throws:
  `TransformerException` - if the application chooses to discontinue the transformation (never does in our case).
See Also:
  `TransformerException`

#### reset

    public void reset()

This method resets the Transformer to its original configuration Transformer code is reset to the same state it was when it was created

Overrides:
  `reset` in class `Transformer`
Since:
  1.5