Sourceforge Project Site
 

CachedFOPTransformer

Transformer features and configuration

Overview

This transformer uses a JAXP 1.2 -implementing XSLT processor and Apache FOP to transform the XML with one or more XSL files into XSL-FO then convert the XSL-FO into PDF or SVG. It takes advantage of TRaX interfaces to compile and cache stylesheets to speed up the transformation process. .

Features

  • Multiple XSL stylesheet support
  • Can output Adobe PDF or SVG format
  • Configurable cache of compiled stylesheets
  • Uses SAX to build the document
  • Can be extended to add SAX filters before XSLT processing

Configuration

Global

Global stxx.properties properties
Property Value Status
outputType svg | pdf (default) Optional
autoReloadTemplates true | false (default). If true, the cached Templates will be checked to see if the stylesheet has been modified since and reload as necessary. Optional
resolveFromTemplatePath false | true (default). If true, URIs used in xsl:import, or xsl:include are resolved from the directory of the parent stylesheet. Otherwise, URIs are resolved from the root directory of the web application. Optional
transformerFactoryClass The name of the JAXP transformer factory implementation to use. Optional
Note
If you are having problems with NullPointerExceptions when stxx is loading stylesheets, it could be because your servlet container doesn't implement request.getRealPath() in a useful manner. If this is the case, set both resolveFromTemplatePath and autoReloadTemplates to "false" and stxx will load the stylesheets using ServletContext.getResourceAsStream().

Transform-specific

These parameters are specified in stxx 1.2+ pipeline configuration format. See Configuring with Struts 1.1 for more information.

Transform-specific parameters
Parameter Value Status
path The path to the XSL file Required and can be repeated
debug true | false (default) Optional
attachRequestParameters false | true (default) Optional
attachRequestAttributes false | true (default) Optional
attachForm false | true (default) Optional
attachResources false | true (default) Optional
attachErrors false | true (default) Optional
attachMessages false | true (default)

When this transformer is debugged either by setting the "debug" param or by passing "debug=true" on the querystring (if activated), the debugging XML is the original stxx-produced XML transformed by the XSL files into XSL-FO. This should make it easier to debug FOP processing.

Examples

Global configuration:

stxx.transformer.pdf.class=com.oroad.stxx.transform.CachedFOPTransformer
stxx.transformer.pdf.outputType=pdf

Transform-specific configuration:

<pipeline match="pdf/*.dox">
    <transform type="pdf">
        <param name="path" value="/{1}.xsl" />
    </transform>
</pipeline>

by Don Brown