XSLT Xalan dyn:评估示例

发布于 2024-07-07 23:54:42 字数 208 浏览 7 评论 0原文

我希望您在样式表中使用 EXSLT - DYN:EVALUATE。 我已添加名称pace,但我不知道需要导入的 .xsl 文件在哪里。 我不相信我安装了 XALAN 来指向导入。 我该如何安装这个? 安装后,我将其指向 .xsl,它会选择该函数并应用它吗? 我正在运行Windows。 XSLT 文件包含在 XML 文档的顶部。

谢谢皮特

I want yo use the EXSLT - DYN:EVALUATE in a style sheet. I have added the names pace but I don't know where the .xsl file I need to import is. I don't believe I have XALAN installed to point the import to. How would I install this? Once installed and I point it to the .xsl will it pick up the function and apply it? I am running Windows. The XSLT file is included at the top of the XML document.

Thanks

Pete

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

究竟谁懂我的在乎 2024-07-14 23:54:42

Xalan 内置了 EXSL dyn:evaluate 函数,您无需导入任何内容即可使用它。 您只需要声明名称空间。 我将举一个小例子:

input.xml

<root>
<foo>I am foo</foo>    
<bar>I am bar</bar>    
</root>

dyn_evaluate.xsl

<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:dyn="http://exslt.org/dynamic"
    extension-element-prefixes="dyn">

  <xsl:param name="path"/>

  <xsl:output method="text"/>

  <xsl:template match="/">
    <xsl:value-of select="dyn:evaluate($path)"/>
  </xsl:template>

</xsl:stylesheet>

运行

xalan.exe -p path '/root/foo' input.xml dyn_evaluate.xsl

给出

I am foo

运行

xalan.exe -p path '/root/bar' input.xml dyn_evaluate。 xsl

给出

I am bar

希望这有帮助。

Xalan has the EXSL dyn:evaluate function built-in, you don't need to import anything in order to use it. You just need to declare the namespace. I'll give a small example:

input.xml:

<root>
<foo>I am foo</foo>    
<bar>I am bar</bar>    
</root>

dyn_evaluate.xsl:

<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:dyn="http://exslt.org/dynamic"
    extension-element-prefixes="dyn">

  <xsl:param name="path"/>

  <xsl:output method="text"/>

  <xsl:template match="/">
    <xsl:value-of select="dyn:evaluate($path)"/>
  </xsl:template>

</xsl:stylesheet>

Running

xalan.exe -p path '/root/foo' input.xml dyn_evaluate.xsl

gives

I am foo

Running

xalan.exe -p path '/root/bar' input.xml dyn_evaluate.xsl

gives

I am bar

Hope this helps.

初见终念 2024-07-14 23:54:42

您将如何从 JSP 页面调用它? JSP 提供 XML,当前将样式表附加到 XML 页面并提供结果。

How would you call this from a JSP page? The JSP serves up the XML and currently attaches the style sheet to the XML page and servers the result.

绝對不後悔。 2024-07-14 23:54:42

不能,因为如果您向客户端提供带有附加样式表的 XML 页面,则这是行不通的。 浏览器不支持 exslt。

但是,如果您在服务器上进行 XSLT 处理(使用 xalan),您可以让它工作,但我不明白如何将 xslt 与 jsp 结合起来。

You can't, because if you'll serve the client with XML page with attached stylesheet, this wouldn't work. Browsers don't support exslt.

However, if you do XSLT processing on server (with xalan) you can get it to work, but I don't understand how you combine xslt with jsp.

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