org.apache.turbine.services.xslt
Class TurbineXSLTService

java.lang.Object
  extended byorg.apache.turbine.services.BaseInitable
      extended byorg.apache.turbine.services.BaseService
          extended byorg.apache.turbine.services.TurbineBaseService
              extended byorg.apache.turbine.services.xslt.TurbineXSLTService
All Implemented Interfaces:
Initable, Service, XSLTService

public class TurbineXSLTService
extends TurbineBaseService
implements XSLTService

Implementation of the Turbine XSLT Service. It transforms xml with a given xsl file. XSL stylesheets are compiled and cached (if the property in TurbineResources.properties is set) to improve speeds.

Version:
$Id: TurbineXSLTService.java 567398 2007-08-19 13:11:33Z tv $
Author:
Leon Messerschmidt, Sam Ruby, Thomas Vandahl

Field Summary
protected  boolean caching
          Property to control the caching of StyleSheetRoots.
protected  java.lang.String path
          Path to style sheets used for tranforming well-formed XML documents.
 
Fields inherited from class org.apache.turbine.services.BaseService
configuration, name, serviceBroker
 
Fields inherited from class org.apache.turbine.services.BaseInitable
initableBroker, isInitialized
 
Fields inherited from interface org.apache.turbine.services.xslt.XSLTService
SERVICE_NAME, STYLESHEET_CACHING, STYLESHEET_CACHING_DEFAULT, STYLESHEET_PATH, STYLESHEET_PATH_DEFAULT
 
Constructor Summary
TurbineXSLTService()
           
 
Method Summary
protected  javax.xml.transform.Templates compileTemplates(java.net.URL source)
          Compile Templates from an input URL.
protected  javax.xml.transform.Templates getTemplates(java.lang.String xslName)
          Retrieves Templates.
 void init()
          Initialize the TurbineXSLT Service.
 java.lang.String transform(java.lang.String xslName, org.w3c.dom.Node in)
          Execute an xslt
 java.lang.String transform(java.lang.String xslName, org.w3c.dom.Node in, java.util.Map params)
          Execute an xslt
 void transform(java.lang.String xslName, org.w3c.dom.Node in, java.io.Writer out)
          Execute an xslt
 void transform(java.lang.String xslName, org.w3c.dom.Node in, java.io.Writer out, java.util.Map params)
          Execute an xslt
 java.lang.String transform(java.lang.String xslName, java.io.Reader in)
          Execute an xslt
 java.lang.String transform(java.lang.String xslName, java.io.Reader in, java.util.Map params)
          Execute an xslt
 void transform(java.lang.String xslName, java.io.Reader in, java.io.Writer out)
          Execute an xslt
 void transform(java.lang.String xslName, java.io.Reader in, java.io.Writer out, java.util.Map params)
          Execute an xslt
protected  void transform(java.lang.String style, javax.xml.transform.Source in, javax.xml.transform.Result out, java.util.Map params)
          Transform the input source into the output source using the given style
 
Methods inherited from class org.apache.turbine.services.TurbineBaseService
init, init, init, shutdown
 
Methods inherited from class org.apache.turbine.services.BaseService
getConfiguration, getName, getProperties, getServiceBroker, setName, setServiceBroker
 
Methods inherited from class org.apache.turbine.services.BaseInitable
getInit, getInitableBroker, setInit, setInitableBroker
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.turbine.services.Service
getConfiguration, getName, getProperties, setName, setServiceBroker
 
Methods inherited from interface org.apache.turbine.services.Initable
getInit, init, setInitableBroker, shutdown
 

Field Detail

caching

protected boolean caching
Property to control the caching of StyleSheetRoots.


path

protected java.lang.String path
Path to style sheets used for tranforming well-formed XML documents. The path is relative to the webapp context.

Constructor Detail

TurbineXSLTService

public TurbineXSLTService()
Method Detail

init

public void init()
          throws InitializationException
Initialize the TurbineXSLT Service. Load the path to search for xsl files and initiates the cache.

Specified by:
init in interface Initable
Overrides:
init in class TurbineBaseService
Throws:
InitializationException

compileTemplates

