1

I have a requirement where I have to call functions in xsl:value-of select=<Function Name>. The below code helps me do it in IE, but I need the same alternative for Chrome.

<xsl:value-of select="xslscript:ConvertDate()"/>

      <msxsl:script language="javascript" implements-prefix="xslscript">
     function ConvertDate()
    {
                 /*Function body*/
    }

... where msxsl is the namespace given by Microsoft (xmlns:msxsl="urn:schemas-microsoft-com:xslt").

I need the same support for Chrome. Please let me know how can I call the ConvertDate method, as I do not have msxsl namespace support for Chrome, since this is given by Microsoft and it is IE specific.

Eiríkr Útlendi
  • 1,160
  • 11
  • 23
Ankur
  • 11
  • 3
  • As far as I know, Chrome uses libxslt http://xmlsoft.org/libxslt/ as its XSLT library and that does not have support to any extension element to write extension functions in Javascript. So I don't think there is a way to do what you want. You could check whether you can implement the function logic in XSLT 2.0 using `xsl:function` and then use Saxon-CE or Saxon-JS inside the browser to execute the XSLT, if you really need to use client-side XSLT. Or you need to move the XSLT to the server. – Martin Honnen Jul 05 '17 at 08:19
  • 1
    You might also be able to convert your functions into pure XSLT. For your `ConvertDate`, in XSLT 1.0 you would probably have to use string functions, such as substring, to manipulate the date. The complexity of this would depend on what your ConvertDate function actually did though. – Tim C Jul 05 '17 at 08:51
  • 1
    To overcome this problem, I ported the javascript to a separate file and edited the xsl out put to have the browser include that new file. The javascript runs client-side, which Chrome can handle. – Jeromy French Oct 18 '18 at 16:13

0 Answers0