je XML comme ceci:Comment utiliser XSLT pour créer des valeurs distinctes
<items>
<item>
<products>
<product>laptop</product>
<product>charger</product>
</products>
</item>
<item>
<products>
<product>laptop</product>
<product>headphones</product>
</products>
</item>
</items>
Je veux à la sortie comme
laptop charger headphones
Je tentais d'utiliser distinct-values()
mais je suppose im faire quelque chose de mal . Quelqu'un peut-il me dire comment y parvenir en utilisant distinct-values()
? Merci.
<xsl:template match="/">
<xsl:for-each select="//products/product/text()">
<li>
<xsl:value-of select="distinct-values(.)"/>
</li>
</xsl:for-each>
</xsl:template>
mais sa me donner une sortie comme ceci:
<li>laptop</li>
<li>charger</li>
<li>laptop></li>
<li>headphones</li>
vaudraient peut-être examiner cette question connexe: http://stackoverflow.com/questions/1813286/xslt-select-distinct-but-slightly-different-to-other-examples –