在 Spring MVC 中使用 AXSLT 组件

发布于 2024-07-24 23:02:40 字数 1069 浏览 2 评论 0原文

我不久前编写了一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

奈何桥上唱咆哮 2024-07-31 23:02:40

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文