我有这样的XML:如何使用XSLT来创造独特的价值
<items>
<item>
<products>
<product>laptop</product>
<product>charger</product>
</products>
</item>
<item>
<products>
<product>laptop</product>
<product>headphones</product>
</products>
</item>
</items>
我希望它输出像
laptop charger headphones
我试图用distinct-values()
但我猜即时通讯做错了什么。谁能告诉我如何使用distinct-values()
来实现这个目标?谢谢。
<xsl:template match="/">
<xsl:for-each select="//products/product/text()">
<li>
<xsl:value-of select="distinct-values(.)"/>
</li>
</xsl:for-each>
</xsl:template>
但它给我的输出是这样的:
<li>laptop</li>
<li>charger</li>
<li>laptop></li>
<li>headphones</li>
可能是值得看此相关的问题:http://stackoverflow.com/questions/1813286/xslt-select-distinct-but-slightly-different-to-other-examples – 2010-02-18 19:33:19