This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: rookie questions - Try 2
- To: "'xsl-list at mulberrytech dot com'" <xsl-list at mulberrytech dot com>
- Subject: RE: rookie questions - Try 2
- From: Kay Michael <Michael dot Kay at icl dot com>
- Date: Tue, 18 Apr 2000 09:43:56 +0100
- Reply-To: xsl-list at mulberrytech dot com
> 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