Problem in using xpath with xslt having distinct values
Posted
by AB
on Stack Overflow
See other posts from Stack Overflow
or by AB
Published on 2010-03-31T22:10:21Z
Indexed on
2010/03/31
23:23 UTC
Read the original article
Hit count: 321
I have XML like,
<items>
<item>
<products>
<product>laptop</product>
<product>charger</product>
<product>Cam</product>
</products>
</item>
<item>
<products>
<product>laptop</product>
<product>headphones</product>
<product>Photoframe</product>
</products>
</item>
<item>
<products>
<product>laptop</product>
<product>charger</product>
<product>Battery</product>
</products>
</item>
</items>
and I am using xslt on it
//can't change xpath as getting it from somewhere else
<xsl:param name="xparameter" select="items/item[products/product='laptop' and products/product='charger']"></xsl:param>
<xsl:template match="/">
<xsl:for-each select="$xparameter">
<xsl:for-each select="products/product[not(.=preceding::product)]">
<xsl:sort select="."></xsl:sort>
<xsl:value-of select="." ></xsl:value-of>,
</xsl:for-each>
</xsl:for-each>
</xsl:template>
I want the output to be
laptop
charger
cam
Battery
But I m not getting the result as I m expecting...distinct values is working fine ..something is getting wrong when I am adding that and claus
© Stack Overflow or respective owner