First of all this
Code:
<item>
<title>random text1</title>
<category>research</category>
<category>marketing</category>
<category>industry</category>
</item>
<item>
<title>random text2</title>
<category>research</category>
<category>development</category>
</item>
<item>
<title>random text3</title>
<category>marketing</category>
<category>fishing</category>
<category>hunting</category>
<category>development</category>
</item>
What i need is to be able to generate a list of all the unique "category" items, without having any duplicates.... eg in the example above, the list would be "marketing, fishing, hunting, research, development, industry"
I've been using the following xsl, which works, but only when there is a single <category> in each <item> node, but i cant work out how to extend this to look at ALL the categories in the <item>. When i add additional <category> nodes, the xsl stops processing them. There was a lot of trial and error to get this far, but really struggling to get any further.
Code:
<xsl:param name="cat">all</xsl:param>
<xsl:key name="uniqueCategoryKey" match="item" use="./category"/>
<select name="cat">
<option value="all">all</option>
<xsl:for-each select="//item[generate-id() = generate-id(key('uniqueCategoryKey', ./category))]">
<xsl:choose>
<xsl:when test="$cat = category">
<option selected="{category}"><xsl:value-of select="category"/></option>
</xsl:when>
<xsl:otherwise>
<option value="{category}"><xsl:value-of select="category"/></option>
</xsl:otherwise>
</xsl:choose>
<br/>
</xsl:for-each>
</select>
is the correct code.
Code:
<xsl:key name="uniqueCategoryKey" match="item" use="./category"/> This makes problems?
Look at this http://www.webproworld.com/search-en...tml#post384523 example. Manufactures are child nodes of the mcatalog node.
Generally, why do you not use the XML query language XPath 2.0 / XQuery to select nodes?