Subject: Re: sorting & styling From: Miloslav Nic <nicmila@xxxxxxxx> Date: Wed, 15 Sep 1999 15:55:59 +0200 |
This approach fails if you need sorting as was requested in this case. Kay Michael wrote: > > > > > Sort, once, a list of elements and generate a table with the > > sorted list, with the number of elements per row given in the stylesheet: > > > This falls into the general category of "grouping problems", they can be > done in XSLT but it isn't easy. > > You need something like > > <xsl:template name="do-the-rest"> > <xsl:param name="start"/> > <xsl:param name="count"/> > <tr> > <xsl:for-each select="item[position()>=$start and > position()<$start+$count"> > <td> > <xsl:value-of select="."/> > </td> > </xsl:for-each> > </tr> > <xsl:if test="$start + $count - 1 < last()"> > <xsl:call-template name="do-the-rest"> > <xsl:with-param name="start" select="$start + $count"/> > <xsl:with-param name="count" select="$count"/> > </xsl:call-template> > </xsl:if> > </xsl:template> > > <xsl:template match="data"> > <xsl:call-template name="do-the-rest"> > <xsl:with-param name="start" select="1"/> > <xsl:with-param name="count" select="2"/> > </xsl:call-template> > </xsl:template> > > Mike Kay > > > > > For example: > > > > <data> > > <item>b</item> > > <item>a</item> > > <item>d</item> > > <item>c</item> > > </data> > > > > gives, with 2 elements per row: > > > > <table> > > <tr> <td>a</td> <td>b</td> </tr> > > <tr> <td>c</td> <td>d</td> </tr> > > </table> > > > > > > Olivier > > > > > > --- > > Olivier Corby, Acacia project, INRIA Sophia Antipolis > > email : Olivier.Corby@xxxxxxxxxxxxxxx tel : +33 4 92 38 78 71 > > > > > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list -- *************************************************************** Dr. Miloslav Nic e-mail: nicmila@xxxxxxxx Department of Organic Chemistry TEL: +420 2 2435 5012 ICT Prague (VSCHT Praha) +420 2 2435 4118 FAX: +420 2 2435 4288 **************************************************************** XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: sorting & styling, Kay Michael | Thread | ANN: XML-Fin postituslista, Jarno Elovirta |
Re: What will be the future improve, David Carlisle | Date | Re: What will be the future improve, Miloslav Nic |
Month |