|
 |
xslt thread: HTML table rows: XSLT to start a new row for each 5th item
Message #1 by "James Birchler" <jamesbirchler@y...> on Sat, 26 May 2001 01:03:20
|
|
You're still thinking sequentially!
The way to do this is:
<xsl:for-each select="item[position() mod 5 = 1]">
<tr>
<xsl:for-each select=".|following-sibling::item[position() < 5]">
<td>....</td>
</xsl:for-each>
</tr>
</xsl:for-each>
Mike Kay
> -----Original Message-----
> From: James Birchler [mailto:jamesbirchler@y...]
> Sent: 26 May 2001 01:03
> To: P2P_XSLT
> Subject: [xslt] HTML table rows: XSLT to start a new row for each 5th
> item
>
>
> I've got an XML file with data like this:
>
> <data>
> <item>1</item>
> <item>2</item>
> ...
> <item>15</item>
> </data>
>
> I'd like to output the item number in a 5 column table, and am having
> trouble. Here is what I tried (but it doesn't create the
> correct output).
> Suggestions? Perhaps there is a better way of doing this!
>
> Thanks,
>
> James
> ------------------------------------------------
>
> <xsl:stylesheet version="1.1"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:fo="http://http://www.w3.org/1999/XSL/Format">
>
>
> <xsl:output method="html"
> indent="yes"
> doctype-public="-//W3C//DTD HTML 3.2 Final//EN"/>
>
>
> <xsl:template match="/">
>
> <xsl:variable name="line-nr">
> <xsl:number level="any" from="data" />
> </xsl:variable>
>
> <HTML>
> <TABLE width="600" border="0" align="center">
>
> <xsl:for-each select="/data/item">
> <tr>
> <td>
> <xsl:value-of select="/data/item" />
> </td>
> <xsl:if test="$line-nr mod 5 = 0">
> </tr>
> </xsl:if>
> </table>
> </html>
> </xsl:template>
>
>
|
|
 |