Previous | Next | Indexes
adultinternetusers > Tutorials > XSLT 2.0 Tutorial > Groups (5/10) >

Grouping in sequences with group-by

The xsl:for-each-group with group-byCan be used on any sequence not only on collections of nodes.

XSLT

      <xsl:stylesheet
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  version="2.0">
            <xsl:output  method="xml"
                        indent="yes"
                        omit-xml-declaration="yes"/>

            <xsl:template  match="/aaa">
                  <xsl:for-each-group  select="1 to 10"
                              group-by=". mod 3">
                        <value>
                              <xsl:value-of  select="."/>
                        </value>
                        <group-members>
                              <xsl:for-each  select="current-group()">
                                    <value>
                                          <xsl:value-of  select="."/>
                                    </value>
                              </xsl:for-each>
                        </group-members>
                  </xsl:for-each-group>
            </xsl:template>

      </xsl:stylesheet>
XML

      <aaa/>
Output

      <value>1</value>
      <group-members>
            <value>1</value>
            <value>4</value>
            <value>7</value>
            <value>10</value>
      </group-members>
      <value>2</value>
      <group-members>
            <value>2</value>
            <value>5</value>
            <value>8</value>
      </group-members>
      <value>3</value>
      <group-members>
            <value>3</value>
            <value>6</value>
            <value>9</value>
      </group-members>


Previous chapter: Elements and attributes
Next chapter: Multiple source documents
Previous page: Grouping with group-ending-with
Next page: Grouping in sequences with group-adjacent

Kevin Carr in Stanton

Natural Skin Care and European Soaps
TickTalk 5
city of stanton
internetusers


You can also get Organic Skin Care products from Bliss Bath Body and you must check out their Natural Body Lotions and bath soaps

Now if you are looking for the best deals on surf clothing from Quiksilver and Roxy then you have to check these amazing deals here:

Hey, check out this Organic Skin Care European Soaps along with Natural Lavender Body Lotion and shea butter

and we can get surf t shirts surfing shirt and And you must check out this website swim suit swimming suit and swim trunks