views:

232

answers:

1

I while ago I wrote a Java application that processes XML with XSLT using Xalan. Now I'm trying to move towards Spring.

I've been having trouble accessing components. As far as I can tell my XML, XSLT and Java objects are correct, but Spring cannot seem to find and reference the components I want to access.

...
<axslt:component prefix="oni" functions="say">
    <axslt:script lang="javaclass" src="xslt.components.TestComponent" />
</axslt:component>
...

I also tried with a JavaScript component (with bsf.jar and js.jar) and that also fails.

...
<axslt:component prefix="js" functions="say">
    <xalan:script lang="javascript">
     function say() { return "Hello from JavaScript"; }
    </xalan:script>
</axslt:component>
...

I consistently get this error:

javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
    com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(Unknown Source)
    org.springframework.web.servlet.view.xslt.XsltView.loadTemplates(XsltView.java:417)
    ...

I've looked online and haven't found a lot to go on. Spring+XSLT doesn't seem to be a very prominent topic. Any suggestions on something in Spring I need to configure, or something I would need to extend?

A: 

The source code for Spring's XsltView class is freely available. I suggest reading it to see how it uses the XSLT API, and compare that with how your own code did it.

skaffman