<category link-id="681" link-handle="package-products" value="Package products">
<entry id="1077" images="1" products="1" brands="1">
<sub-category>
<item handle="pens">Pens</item>
<item handle="refills-pens">Refills : Pens</item>
</sub-category>
</entry>
<entry id="1075" images="1" products="1" brands="1">
<sub-category>
<item handle="pencil">Pencil</item>
<item handle="refills-pencil">Refills : Pencil</item>
</sub-category>
</entry>
<entry id="1073" images="1" products="1" brands="1">
<sub-category>
<item handle="pencil">Pencil</item>
<item handle="refills-pencil">Refills : Pencil</item>
</sub-category>
</entry>
<entry id="1050" images="1" products="1" brands="1">
<sub-category>
<item handle="marker">Marker</item>
<item handle="refills-marker">Refills : Marker</item>
</sub-category>
</entry>
I want to remove duplication of 3rd block from sub category for output. Please help me on this. I want output as :
Pens
Refills : Pens
Pencil
Refills : Pencils
Marker
Refills : Marker
Try This: (XSLT version 2)
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="kItemHandle" match="entry" use="sub-category/item"/>
<xsl:template match="node()|@*">
<xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy>
</xsl:template>
<xsl:template match="category">
<xsl:for-each select="entry[count(. | key('kItemHandle', sub-category/item[1])[1])=1]">
<xsl:value-of select="sub-category/item[1]"/>
<xsl:text>
</xsl:text>
<xsl:value-of select="sub-category/item[2]"/><xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments