Replacement of and in XSL

2019-03-06 02:04发布

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>
             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条回答
走好不送
2楼-- · 2019-03-06 02:17

Embedded extension functions in other language is not the content model of XSLT.

Extension elements and extension functions are part of the content model as described in http://www.w3.org/TR/xslt#extension : it's implementation dependant how exactly an XSLT processor register those extensions.

As pointed by @Martin Honnen's answer, in XSLT 2.0 you can declare "stylesheet functions" with XSLT itself.

查看更多
趁早两清
3楼-- · 2019-03-06 02:39

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.

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.

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.

查看更多
登录 后发表回答