net.sourceforge.blogentis.turbine
Class BlogXSLTService

java.lang.Object
  extended byorg.apache.turbine.services.BaseInitable
      extended byorg.apache.turbine.services.BaseService
          extended byorg.apache.turbine.services.TurbineBaseService
              extended bynet.sourceforge.blogentis.turbine.BlogXSLTService
All Implemented Interfaces:
org.apache.turbine.services.Initable, org.apache.turbine.services.Service, org.apache.turbine.services.xslt.XSLTService

public class BlogXSLTService
extends org.apache.turbine.services.TurbineBaseService
implements org.apache.turbine.services.xslt.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.Map 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.
 
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_PATH
 
Constructor Summary
BlogXSLTService()
           
 
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 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.


cache

protected java.util.Map cache
Cache of compiled StyleSheetRoots.

Constructor Detail

BlogXSLTService

public BlogXSLTService()
Method Detail

init

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

Specified by:
init in interface org.apache.turbine.services.Initable
Throws:
org.apache.turbine.services.InitializationException

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.

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 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.

Throws:
java.lang.Exception

transform

protected void transform(java.lang.String xslName,
                         javax.xml.transform.Source xmlin,
                         javax.xml.transform.Result xmlout)
                  throws java.lang.Exception
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 org.apache.turbine.services.xslt.XSLTService
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 org.apache.turbine.services.xslt.XSLTService
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 org.apache.turbine.services.xslt.XSLTService
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 org.apache.turbine.services.xslt.XSLTService
Throws:
java.lang.Exception


Copyright © 2003-2004 SourceForge.net. All Rights Reserved.