Hi,
I've an XML document and I am creating another XML using XSL. I need to check some specific conditions and for that I want to use Javascript in my XSL. I tried it, however, couldn't get the desired result. As I could not change the XSL variables frequiently so i am trying to use Javascript.
XSL-
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:es="http://ucmservice"
version="1.0" xmlns="http://filenet.com/namespaces/wcm/apps/1.0" xmlns:java="http://xml.apache.org/xalan/java" xmlns:js="urn:custom-javascript" xmlns:lxslt="http://xml.apache.org/xslt"
xmlns:totalSys="TotalSystem" extension-element-prefixes="totalSys">
<lxslt:component prefix="totalSys" functions="checkFirstProp">
<lxslt:script lang="javascript">
var firstPropVal = "";
var secondPropVal = "";
var completedFirstPropVal= new Array();
var completedSecondPropVal= new Array();
var firstDecisionFlag = 0;
function checkFirstProp(xmlValue)
{
firstDecisionFlag = 0;
if(firstPropVal.length == 0)
{
firstPropVal = xmlValue;
firstDecisionFlag = 1;
}
else
{
if(firstPropVal != xmlValue)
{
firstPropVal = xmlValue;
firstDecisionFlag = 2;
}
}
return firstDecisionFlag;
}
</lxslt:script>
</lxslt:component>
<xsl:template match="/">
<xsl:apply-templates select="XMLTag"/>
</xsl:template>
<xsl:template match="XMLTag">
<xsl:variable name="firstPropDecisionFlag">
<xsl:value-of select="totalSys:checkFirstProp(param)"/>
</xsl:variable>
<xsl:if test="$firstPropDecisionFlag=2">
{
task
}
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Please advise, where am i going wrong?