在 Spring MVC 中使用 AXSLT 组件
我不久前编写了一个 Java 应用程序,它使用 Xalan 通过 XSLT 处理 XML。 现在我正在努力走向春天。
我在访问组件时遇到问题。 据我所知,我的 XML、XSLT 和 Java 对象是正确的,但 Spring 似乎无法找到并引用我想要访问的组件。
...
<axslt:component prefix="oni" functions="say">
<axslt:script lang="javaclass" src="xslt.components.TestComponent" />
</axslt:component>
...
我还尝试使用 JavaScript 组件(使用 bsf.jar 和 js.jar),但也失败了。
...
<axslt:component prefix="js" functions="say">
<xalan:script lang="javascript">
function say() { return "Hello from JavaScript"; }
</xalan:script>
</axslt:component>
...
我一直收到此错误:
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)
...
我在网上查找过,但没有找到很多可以继续的内容。 Spring+XSLT 似乎并不是一个非常突出的话题。 关于 Spring 中我需要配置的东西或者我需要扩展的东西有什么建议吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Spring 的 XsltView 类的源代码可以免费获得。 我建议阅读它以了解它如何使用 XSLT API,并将其与您自己的代码的执行方式进行比较。
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.