Skip to content

Instantly share code, notes, and snippets.

@andrewminton
Created March 21, 2012 15:15
Show Gist options
  • Save andrewminton/2148260 to your computer and use it in GitHub Desktop.
Save andrewminton/2148260 to your computer and use it in GitHub Desktop.
<data>
<the-pip>
<entry>
<published-by id="0001">
<item>Smith</item>
</published-by>
</entry>
<entry>
<published-by id="0002">
<item>Jones</item>
</published-by>
</entry>
<entry>
<published-by id="0003">
<item>Jones</item>
</published-by>
</entry>
</the-pip>
</data>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" />
<xsl:key name="contacts-by-surname" match="published-by" use="item" />
<xsl:template match="/">
<ul>
<xsl:apply-templates select="data/the-pip/entry"/>
</ul>
</xsl:template>
<xsl:template match="data/the-pip/entry">
<xsl:for-each select="published-by[count(. | key('contacts-by-surname', item)[1]) = 1]">
<xsl:sort select="item" />
<li><xsl:value-of select="item" /></li>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment