Upgrading eXist for XSLT 2.0 (Saxon)

This howto assumes that you wish to replace eXist's default XSLT processor (Xalan) with a processor that supports XSLT 2.0 (Saxon). eXist is installed in EXIST_HOME. The following describes the necessary steps to replace Xalan with Saxon.

1.1 Required jars

This has been tested with both Saxon-B versions 8.7.3 to 9.1.0.7, Saxon-HE 9.2.0.3 and Jakarta RegExp version 1.5

Saxon is available from -

Apache Jakarta RegExp is available from -

Download Saxon and Apache Jakarta Regexp and copy the following jars to EXIST_HOME/lib/user

  • jakarta-regexp-1.5.jar (only needed if your using eXist with Cocoon and are also switching Cocoon to Saxon as well).

For Saxon-B -

  • saxon9.jar
  • saxon9-dom.jar
  • saxon9-xpath.jar

For Saxon-HE -

  • saxon9he.jar

If you are not using eXist with Cocoon, or wish for Cocoon to also use Saxon instead of Xalan, delete the file xalan.jar in EXIST_HOME/lib/endorsed

1.2 eXist Configuration

In the eXist configuration file EXIST_HOME/conf.xml find the configuration section for the transformer and change:

<transformer class="org.apache.xalan.processor.TransformerFactoryImpl" />

to:

<transformer class="net.sf.saxon.TransformerFactoryImpl" />

1.3 Cocoon Changes (Optional)

If you also wish for Cocoon to use Saxon instead of Xalan, you will also need to make changes to two Cocoon configuration files.

1.3.1 cocoon.xconf

Typically this is found in EXIST_HOME/webapp/WEB-INF

In the XSLT Processor section, comment out the two elements for configuring Xalan xslt and Xalan xsltc, e.g. -

<!--+ | XSLT Processor using xsltc from Xalan | For Interpreted Xalan use: | <transformer-factory>org.apache.xalan.processor.TransformerFactoryImpl</transformer-factory> +--> <!-- <component class="org.apache.excalibur.xml.xslt.XSLTProcessorImpl" logger="core.xslt-processor" role="org.apache.excalibur.xml.xslt.XSLTProcessor/xsltc"> <parameter name="use-store" value="true"/> <parameter name="transformer-factory" value="org.apache.xalan.xsltc.trax.TransformerFactoryImpl"/> </component> --> <!--+ | Xalan XSLT Processor +--> <!-- <component class="org.apache.excalibur.xml.xslt.XSLTProcessorImpl" logger="core.xslt-processor" role="org.apache.excalibur.xml.xslt.XSLTProcessor/xalan"> <parameter name="use-store" value="true"/> <parameter name="incremental-processing" value="false"/> <parameter name="transformer-factory" value="org.apache.xalan.processor.TransformerFactoryImpl"/> </component> -->

Then uncomment the element for configuring Saxon, and make sure the transformer-factory parameter is set correctly, as below -

<!--+ | Saxon XSLT Processor | For old (6.5.2) Saxon use: | <parameter name="transformer-factory" value="com.icl.saxon.TransformerFactoryImpl"/> | For new (7+) Saxon use: | <parameter name="transformer-factory" value="net.sf.saxon.TransformerFactoryImpl"/> +--> <component logger="core.xslt-processor" role="org.apache.excalibur.xml.xslt.XSLTProcessor/saxon" class="org.apache.excalibur.xml.xslt.XSLTProcessorImpl"> <parameter name="use-store" value="true"/> <parameter name="transformer-factory" value="net.sf.saxon.TransformerFactoryImpl"/> </component>

Modify the XPath Processor configuration from:

<xpath-processor class="org.apache.excalibur.xml.xpath.XPathProcessorImpl" logger="core.xpath-processor"/>

to:

<xpath-processor class="org.apache.excalibur.xml.xpath.Saxon7ProcessorImpl" logger="core.xpath-processor"/>

1.3.2 sitemap.xmap

Typically this is found in EXIST_HOME/webapp

Here we need to change the XSLT Transformer section from:

<!-- NOTE: This is the default XSLT processor. --> <map:transformer logger="sitemap.transformer.xslt" name="xslt" pool-grow="2" pool-max="32" pool-min="8" src="org.apache.cocoon.transformation.TraxTransformer"> <use-request-parameters>false</use-request-parameters> <use-session-parameters>false</use-session-parameters> <use-cookie-parameters>false</use-cookie-parameters> <xslt-processor-role>xalan</xslt-processor-role> <check-includes>true</check-includes> </map:transformer>

to:

<!-- NOTE: This is the default XSLT processor. --> <map:transformer name="xslt" logger="sitemap.transformer.xslt" pool-max="32" src="org.apache.cocoon.transformation.TraxTransformer"> <use-request-parameters>false</use-request-parameters> <use-session-parameters>false</use-session-parameters> <use-cookie-parameters>false</use-cookie-parameters> <xslt-processor-role>saxon</xslt-processor-role> <check-includes>true</check-includes> </map:transformer>

Also comment out the other XSLT transformers for Xalan xslt and xsltc, e.g. -

<!-- NOTE: This is the same as the default processor but with a different name (for compatibility) --> <!-- <map:transformer logger="sitemap.transformer.xalan" name="xalan" pool-grow="2" pool-max="32" pool-min="8" src="org.apache.cocoon.transformation.TraxTransformer"> <use-request-parameters>false</use-request-parameters> <use-session-parameters>false</use-session-parameters> <use-cookie-parameters>false</use-cookie-parameters> <xslt-processor-role>xalan</xslt-processor-role> <check-includes>true</check-includes> </map:transformer> --> <!-- NOTE: You can also try XSLTC as the default processor. If you use Xalan extensions, use the "xalan" transformer. --> <!-- <map:transformer logger="sitemap.transformer.xsltc" name="xsltc" pool-grow="2" pool-max="32" pool-min="8" src="org.apache.cocoon.transformation.TraxTransformer"> <use-request-parameters>false</use-request-parameters> <use-session-parameters>false</use-session-parameters> <use-cookie-parameters>false</use-cookie-parameters> <xslt-processor-role>xsltc</xslt-processor-role> <check-includes>true</check-includes> </map:transformer> -->