xslt - Remove duplicate subcategory block items from xml -
xslt - Remove duplicate subcategory block items from xml -
<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 remove duplication of 3rd block sub category output. please help me on this. want output :
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>
xml xslt
Comments
Post a Comment