org.ibisph.xslt
Class TransformerFactory

java.lang.Object
  extended by org.ibisph.xslt.TransformerFactory
Direct Known Subclasses:
TemplateCachingTransformerFactory

public class TransformerFactory
extends java.lang.Object

Provides a thread safe way to get a single usage XSLT transformer based on the thread safe template. This class also offers the ability to specify/ override the application's default XSLT transformation engine.

NOTE: XSLTc could be used to improve performance and resource utilization. However, since most users of the IBISPH-IRV system should use the artifact mechanism, implementing XSLTc was not pursued.
This does NOT: "implements java.io.Serializable" because there isn't a reason to persist/distribute across machines.

Author:
Garth Braithwaite, STG

Field Summary
protected static javax.xml.transform.TransformerFactory transformerFactory
           
 
Constructor Summary
TransformerFactory()
          Default factory constructor which uses the JAPX TransformerFactory.
TransformerFactory(java.lang.String transformerFactoryClassName)
          Factory constructor which allows a for a different non default JAXP TransformerFactory to be used.
 
Method Summary
static javax.xml.transform.Transformer newTransformer(javax.xml.transform.Source xsltSource)
          Thread safe, factory method that produces an un-cached/un-managed XSLT transformer.
static javax.xml.transform.Transformer newTransformer(java.lang.String xsltURISystemID)
          Thread safe, factory method that produces an un-cached/un-managed XSLT transformer.
static void setTransformerFactoryClassName(java.lang.String transformerFactoryClassName)
          Sets specified XSLT Transformation Engine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

transformerFactory

protected static javax.xml.transform.TransformerFactory transformerFactory
Constructor Detail

TransformerFactory

public TransformerFactory()
Default factory constructor which uses the JAPX TransformerFactory.


TransformerFactory

public TransformerFactory(java.lang.String transformerFactoryClassName)
Factory constructor which allows a for a different non default JAXP TransformerFactory to be used.

Parameters:
transformerFactoryClassName - Fully qualified class name of the transformation factory to use.
Method Detail

setTransformerFactoryClassName

public static void setTransformerFactoryClassName(java.lang.String transformerFactoryClassName)
Sets specified XSLT Transformation Engine. This allows for Saxon or any other XSLT engine to be used in an environment that already has an endorsed JVM or Application Server XSLT engine (typically Xalan). This can also be accomplished via setting a system property or changing the jars inside the JVM or App Server's endorsed directory. The down side to the System.property approach is that ALL applications within the app server and/or JVM will then be forced to use that XSLT engine.

Parameters:
transformerFactoryClassName - Fully qualified class name of the transformation factory to use.

newTransformer

public static javax.xml.transform.Transformer newTransformer(java.lang.String xsltURISystemID)
                                                      throws javax.xml.transform.TransformerConfigurationException,
                                                             java.io.FileNotFoundException
Thread safe, factory method that produces an un-cached/un-managed XSLT transformer. This factory is simply a helper that creates and returns a new transformer instance based on the supplied XSLT System ID.

Parameters:
xsltURISystemID - XSLT stylesheet file to be parsed and cached.
Returns:
newTransformer parsed, ready to "transform" XSLT transformer based on a thread safe template.
Throws:
javax.xml.transform.TransformerConfigurationException
java.io.FileNotFoundException

newTransformer

public static javax.xml.transform.Transformer newTransformer(javax.xml.transform.Source xsltSource)
                                                      throws javax.xml.transform.TransformerConfigurationException
Thread safe, factory method that produces an un-cached/un-managed XSLT transformer. This factory is simply a helper that creates and returns a new transformer instance based on the supplied XSLT source.

Parameters:
xsltSource - the javax.xml.tarnsform.Source XSLT stylesheet.
Returns:
newTransformer parsed, ready to "transform" XSLT transformer based on a thread safe template.
Throws:
javax.xml.transform.TransformerConfigurationException