The processing part of a Pipeline. Its inputs and outputs are both SAX events. The output stream is the result of some processing, which may involve an XSLT transformation.

Declaration

<map:transformers default="xslt">
<map:transformer name="xslt" src="org.apache.cocoon.transformation.TraxTransformer">
<use-store map:value="true"/>
<use-request-parameters map:value="false"/>
<use-browser-capabilities-db map:value="false"/>
</map:transformer>
<map:transformer name="log" src="org.apache.cocoon.transformation.LogTransformer"/>
...
</map:transformers>

The default attribute on the transformers element indicates the default transformer to use if a pipeline does not explicitly declare one.

Usage

Sample usage:

<map:match pattern="hello.html">
<map:generate src="docs/samples/hello-page.xml"/>
<map:transform src="stylesheets/page/simple-page2html.xsl"/>
<map:serialize type="html"/>
</map:match>

Standard Transformers

The simplest transformer provided is the XalanTransformer (and presumably one of these performing an identity transform). Several transformers are provided with Cocoon:

  • XSLTTransformer – reads XSLT stylesheet from file system or URL and transforms the event stream using it. Can use several XSLT implementations
  • I18NTransformer – uses XML dictionary to translate content into other languages
  • Log Transformer – useful for debugging, copies SAX events into a file or the STDOUT of the servlet engine. Not thread safe
  • SQLTransformer – allows interaction with a database, produces XML results from database data. cf: OracleXSQL
  • Filter Transformer – allows filtering of content, particularly useful with SQLTransformer, as it allows results to be chunked into pages.
  • Read/Write DOM Session Tranformers – extracts a DOM object from the session and inserts it into the SAX event stream
  • XInclude Transformer – XInclude implementation, performs inclusions if XInclude elements present in stream
  • CInclude Transformer – 'Cocoon Include', cocoon-specific, but higher performing and more versatile.
  • XT Transformer – allows use of XT, which isn't TRAX compatible
  • LDAP Transformer – allows querying of LDAP directory, not part of distribution
  • LuceneIndexTransformer – creates Lucene indexes, for searching. Available in the Lucene block in C2.1.

Additional Transformers

Implementing transformers

ImplementingTransformers

  • No labels