简体   繁体   English

如何在xsl中调用外部javascript函数?

[英]How to call external javascript function in xsl?

I have one js file in which one function is returning value. 我有一个js文件,其中一个函数返回值。

I want to compare this value with xml value in xsl file. 我想将此值与xsl文件中的xml值进行比较。

My javascript is 我的javascript是

function getUser()
{
   return user;
}

In xsl file i want to check this value in conditon. 在xsl文件中,我想在conditon中检查此值。

How I can do that?? 我怎么能这样做?

Although it is not standard, it is possible to execute JavaScript functions from within your XSLT . 虽然它不是标准的, 但可以在XSLT中执行JavaScript函数

With MSXML you can use the msxsl:script extension element . 使用MSXML,您可以使用msxsl:script扩展元素

<?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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM