org.crosswire.common.xml

## Class TransformingSAXEventProvider

- java.lang.Object
- - javax.xml.transform.Transformer
  - - org.crosswire.common.xml.TransformingSAXEventProvider

- All Implemented Interfaces:
    SAXEventProvider

      public class TransformingSAXEventProvider
      extends Transformer
      implements SAXEventProvider

  A SAXEventProvider that gets its output data from an XSL stylesheet and another SAXEventProvider (supplying input XML).
  Author:
    Joe Walker
  See Also:
    `The GNU Lesser General Public License for details.`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `private static class` | `TransformingSAXEventProvider.TemplateInfo` A simple class to link modification times to Templates objects

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private static boolean` | `developmentMode` In development mode the style sheet is checked for modifications before use and if so, it is recompiled.
    `private ErrorListener` | `errors` The remembered ErrorListener because the transformer has not been created
    `private static org.slf4j.Logger` | `log` The log stream
    `private Properties` | `outputs` The remembered OutputProperties because the transformer has not been created
    `private Map<String,Object>` | `params` The remembered Parameters because the transformer has not been created
    `private URIResolver` | `resolver` The remembered URIResolver because the transformer has not been created
    `private TransformerFactory` | `transfact` How we get the transformer objects
    `private static Map<URI,TransformingSAXEventProvider.TemplateInfo>` | `txers` A cache of transformers
    `private SAXEventProvider` | `xmlsep` The XML input source
    `private URI` | `xsluri` The XSL stylesheet

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TransformingSAXEventProvider(URI xsluri, SAXEventProvider xmlsep)` Simple ctor

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clearParameters()`
    `ErrorListener` | `getErrorListener()`
    `Properties` | `getOutputProperties()`
    `String` | `getOutputProperty(String name)`
    `Object` | `getParameter(String name)`
    `private TransformingSAXEventProvider.TemplateInfo` | `getTemplateInfo()` Compile the XSL or retrieve it from the cache
    `URIResolver` | `getURIResolver()`
    `static boolean` | `isDevelopmentMode()` In development mode the style sheet is checked for modifications before use and if so, it is recompiled.
    `void` | `provideSAXEvents(ContentHandler handler)` When SAX events are required the user of this interface can call this method.
    `static void` | `setDevelopmentMode(boolean developmentMode)` In development mode the style sheet is checked for modifications before use and if so, it is recompiled.
    `void` | `setErrorListener(ErrorListener errors)`
    `void` | `setOutputProperties(Properties outputs)`
    `void` | `setOutputProperty(String name, String value)`
    `void` | `setParameter(String name, Object value)`
    `void` | `setURIResolver(URIResolver resolver)`
    `void` | `transform(Source xmlSource, Result outputTarget)`

    - ### Methods inherited from class javax.xml.transform.Transformer

      `reset`

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

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

- - ### Field Detail

    - #### developmentMode

          private static boolean developmentMode

      In development mode the style sheet is checked for modifications before use and if so, it is recompiled.

    - #### errors

          private ErrorListener errors

      The remembered ErrorListener because the transformer has not been created

    - #### resolver

          private URIResolver resolver

      The remembered URIResolver because the transformer has not been created

    - #### outputs

          private Properties outputs

      The remembered OutputProperties because the transformer has not been created

    - #### params

          private Map<String,Object> params

      The remembered Parameters because the transformer has not been created

    - #### xsluri

          private URI xsluri

      The XSL stylesheet

    - #### xmlsep

          private SAXEventProvider xmlsep

      The XML input source

    - #### transfact

          private TransformerFactory transfact

      How we get the transformer objects

    - #### txers

          private static Map<URI,TransformingSAXEventProvider.TemplateInfo> txers

      A cache of transformers

    - #### log

          private static final org.slf4j.Logger log

      The log stream

  - ### Constructor Detail

    - #### TransformingSAXEventProvider

          public TransformingSAXEventProvider(URI xsluri,
                                      SAXEventProvider xmlsep)

      Simple ctor
      Parameters:
        `xsluri` - the URI of XSL
        `xmlsep` - a SAX Event Provider for an XML document

  - ### Method Detail

    - #### getTemplateInfo

          private TransformingSAXEventProvider.TemplateInfo getTemplateInfo()
                                                                     throws TransformerConfigurationException,
                                                                            IOException

      Compile the XSL or retrieve it from the cache
      Returns:
        the template information
      Throws:
        `TransformerConfigurationException` - when there is a problem with configuring the transformer
        `IOException` - when there is an I/O error

    - #### transform

          public void transform(Source xmlSource,
                       Result outputTarget)
                         throws TransformerException

      Specified by:
        `transform` in class `Transformer`
      Throws:
        `TransformerException`

    - #### provideSAXEvents

          public void provideSAXEvents(ContentHandler handler)
                                throws SAXException

      Description copied from interface: `SAXEventProvider`
      When SAX events are required the user of this interface can call this method.
      Specified by:
        `provideSAXEvents` in interface `SAXEventProvider`
      Parameters:
        `handler` - The place to send SAX events.
      Throws:
        `SAXException` - when a SAX encounters a problem

    - #### getErrorListener

          public ErrorListener getErrorListener()

      Specified by:
        `getErrorListener` in class `Transformer`

    - #### setErrorListener

          public void setErrorListener(ErrorListener errors)
                                throws IllegalArgumentException

      Specified by:
        `setErrorListener` in class `Transformer`
      Throws:
        `IllegalArgumentException`

    - #### getURIResolver

          public URIResolver getURIResolver()

      Specified by:
        `getURIResolver` in class `Transformer`

    - #### setURIResolver

          public void setURIResolver(URIResolver resolver)

      Specified by:
        `setURIResolver` in class `Transformer`

    - #### getOutputProperties

          public Properties getOutputProperties()

      Specified by:
        `getOutputProperties` in class `Transformer`

    - #### setOutputProperties

          public void setOutputProperties(Properties outputs)
                                   throws IllegalArgumentException

      Specified by:
        `setOutputProperties` in class `Transformer`
      Throws:
        `IllegalArgumentException`

    - #### getOutputProperty

          public String getOutputProperty(String name)
                                   throws IllegalArgumentException

      Specified by:
        `getOutputProperty` in class `Transformer`
      Throws:
        `IllegalArgumentException`

    - #### setOutputProperty

          public void setOutputProperty(String name,
                               String value)
                                 throws IllegalArgumentException

      Specified by:
        `setOutputProperty` in class `Transformer`
      Throws:
        `IllegalArgumentException`

    - #### clearParameters

          public void clearParameters()

      Specified by:
        `clearParameters` in class `Transformer`

    - #### getParameter

          public Object getParameter(String name)

      Specified by:
        `getParameter` in class `Transformer`

    - #### setParameter

          public void setParameter(String name,
                          Object value)

      Specified by:
        `setParameter` in class `Transformer`

    - #### setDevelopmentMode

          public static void setDevelopmentMode(boolean developmentMode)

      In development mode the style sheet is checked for modifications before use and if so, it is recompiled.
      Parameters:
        `developmentMode` - the developmentMode to set

    - #### isDevelopmentMode

          public static boolean isDevelopmentMode()

      In development mode the style sheet is checked for modifications before use and if so, it is recompiled.
      Returns:
        the developmentMode