Replacement of <xsl:eval> and <xsl:script> in 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>
             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????

Answers


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.


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.


Need Your Help

Allow user to copy image from picturebox and save it everywhere

c# image clipboard copy-paste

In my application I have a pictureBox that shows an image. When user right clicks on the pictureBox and selects Copy from the context menu, I want to copy the image into the clipboard so the user can

Unable to use curl despite it appears enabled

php curl command-line cmd xampp

I am using xampp on Windows 8 ,curl appears to be enabled in my PHP configuration but still when I write this in cmd

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.