You should use the section in the key as that is what you want to group
on. Then the for-each selecting element in the document context (/)
will not select anything. Last, you need either to remove the mode on
the template or have some other template that applies templates with
the show mode on the document node. A working stylesheet is below:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:key name="section-group" match="element" use="section"/>
<xsl:template match="/">
<xsl:for-each select="//element[generate-id() =
generate-id(key('section-group',section) [1])]">
<h1>
<xsl:value-of select="section"/>
</h1>
<xsl:for-each select="key('section-group',section)">
<xsl:value-of select="name"/>
<br/>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com