org.apache.cocoon.transformation
Class XSLTTransformer

java.lang.Object
  extended byorg.apache.cocoon.util.AbstractLogEnabled
      extended byorg.apache.cocoon.xml.AbstractXMLProducer
          extended byorg.apache.cocoon.xml.AbstractXMLPipe
              extended byorg.apache.cocoon.transformation.AbstractTransformer
                  extended byorg.apache.cocoon.transformation.XSLTTransformer
All Implemented Interfaces:
org.apache.cocoon.caching.CacheableProcessingComponent, Configurable, ContentHandler, Disposable, LexicalHandler, Poolable, Recyclable, Serviceable, org.apache.cocoon.sitemap.SitemapModelComponent, org.apache.cocoon.transformation.Transformer, org.apache.cocoon.xml.XMLConsumer, XMLConsumer, org.apache.cocoon.xml.XMLPipe, org.apache.cocoon.xml.XMLProducer

public class XSLTTransformer
extends org.apache.cocoon.transformation.AbstractTransformer
implements Serviceable, Configurable, org.apache.cocoon.caching.CacheableProcessingComponent, Disposable

The XSLT stylesheet processor

This Transformer is used to transform the incoming SAX stream using a TrAXProcessor. Use the following sitemap declarations to define, configure and parameterize it:

In the map:sitemap/map:components/map:transformers:
 <map:transformer name="xslt" src="org.apache.cocoon.transformation.TraxTransformer">
<use-request-parameters>false</use-request-parameters> <use-browser-capabilities-db>false</use-browser-capabilities-db> <use-session-info>false</use-session-info> <xslt-processor-role>xslt</xslt-processor-role> <check-includes>true</check-includes> </map:transformer>
The <use-request-parameter> configuration forces the transformer to make all request parameters available in the XSLT stylesheet. Note that this has implications for caching of the generated output of this transformer.
This property is false by default.

The <use-cookies> configuration forces the transformer to make all cookies from the request available in the XSLT stylesheets. Note that this has implications for caching of the generated output of this transformer.
This property is false by default.

