XSL Counter

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,
I have a scenario where I have a XML like -
<AllEmp>
<EMPTable>
<Table>
<EID>1</EID>
<EmpID>1</EmpID>
<EmpName>Name1</EmpName>
<EmpDesig>Desig1<EmpDesig>
</Table>
<Table>
<EID>2</EID>
<EmpID>2</EmpID>
<EmpName>Name2</EmpName>
<EmpDesig>Desig2<EmpDesig>
</Table>
<Table>
<EID>3</EID>
<EmpID>3</EmpID>
<EmpName>Name3</EmpName>
<EmpDesig>Desig3<EmpDesig>
</Table>
</EMPTable>
<EMPDetails>
<Table>
<EID>1</EID>
<Dept>Dept1<Dept>
</Table>
<Table>
<EID>2</EID>
<Dept>Dept2<Dept>
</Table>
<Table>
<EID>3</EID>
<Dept>Dept3<Dept>
</Table>
</EMPDetails>
<AllEmp>
I loop through this and generate a different set of XML considering the unique EID that is there, this process is working fine.
I get this like-
<xsl:for-each select="AllEmp/EMPTable/Table
<xsl:variable name="EMPKeyId
<xsl:value-of select="EID"/>
</xsl:variable>
<xsl:variable name="EmpDept
<xsl:value-of select="//AllEmp/EMPTable/Table[EID = $EMPKeyId]Dept"/>
</xsl:variable>
</xsl:for-each>
within the for-each loop I have a If condition to process only if the EMPKeyId is not null, this is working fine as well.
All I want is the count whenever it enters the if condition, I tried this with position(), but say when the EMPKeyId is null and I will not be entering the If condition I get a wrong Position number, is there a way to achieve this? Could you please advise. Thanks.
Rpaul

View the full article
 
Back
Top