org.apache.turbine.services.xslt
Class TurbineXSLTService
java.lang.Object
|
+--org.apache.turbine.services.BaseInitable
|
+--org.apache.turbine.services.BaseService
|
+--org.apache.turbine.services.TurbineBaseService
|
+--org.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.
- Author:
- Leon Messerschmidt, Sam Ruby
Field Summary |
protected java.util.Hashtable |
cache
Cache of compiled StyleSheetRoots. |
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. |
private static javax.xml.transform.TransformerFactory |
tfactory
Factory for producing templates and null transformers |
Method Summary |
protected javax.xml.transform.Templates |
compileTemplates(java.lang.String source)
Compile Templates from an input file. |
protected java.lang.String |
getFileName(java.lang.String templateName)
Get a valid and existing filename from a template name. |
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 |
void |
transform(java.lang.String xslName,
org.w3c.dom.Node in,
java.io.Writer out)
Execute an xslt |
java.lang.String |
transform(java.lang.String xslName,
java.io.Reader in)
Execute an xslt |
void |
transform(java.lang.String xslName,
java.io.Reader in,
java.io.Writer out)
Execute an xslt |
protected void |
transform(java.lang.String xslName,
javax.xml.transform.Source xmlin,
javax.xml.transform.Result xmlout)
|
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
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.
cache
protected java.util.Hashtable cache
- Cache of compiled StyleSheetRoots.
tfactory
private static javax.xml.transform.TransformerFactory tfactory
- Factory for producing templates and null transformers
TurbineXSLTService
public TurbineXSLTService()
init
public void init()
- 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
- Following copied from interface:
org.apache.turbine.services.Initable
- Throws:
InitializationException,
- if initialization of this
class was not successful.
getFileName
protected java.lang.String getFileName(java.lang.String templateName)
- Get a valid and existing filename from a template name.
The extension is removed and replaced with .xsl. If this
file does not exist the method attempts to find default.xsl.
If it fails to find default.xsl it returns null.
compileTemplates
protected javax.xml.transform.Templates compileTemplates(java.lang.String source)
throws java.lang.Exception
- Compile Templates from an input file.
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 of or if the Stylesheet is not found
in the cache a new StyleSheetRoot is compiled from an input
file.
This method is synchronized on the xsl cache so that a thread
does not attempt to load a StyleSheetRoot from the cache while
it is still being compiled.
transform
protected void transform(java.lang.String xslName,
javax.xml.transform.Source xmlin,
javax.xml.transform.Result xmlout)
throws 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
- Following copied from interface:
org.apache.turbine.services.xslt.XSLTService
- Parameters:
xslName
- The name of the file that contains the xsl stylesheet.in
- The reader that passes the xml to be transformedout
- The writer for the transformed output
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
- Following copied from interface:
org.apache.turbine.services.xslt.XSLTService
- Parameters:
xslName
- The name of the file that contains the xsl stylesheet.in
- The reader that passes the xml to be transformed
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
- Following copied from interface:
org.apache.turbine.services.xslt.XSLTService
- Parameters:
xslName
- The name of the file that contains the xsl stylesheet.in
- The DOM Node to be transformedout
- The writer for the transformed output
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
- Following copied from interface:
org.apache.turbine.services.xslt.XSLTService
- Parameters:
xslName
- The name of the file that contains the xsl stylesheet.out
- The writer for the transformed output
Copyright © 2000-2002 Apache Software Foundation. All Rights Reserved.