开发者

How to call external javascript function in xsl?

I have one js file in which one function is returning value.

I want to compare this value with xml value in xsl file.

My javascript is

function getUser()
{
   return user;
}

In xsl 开发者_JAVA技巧file i want to check this value in conditon.

How I can do that??


Although it is not standard, it is possible to execute JavaScript functions from within your XSLT.

With MSXML you can use the msxsl:script extension element.

<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxsl="urn:schemas-microsoft-com:xslt"
      xmlns:user="http://mycompany.com/mynamespace">

<msxsl:script language="JScript" implements-prefix="user">
  function getUser()
  {
   return user;
  }

</msxsl:script>

<xsl:template match="/">
   <xsl:value-of select="user:getUser(.)"/>
</xsl:template>

</xsl:stylesheet>


Refer following

  1. How To Include Client-Side Script Functions in an XSL Document
  2. Passing parameters to javascript script in xslt
  3. Row value is not available in javascript
  4. Calling Javascript within XSL after transformation in RSS Web Part

Also remember to add DEFER attrinute.

 <SCRIPT LANGUAGE="javascript" DEFER="true">
  <xsl:comment>

function hiLite()
 {
   alert("hello");
 }

</xsl:comment>
</SCRIPT>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