Skip to content

Instantly share code, notes, and snippets.

@andrewminton
Created March 21, 2012 14:16
Show Gist options
  • Save andrewminton/2147219 to your computer and use it in GitHub Desktop.
Save andrewminton/2147219 to your computer and use it in GitHub Desktop.
<data>
<the-pip>
<entry>
<published-by>
<item id="191" handle="tim-powell" section-handle="team-members" section-name="Team Members">Tim Powell</item>
</published-by>
</entry>
<entry>
<published-by>
<item id="192" handle="andy-minton" section-handle="team-members" section-name="Team Members">Andy Minton</item>
</published-by>
</entry>
<entry>
<published-by>
<item id="191" handle="tim-powell" section-handle="team-members" section-name="Team Members">Tim Powell</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="staff-by-surname" match="published-by" use="item" />
<xsl:template match="data">
<hi>The Pip</hi>
<xsl:apply-templates select="the-pip/entry"/>
</xsl:template>
<xsl:template match="the-pip/entry">
<xsl:apply-templates
select="published-by[count(. | key('staff-by-surname', item)[1]) = 1]"/>
</xsl:template>
<xsl:template match="published-by/item">
<p><xsl:value-of select="key('staff-by-surname', item)"/></p>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment