I am using <xsl:key> to identify unique values amongst a set of nodes. However, some of my nodes are nested, and my current implementation is not picking up those values.
Say I have the following XML structure:
<Concepts>
<Concept>
<Type>A</Type>
</Concept>
<Concept>
<Type>B</Type>
</Concept>
<Concept>
<OR>
<Type>C</Type>
</OR>
<OR>
<Type>D</Type>
</OR>
</Concept>
</Concepts>
I currently am using the following XSLT1.0 code:
<xsl:key name="types" match="Concepts/Concept" use="Type"/>
<xsl:template match="/">
<ul>
<xsl:for-each select="//Concept[generate-id() = generate-id(key('types',Type)[1])]">
<li><xsl:value-of select="Type"/></li>
</xsl:for-each>
</ul>
</xsl:template>
and the result is:
- A
- B
However, I would like the result to be:
- A
- B
- C
- D
Is there any easy solution, or will I have to restructure my XML?
No comments:
Post a Comment