Skip to content

Instantly share code, notes, and snippets.

@spdustin
Created July 7, 2015 20:00
Show Gist options
  • Save spdustin/f25cf2bed013a7c8c284 to your computer and use it in GitHub Desktop.
Save spdustin/f25cf2bed013a7c8c284 to your computer and use it in GitHub Desktop.
XSL Example - Group By "Group"
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:key name="group-by-group" match="Row" use="@Group"/>
<xsl:template match="/">
<xsl:apply-templates select="/dsQueryResponse/Rows/Row[count(. | key('group-by-group', @Group)[1]) = 1]" mode="header">
<xsl:sort select="@Group"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="Row" mode="header">
<h1><xsl:value-of select="@Group"/></h1>
<ul>
<xsl:apply-templates select="key('group-by-group',@Group)" mode="content">
<xsl:sort select="@Title"/>
</xsl:apply-templates>
</ul>
</xsl:template>
<xsl:template match="Row" mode="content">
<li><xsl:value-of select="@Title"/></li>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment