I am trying to display all
s of
node. But I don\'t want to display duplicate entries of department
from
You need a second level of Muenchian grouping - you already have a key that finds unique company names, you now need a second key that finds unique company-department pairs:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" />
<xsl:key name="companyname" match="company" use="companyname"/>
<xsl:key name="companyDepartment" match="company"
use="concat(companyname, '|', department)" />
<xsl:template match="/">
<xsl:for-each select="/employee_data/employeedetails/company[generate-id() = generate-id(key('companyname', companyname)[1])]">
<tr>
<td>
<xsl:value-of select="@id"/>
</td>
<td>
<xsl:apply-templates select="key('companyname', companyname)
[generate-id() = generate-id(key('companyDepartment',
concat(companyname, '|', department))[1])]" />
</td>
</tr>
</xsl:for-each>
</xsl:template>
<xsl:template match="company">
<xsl:value-of select="department" />
<br />
</xsl:template>
</xsl:stylesheet>
This filters the list of all company
elements matching the current companyname
so you just get the first mention of each department
.