替换 <xsl:eval>和 <xsl:script>在 XSL 中 [英] Replacement of <xsl:eval> and <xsl:script> in XSL

查看:26
本文介绍了替换 <xsl:eval>和 <xsl:script>在 XSL 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试修改旧版本的 xsl.我遇到以下情况:

I am trying to modify an xsl which is of the older version. I come across the following:

<xsl:eval>FormatAccount(this)</xsl:eval>

<xsl:script>
    function FormatAccount(e) {
       // function details
    }
</xsl:script>

我正在尝试使用 <xsl:eval> 调用 FormatAccount() javascript 函数,并且该函数是用 <xsl:script> 编写的..

I am trying to call the FormatAccount() javascript function using <xsl:eval> and the function is written in <xsl:script>.

如何按照最新标准执行此操作?

How to do this as per the latest standards?

推荐答案

最新的标准是 XSLT 2.0 http://www.w3.org/TR/xslt20/,它没有任何功能可以在 Javascript 中定义函数,但是它允许您使用 XSLT 本身定义函数:http://www.w3.org/TR/xslt20/#stylesheet-functions.XSLT 2.0 受 XSLT 2.0 处理器支持,如 Saxon 9 http://saxon.sourceforge.net/、AltovaXML Toolshttp://www.altova.com/altovaxml.html 或 XQSharp http://www.xqsharp.com/xqsharp/beta.htm.

The latest standard is XSLT 2.0 http://www.w3.org/TR/xslt20/, it does not have any facility to define functions in Javascript, it however allows you to define functions with XSLT itself: http://www.w3.org/TR/xslt20/#stylesheet-functions. XSLT 2.0 is supported by XSLT 2.0 processors like Saxon 9 http://saxon.sourceforge.net/, AltovaXML Tools http://www.altova.com/altovaxml.html or XQSharp http://www.xqsharp.com/xqsharp/beta.htm.

如果您想使用 Javascript 来定义扩展功能,我们需要知道您使用的 XSLT 处理器,在我提到的这三个 XSLT 2.0 处理器中,我认为只有 AltovaXML 工具允许(http://manual.altova.com/AltovaXML/altovaxmlcommunity/index.html?xextmsxsl.htm),而且我认为只是为了更轻松地迁移为 Microsoft MSXML 编写的 XSLT 1.0 样式表.

If you want to use Javascript to define extension functions we need to know which XSLT processor you use, of those three XSLT 2.0 processors I mentioned I think only AltovaXML Tools allows that (http://manual.altova.com/AltovaXML/altovaxmlcommunity/index.html?xextmsxsl.htm), and only, I think, to allow easier migration of XSLT 1.0 stylesheets written for Microsoft MSXML.

如果您想使用 XSLT 1.0 处理器,那么在特定的编程语言(如 Javascript)中定义扩展函数也取决于您使用的处理器,对于 MSXML,有一个 msxsl:script 元素:http://msdn.microsoft.com/en-us/library/ms256042.aspx.

If you want to use an XSLT 1.0 processor then there too defining extension functions in a particular programming language like Javascript depends on the processor you use, for MSXML there is an msxsl:script element: http://msdn.microsoft.com/en-us/library/ms256042.aspx.

这篇关于替换 &lt;xsl:eval&gt;和 &lt;xsl:script&gt;在 XSL 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