RE: [xsl] Grouping question

Subject: RE: [xsl] Grouping question
From: bryan.s.schnabel@xxxxxxxxxxxxxx
Date: Tue, 21 May 2002 10:31:41 -0700
While we wait for Jeni to give us the well-thought-out XSLT 1.0 Meunchian
method, here's some fun to consider with XSLT 2.0.

Assuming your input is well formed (not </color>):
  <n color="R">1</n>
  <n color="R">2</n>
  <n color="R">3</n>
  <n color="Y">4</n>
  <n color="Y">5</n>
  <n color="Y">6</n>
  <n color="W">7</n>
  <n color="W">8</n>
  <n color="W">9</n>

Something like this would work:

<xsl:template match="data">
  <xsl:for-each-group select="n" group-by="@color">
    <xsl:sort select="." />
      <xsl:for-each select="current-group()">
       <xsl:if test="position() mod 2">
        <xsl:variable name="color" select="@color" />
          <xsl:value-of select="." />
         <xsl:if test="following-sibling::n[@color=$color]">
           <xsl:value-of select="following-sibling::n[@color=$color]" />


-----Original Message-----
From: Spectron International, Inc. [mailto:spectron@xxxxxxxxx]
Sent: Tuesday, May 21, 2002 7:05 AM
To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] Grouping question

I have the following XML:

  <n color="R">1</color>
  <n color="R">2</color>
  <n color="R">3</color>
  <n color="Y">4</color>
  <n color="Y">5</color>
  <n color="Y">6</color>
  <n color="W">7</color>
  <n color="W">8</color>
  <n color="W">9</color>

and I want to create 3 tables (one for each color) with 2 columns each:



I have checked the grouping section in but
none of the samples do what I need. How can I do that?


 XSL-List info and archive:

 XSL-List info and archive:

Current Thread