[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: sorting & styling
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|