The <use-session-info> configuration forces the transformer to make all of the session information available in the XSLT stylesheetas.
These infos are (boolean values are "true" or "false" strings: session-is-new, session-id-from-cookie, session-id-from-url, session-valid, session-id.
This property is false by default.

Note that this has implications for caching of the generated output of this transformer.
The <xslt-processor-role> configuration allows to specify the TrAX processor (defined in the cocoon.xconf) that will be used to obtain the XSLT processor. This allows to have several XSLT processors in the configuration (e.g. Xalan, XSLTC, Saxon, ...) and choose one or the other depending on the needs of stylesheet specificities.
If no processor is specified, this transformer will use the XSLT implementation that Cocoon uses internally. The <check-includes> configuration specifies if the included stylesheets are also checked for changes during caching. If this is set to true (default), the included stylesheets are also checked for changes; if this is set to false, only the main stylesheet is checked. Setting this to false improves the performance, and should be used whenever no includes are in the stylesheet. However, if you have includes, you have to be careful when changing included stylesheets as the changes might not take effect immediately. You should touch the main stylesheet as well.

In a map:sitemap/map:pipelines/map:pipeline:

 <map:transform type="xslt" src="stylesheets/yours.xsl">
<parameter name="myparam" value="myvalue"/> </map:transform>
All <parameter> declarations will be made available in the XSLT stylesheet as xsl:variables.

Version:
SVN $Id: XSLTTransformer.html 1304280 2012-03-23 11:18:01Z ilgrosso $

Field Summary
protected  Map logicSheetParameters
          Logicsheet parameters (protected because used by subclasses)
protected  ServiceManager manager
          The service manager instance (protected because used by subclasses)
protected  Map objectModel
          The object model (protected because used by subclasses)
protected  TransformerHandler transformerHandler
          The trax TransformerHandler
protected  SourceValidity transformerValidity
          The validity of the Transformer
 
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer
 
Fields inherited from interface org.apache.cocoon.transformation.Transformer
ROLE
 
Constructor Summary
XSLTTransformer()
           
 
Method Summary
 void configure(Configuration conf)
          Configure this transformer.
 void dispose()
          Disposable
 void endDocument()
          Fix for stopping hanging threads of Xalan
 Serializable getKey()
          Generate the unique key.
protected  Map getLogicSheetParameters()
          Get the parameters for the logicsheet
 SourceValidity getValidity()
          Generate the validity object.
 void recycle()
          Recyclable
 void service(ServiceManager manager)
          Set the current ServiceManager instance used by this Serviceable.
 void setConsumer(org.apache.cocoon.xml.XMLConsumer consumer)
          Set the XMLConsumer that will receive XML data.
 void setup(org.apache.cocoon.environment.SourceResolver resolver, Map objectModel, String src, Parameters par)
          Set the SourceResolver, the Map with the object model, the source and sitemap Parameters used to process the request.
 void startDocument()
           
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLPipe
characters, comment, endCDATA, endDTD, endElement, endEntity, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startCDATA, startDTD, startElement, startEntity, startPrefixMapping
 
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
setContentHandler, setLexicalHandler
 
Methods inherited from class org.apache.cocoon.util.AbstractLogEnabled
getLogger, setLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xml.sax.ContentHandler
characters, endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startElement, startPrefixMapping
 
Methods inherited from interface org.xml.sax.ext.LexicalHandler
comment, endCDATA, endDTD, endEntity, startCDATA, startDTD, startEntity
 

Field Detail

manager

protected ServiceManager manager
The service manager instance (protected because used by subclasses)


objectModel

protected Map objectModel
The object model (protected because used by subclasses)


logicSheetParameters

protected Map logicSheetParameters
Logicsheet parameters (protected because used by subclasses)


transformerHandler

protected TransformerHandler transformerHandler
The trax TransformerHandler


transformerValidity

protected SourceValidity transformerValidity
The validity of the Transformer

Constructor Detail

XSLTTransformer

public XSLTTransformer()
Method Detail

configure

public void configure(Configuration conf)
               throws ConfigurationException
Configure this transformer.

Specified by:
configure in interface Configurable
Throws:
ConfigurationException

service

public void service(ServiceManager manager)
             throws ServiceException
Set the current ServiceManager instance used by this Serviceable.

Specified by:
service in interface Serviceable
Throws:
ServiceException

setup

public void setup(org.apache.cocoon.environment.SourceResolver resolver,
                  Map objectModel,
                  String src,
                  Parameters par)
           throws SAXException,
                  org.apache.cocoon.ProcessingException,
                  IOException
Set the SourceResolver, the Map with the object model, the source and sitemap Parameters used to process the request.

Specified by:
setup in interface org.apache.cocoon.sitemap.SitemapModelComponent
Throws:
SAXException
org.apache.cocoon.ProcessingException
IOException

getKey

public Serializable getKey()
Generate the unique key. This key must be unique inside the space of this component.

Specified by:
getKey in interface org.apache.cocoon.caching.CacheableProcessingComponent
Returns:
The generated key hashes the src

getValidity

public SourceValidity getValidity()
Generate the validity object.

Specified by:
getValidity in interface org.apache.cocoon.caching.CacheableProcessingComponent
Returns:
The generated validity object or null if the component is currently not cacheable.

setConsumer

public void setConsumer(org.apache.cocoon.xml.XMLConsumer consumer)
Set the XMLConsumer that will receive XML data.

Specified by:
setConsumer in interface org.apache.cocoon.xml.XMLProducer

getLogicSheetParameters

protected Map getLogicSheetParameters()
Get the parameters for the logicsheet


dispose

public void dispose()
Disposable

Specified by:
dispose in interface Disposable

recycle

public void recycle()
Recyclable

Specified by:
recycle in interface Recyclable

endDocument

public void endDocument()
                 throws SAXException
Fix for stopping hanging threads of Xalan

Specified by:
endDocument in interface ContentHandler
Throws:
SAXException

startDocument

public void startDocument()
                   throws SAXException
Specified by:
startDocument in interface ContentHandler
Throws:
SAXException


Copyright © 1999-2008 The Apache Software Foundation. All Rights Reserved.