Reputation: 51
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 file i want to check this value in conditon.
How I can do that??
Upvotes: 4
Views: 14095
Reputation: 22652
Refer following
Also remember to add DEFER
attrinute.
<SCRIPT LANGUAGE="javascript" DEFER="true">
<xsl:comment>
function hiLite()
{
alert("hello");
}
</xsl:comment>
</SCRIPT>
Upvotes: 2
Reputation: 66714
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>
Upvotes: 4