RE: [xsl] Simple Grouping

Subject: RE: [xsl] Simple Grouping
From: Edmund Mitchell <EMitchell@xxxxxxx>
Date: Fri, 16 Mar 2001 11:40:31 -0800
Hello
>From the FAQ at http://www.dpawson.co.uk/xsl/N4486.html#N24517


Steve Tinney offers 

<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:output method="xml" indent="yes"/>

<xsl:template match="/">
  <xsl:call-template name="triples">
    <xsl:with-param name="nodes" select="/*/f"/>
  </xsl:call-template>
</xsl:template>

<xsl:template name="triples">
  <xsl:param name="nodes"/>
  <tr><td><xsl:value-of select="$nodes[1]"/></td>
      <td><xsl:value-of select="$nodes[2]"/></td>
      <td><xsl:value-of 
              select="$nodes[3]"/></td></tr>
  <xsl:if test="count($nodes) > 3">
    <xsl:call-template name="triples">
      <xsl:with-param name="nodes" 
                      select="$nodes[position() > 3]"/>
    </xsl:call-template>
  </xsl:if>
</xsl:template>

</xsl:stylesheet>

A bit of modification to match your element names, and you'll be set.
Also, check www.jenitennison.com for some good grouping examples.

Hope that helps

Edmund

-----Original Message-----
From: ICARO [mailto:icaro@xxxxxxxxxxxxxx]
Sent: Friday, March 16, 2001 2:17 PM
To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] Simple Grouping


Hi all, I´m new in the xsl world and i have this problem:
I have an xml doc like that:
<list>
    <image>#</image>
    <image>#</image>
    <image>#</image>
    <image>#</image>
    ....
</list>
I need to create a table in which i want to group 3 images for each table
row, so the output looks like:
<table>
    <tr>
        <td>image</td>
        <td>image</td>
        <td>image</td>
    </tr>
    <tr>
        <td>image</td>
        <td>image</td>
        <td>image</td>
    </tr>
...
</table>

Thanks for your help!
ivan


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread
  • [xsl] Simple Grouping
    • ICARO - Fri, 16 Mar 2001 20:16:32 +0100
      • <Possible follow-ups>
      • Don Bruey - Fri, 16 Mar 2001 14:31:47 -0500
      • Edmund Mitchell - Fri, 16 Mar 2001 11:40:31 -0800 <=