Grouping Using the Muenchian Method


/ Published in: XSLT
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <xsl:key name="contacts-by-surname" match="contact" use="surname" />
  2. <xsl:template match="records">
  3. <xsl:for-each select="contact[count(. | key('contacts-by-surname', surname)[1]) = 1]">
  4. <xsl:sort select="surname" />
  5. <xsl:value-of select="surname" />,<br />
  6. <xsl:for-each select="key('contacts-by-surname', surname)">
  7. <xsl:sort select="forename" />
  8. <xsl:value-of select="forename" /> (<xsl:value-of select="title" />)<br />
  9. </xsl:for-each>
  10. </xsl:for-each>
  11. </xsl:template>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.