ojoker
May 23rd, 2011, 03:14 AM
Hope anyone can help that I'm struggling to fetch JS var into xsl variable for e.g:
<?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="JavaScript" implements-prefix="js">
function getResult () {
var thisResult;
thisResult = "300";
return thisResult;
}
</msxsl:script>
<xsl:template match="/">
<xsl:variable name="JSattribute"><xsl:value-of select="js:getResult()"/></xsl:variable>
<xsl:variable name="XSLattribute">300</xsl:variable>
<xsl:choose>
<xsl:when test="string(number($JSattribute),string(number($XSLattribute))">
testAttribute is a match number
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
<?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="JavaScript" implements-prefix="js">
function getResult () {
var thisResult;
thisResult = "300";
return thisResult;
}
</msxsl:script>
<xsl:template match="/">
<xsl:variable name="JSattribute"><xsl:value-of select="js:getResult()"/></xsl:variable>
<xsl:variable name="XSLattribute">300</xsl:variable>
<xsl:choose>
<xsl:when test="string(number($JSattribute),string(number($XSLattribute))">
testAttribute is a match number
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>