4

I'd like to use Saxon (9HE) for XSLT processing in Apache Cocoon (2.2). I've followed the instructions for using Saxon from http://wiki.apache.org/cocoon/Saxon. These instructions describe the process using an .xconf file, which is no longer the preferred method of Cocoon configuration (as described at http://cocoon.apache.org/2.2/core-modules/core/2.2/1259_1_1.html), though that page also notes that legacy .xconf configuration is still supported.

I've tried placing the core.xslt-processor configuration at WEB-INF/cocoon.xconf (as described in the Saxon instructions), at WEB-INF/cocoon/xconf/saxon-xslt.xconf (as described in the Cocoon config page linked above), and at META-INF/cocoon/saxon-xslt.xconf. In each case, I get the error:

org.apache.avalon.framework.service.ServiceException: Component with  \
'org.apache.excalibur.xml.xslt.XSLTProcessor/saxon' is not defined in \ 
this service manager. (Key='AvalonServiceManager')

I've placed saxon9he.jar in WEB-INF/lib, and have tried removing its META-INF directory as described in the Saxon instructions. I have restarted my servlet container (Jetty) for each case.

I'm a Java amateur, so it's certainly possible I'm missing some basic step. I should also note that I'm using Cocoon in the context of the DSpace system, so it's possible that DSpace is configured to ignore my .xconf files.

However, it seems like there should be a way to specify the Saxon processor using Spring config or a .properties file, but I haven't found any instructions for doing so online (they all specify the .xconf configuration process).

Any thoughts? Thanks!

Jacob Brown
  • 7,221
  • 4
  • 30
  • 50
  • Sorry you haven't had an answer. It seems we don't have anyone here using Cocoon with Saxon. – Michael Kay Mar 21 '14 at 17:20
  • @MichaelKay, thanks for the comment. I figured out how to do this and have added an answer below. My main problem was my ignorance of Java/Maven. It would still be nice to know how to do this with Spring config or .properties files, but this works for me for now. – Jacob Brown Mar 24 '14 at 14:36

1 Answers1

3

Answering my own question--

Using Saxon with Cocoon XSLT for DSpace

Create an xconf file at [dspace-src]/dspace/modules/xmlui/src/main/resources/META-INF/cocoon/avalon/cocoon-core-saxon-xslt.xconf and add the following lines:

<?xml version="1.0" encoding="UTF-8"?> <components> <component role="org.apache.excalibur.xml.xslt.XSLTProcessor/saxon" class="org.apache.cocoon.components.xslt.TraxProcessor"> <parameter name="use-store" value="true"/> <parameter name="transformer-factory" value="net.sf.saxon.TransformerFactoryImpl"/> </component> </components>

Add the following lines to [dspace-src]/dspace/modules/xmlui/pom.xml (or modify with your version of Saxon):

<dependency> <groupId>net.sf.saxon</groupId> <artifactId>Saxon-HE</artifactId> <version>9.5.1-4</version> </dependency>

Build DSpace with mvn package.

Update your webapps with ant update_webapps (or fresh_install or whatever).

In [dspace]/webapps/xmlui/sitemap.xmap, change the XSLT transformer xslt-processor-role value to saxon. Note: this can be done as part of the build process, but that's not how my workflow is currently set up.

Jacob Brown
  • 7,221
  • 4
  • 30
  • 50