Added by Jeremy Quinn, last edited by Jeremy Quinn on Mar 29, 2006  (view change)

Labels:

jx jx Delete
hippojx hippojx Delete
jxtemplate jxtemplate Delete
Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.

Hippo JXTemplate Generator, what is it? How do you use it? What advantages does it bring?

The JXTemplate Generator in Cocoon is a generator that implements a simple language to allow you to output data from the Sitemap, Flowscript, business Objects etc. into the XML generated by the pipeline.

This technique is commonly used in DASL Queries that your Hippo Site may make, as you often need to pass parameters like the target of a query from the Sitemap to the generated DASL Query.

The JXTemplate Generator does not handle Caching natively, without something else to create the Cache Keys for it.

Typically this is done via FlowScript.

Having to go via FlowScript means that you end up needing two pipelines, one to trigger the FlowScript, and one called by the FlowScript to generate the DASL.

To overcome this inconvenience, Hippo wrote their own version of the JXTemplate Generator, which is able to produce Cache Keys automatically, from the Sitemap Parameters passed to it:

<map:match pattern="dasl/*/**">
  <map:generate src="site://jx/dasl-{1}.xml" type="hippojx">
    <map:parameter name="target" value="{repository:files}/{2}"/>
    <map:parameter name="path" value="{repository:rootPath}{repository:filesPath}/{2}"/> 
    <map:parameter name="query" value="{1}"/> 
    <map:parameter name="depth" value="infinity"/>
    <map:parameter name="nrOfResults" value="30"/>
  </map:generate>
  <map:transform type="webdav"/>
    <map:transform src="site://transformers/util/dasl2collection.xsl">
    <map:parameter name="path" value="{repository:rootPath}{repository:filesPath}/{2}"/>
  </map:transform>
  <map:serialize type="xml"/>
</map:match>

In the example above, the HippoJXTemplate Generator receives 5 parameters. Each of these parameter values is used to make a Cache Key automatically for you, avoiding the double step you'd have with the Cocoon JXTemplate + FlowScript combination.

The HippoJXTemplate Generator takes 3 optional parameters :

Provide your own cache key:

<map:parameter name="jx:cacheKey" value="your custom cachekey"/>

Only include the named parameters in the auto-generated cache key (ignoring all others) :

<map:parameter name="jx:includeInKey" value="comma, delimited, list, of, param, names, to, include"/>

Exclude the named parameters in the auto-generated cache key (including all others) :

<map:parameter name="jx:excludeFromKey" value="comma, delimited, list, of, param, names, to, exclude"/>

To use the HippoJXTemplate Generator in your own project, you first need to add a dependency to the code, in your project.xml file thus :

<dependency>
  <id>hippo-cocoon-extensions:hippo-misc</id>
  <version>1.0.2</version>
  <properties><cocoon.bundle>true</cocoon.bundle></properties>
</dependency>

Once your project has been built, and the dependencies satisfied, you can add the configuration for the generator to your sitemap :

<map:components>
  <map:generators default="file">
    <map:generator label="content" logger="sitemap.generator.jx" name="hippojx" 
         pool-grow="4" pool-max="32" pool-min="4" src="nl.hippo.cocoon.generation.HippoJXTemplateGenerator"/>
  	<!-- more generators -->
  </map:generators>
  <!-- more components -->
<map:components>