xml – How to use for each group in XSL

xml – How to use for each group in XSL

If you group by country you would start with e.g.

<xsl:template match=Person>
  <xsl:for-each-group select=Student/Info [email protected]>
    <country name={current-grouping-key()}>

    </country>
  </xsl:for-each-group>
</xsl:template>

Then you have to decide whether you want to further group the Info elements in each country group, for instance by name:

<xsl:template match=Person>
  <xsl:for-each-group select=Student/Info [email protected]>
    <country name={current-grouping-key()}>
      <xsl:for-each-group select=current-group() [email protected]>
        <student name={current-grouping-key()}>
          <classes>
            <xsl:for-each select=current-group()>
              <class><xsl:value-of [email protected]/></class>
            </xsl:for-each>
          </classes>
        </student>
      </xsl:for-each-group>
    </country>
  </xsl:for-each-group>
</xsl:template>

xml – How to use for each group in XSL

Leave a Reply

Your email address will not be published.