Subject: RE: rookie questions - Try 2
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Tue, 18 Apr 2000 09:43:56 +0100
|
> Currently each time it loops through the results a </TR> is
> inserted to end the row in a html table. How would I modify the style
sheet
> to insert that tag every other time it loops through?
First you need to understand that stylesheets don't write tags, they write
nodes to a tree. Creating a TR element node is one operation, you can't
split it into writing a start tag and an end tag.
You want to create a TR element node for every 2 items in the input, so the
simplest way to do it is along the lines:
<xsl:template match="item[position() mod 2 = 0]">
<tr>
<td><xsl:value-of select="."/></td>
<td><xsl:value-of select="following-sibling::item"/></td>
</tr>
</xsl:template>
<xsl:template match="item[position() mod 2 != 0]"/>
Mike Kay
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|