Using Javascript in XSL

admin

Administrator
Staff member
Am relatively new to XML and XSL. Below is an excerpt of the code that I am using.

I am trying to perform a transformation from XML to HTML and doing some validation in Javascript embedded in XSL file. Whenever I use the statement "if (i>100)" as in below code it throws error, but when I use the statement "if ('i>100')" i.e. the condition present within single quotes, it does not give errors but returns true for the condition even if it is logically false. In other words maybe it does not evaluate the condition ? Any, insights on how to solve this since I have to base decisions on value being higher or lesser ?

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" xmlns:xslt="http://www.w3.org/1999/XSL/Transform" result-ns="">
<xsl:template match="/">
<html>
<head>
<script language="javascript">
var l_index=0;
...
...
function pop_array()
{
...
...
if (i>100)
break;
if ('i>100')
break;
l_index=l_index+1;
}
...
...
</script>
</head>
<body>
<xsl:apply-templates select="linkdetails"/>
<script language="javascript">
...
...
</script>
</body>
</html>
</xsl:template>

<xsl:template match="linkdetails">
<xsl:apply-templates select="linkrow"/>
</xsl:template>
...
...
</xsl:stylesheet>
 
Back
Top