protected javax.xml.transform.Templates compileTemplates(java.net.URL source)
                                                  throws java.lang.Exception
Compile Templates from an input URL.

Throws:
java.lang.Exception

getTemplates

protected javax.xml.transform.Templates getTemplates(java.lang.String xslName)
                                              throws java.lang.Exception
Retrieves Templates. If caching is switched on the first attempt is to load the Templates from the cache. If caching is switched off or if the Stylesheet is not found in the cache a new StyleSheetRoot is compiled from an input file.

Throws:
java.lang.Exception

transform

protected void transform(java.lang.String style,
                         javax.xml.transform.Source in,
                         javax.xml.transform.Result out,
                         java.util.Map params)
                  throws javax.xml.transform.TransformerException,
                         java.io.IOException,
                         java.lang.Exception
Transform the input source into the output source using the given style

Parameters:
style - the stylesheet parameter
in - the input source
out - the output source
params - XSLT parameter for the style sheet
Throws:
javax.xml.transform.TransformerException
java.io.IOException
java.lang.Exception

transform

public void transform(java.lang.String xslName,
                      java.io.Reader in,
                      java.io.Writer out)
               throws java.lang.Exception
Execute an xslt

Specified by:
transform in interface XSLTService
Parameters:
xslName - The name of the file that contains the xsl stylesheet.
in - The reader that passes the xml to be transformed
out - The writer for the transformed output
Throws:
java.lang.Exception

transform

public java.lang.String transform(java.lang.String xslName,
                                  java.io.Reader in)
                           throws java.lang.Exception
Execute an xslt

Specified by:
transform in interface XSLTService
Parameters:
xslName - The name of the file that contains the xsl stylesheet.
in - The reader that passes the xml to be transformed
Throws:
java.lang.Exception

transform

public void transform(java.lang.String xslName,
                      org.w3c.dom.Node in,
                      java.io.Writer out)
               throws java.lang.Exception
Execute an xslt

Specified by:
transform in interface XSLTService
Parameters:
xslName - The name of the file that contains the xsl stylesheet.
in - The DOM Node to be transformed
out - The writer for the transformed output
Throws:
java.lang.Exception

transform

public java.lang.String transform(java.lang.String xslName,
                                  org.w3c.dom.Node in)
                           throws java.lang.Exception
Execute an xslt

Specified by:
transform in interface XSLTService
Parameters:
xslName - The name of the file that contains the xsl stylesheet.
Throws:
java.lang.Exception

transform

public void transform(java.lang.String xslName,
                      java.io.Reader in,
                      java.io.Writer out,
                      java.util.Map params)
               throws java.lang.Exception
Execute an xslt

Specified by:
transform in interface XSLTService
Parameters:
xslName - The name of the file that contains the xsl stylesheet.
in - The reader that passes the xml to be transformed
out - The writer for the transformed output
params - A set of parameters that will be forwarded to the XSLT
Throws:
java.lang.Exception

transform

public java.lang.String transform(java.lang.String xslName,
                                  java.io.Reader in,
                                  java.util.Map params)
                           throws java.lang.Exception
Execute an xslt

Specified by:
transform in interface XSLTService
Parameters:
xslName - The name of the file that contains the xsl stylesheet.
in - The reader that passes the xml to be transformed
params - A set of parameters that will be forwarded to the XSLT
Throws:
java.lang.Exception

transform

public void transform(java.lang.String xslName,
                      org.w3c.dom.Node in,
                      java.io.Writer out,
                      java.util.Map params)
               throws java.lang.Exception
Execute an xslt

Specified by:
transform in interface XSLTService
Parameters:
xslName - The name of the file that contains the xsl stylesheet.
in - The DOM Node to be transformed
out - The writer for the transformed output
params - A set of parameters that will be forwarded to the XSLT
Throws:
java.lang.Exception

transform

public java.lang.String transform(java.lang.String xslName,
                                  org.w3c.dom.Node in,
                                  java.util.Map params)
                           throws java.lang.Exception
Execute an xslt

Specified by:
transform in interface XSLTService
Parameters:
xslName - The name of the file that contains the xsl stylesheet.
params - A set of parameters that will be forwarded to the XSLT
Throws:
java.lang.Exception


Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.