TraxTransformer

XSL Transformers are the heart of any Paloose system (and Cocoon). At minimum they are the means for turning XML content into displayable HTML. They must not be first or last in the pipeline as they take and return DOM information in the pipe. A typical use of TRAXTransformer would be

<map:transformers default="xslt"> <map:transformer name="xslt" src="resource://lib/transforming/TRAXTransformer"> <map:use-request-parameters>true</map:use-request-parameters> </map:transformer> <map:pipelines> <map:pipeline> <map:match pattern="news-rss.xml"> <map:generate src="context://content/newsArticles.xml"/> <transform src="context://resources/transforms/xml2rss.xsl"/> <map:serialize/> </map:match> </map:pipeline> </map:pipelines>

which would process the file "newsArticles.xml" into RSS format using the XSL file "xml2rss.xsl.

Caching Support (avaliable after Version 1.3.0)

The TraxTransformer component supports caching of the data within the pipeline. The transformer takes several inputs that determine whether the pipeline data cache can be used: the state of the transformation file (XSL), the input DOM from the previous stage, and the parameters (have they changed).

Warning
Note that if you have an XSL file that includes other stylesheets, the transformer caching will not detect that these other file sheets have been modified. If you modify them it is important to clear out the caching to let the cache files to be rebuilt.

Enabling caching is done globally and locally. To turn on caching for all TraxTransformers there is an attribute cachable that should be set to true (true/yes/1). So setting the global flag would be (default is false):

<map:transformers default="xslt"> <map:transformer src="resource://lib/transforming/TRAXTransformer" name="xslt" cachable="no"/> ... </map:transformers>

This can be overriden by using the same attribute when the pipeline component is used:

<map:transform src="context://resources/transforms/page2html.xsl" cachable="no"> <map:parameter name="page" value="{1}"/> </map:transform>

The above would turn off the caching for just this instance in the pipeline. It is also possible to change the action of the cache via the query string by using the request parameters. The following would control the generator instance by including the query string "http://[host]/[path-file-name]?cachable=1" or "http://[host]/[path-file-name]?cachable=0".

<map:transformers default="xslt"> <map:transformer src="resource://lib/transforming/TRAXTransformer" name="xslt" cachable="no"> <map:use-request-parameters>true</map:use-request-parameters> </map:transformer> ... </map:transformers> ... <map:transform src="context://resources/transforms/page2html.xsl" cachable="{request-param:cachable}"> <map:parameter name="page" value="{1}"/> </map:transform>
Copyright 2006 – 2017 Hugh Field-Richards. All Rights Reserved.