Skip to content

Instantly share code, notes, and snippets.

@lzcabrera
Created January 23, 2012 04:41
Show Gist options
  • Save lzcabrera/1660636 to your computer and use it in GitHub Desktop.
Save lzcabrera/1660636 to your computer and use it in GitHub Desktop.
Extracting Unique Values with XSL By Dave Pawson as found on http://www.bernzilla.com/item.php?id=333 (Bernie Zimmermann's Blog)
<Main>
<Level>
<Category id="a">
<SubCategory>one</SubCategory>
<SubCategory>two</SubCategory>
<SubCategory>three</SubCategory>
</Category>
<Category id="b">
<SubCategory>one</SubCategory>
<SubCategory>four</SubCategory>
</Category>
<Category id="c">
<SubCategory>two</SubCategory>
<SubCategory>five</SubCategory>
<SubCategory>six</SubCategory>
</Category>
<Category id="d">
<SubCategory>seven</SubCategory>
</Category>
</Level>
</Main>
<xsl:variable name="unique-listing" select="/Main/Level//SubCategory[not(.=following::SubCategory)]"/>
<ul>
<xsl:for-each select="$unique-listing">
<li><xsl:value-of select="." /></li>
</xsl:for-each>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment