Ukázka seskupování

Příklad 10. citaty-seskupeni.xsl

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
  <xsl:output method="html" encoding="utf-8"/>

  <xsl:template match="citaty">
    <html>
      <head>
        <title>Citáty podle autorů</title>
      </head>
      <body>
        <xsl:for-each-group select="citat" group-by="autor">
          <xsl:sort select="current-grouping-key()" lang="cs"/>
          <h1><xsl:value-of select="current-grouping-key()"/></h1>
          <xsl:for-each select="current-group()">
            <xsl:sort select="text" lang="cs"/>
            <p>
              <xsl:value-of select="text"/>
            </p>
          </xsl:for-each>
        </xsl:for-each-group>
      </body>
    </html>
  </xsl:template>

</xsl:stylesheet>