This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Alternate coloured Row Issue
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] Alternate coloured Row Issue
- From: "Tanzila Mohammad" <tmohammad at entier-solutions dot com>
- Date: Wed, 13 Jun 2001 11:37:18 +0100
- Reply-To: xsl-list at lists dot mulberrytech dot com
My xml is as follows:
<products>
<product>
<productID>1</productID>
<name>Motorcyle</name>
</product>
<product>
<productID>2</productID>
<name>Accessories</name>
</product>
..........
</products>
My xsl allows for the products to be displayed on alternate coloured lines:
<xsl:template match="product[position() mod 2 = 1]">
<tr class="odd">
<td>
<div align="center">
<a> <xsl:attribute name="href">product.jsp?productID=<xsl:value-of
select="productID"/>&secondhtml=<xsl:value-of select="$secondhtml"/>
</xsl:attribute>
<b> <font face="Verdana, Arial, Helvetica, sans-serif">
<xsl:value-of select="name"/>
</font> </b>
</a>
</div>
</td>
</tr>
</xsl:template>
<xsl:template match="product">
<tr class="even">
<td>
<div align="center">
<a> <xsl:attribute name="href">product.jsp?productID=<xsl:value-of
select="productID"/>&secondhtml=<xsl:value-of select="$secondhtml"/>
</xsl:attribute>
<b> <font face="Verdana, Arial, Helvetica, sans-serif">
<xsl:value-of select="name"/>
</font> </b>
</a>
</div>
</td>
</tr>
</xsl:template>
My problem relates to incorporating an independent last row, and making it
follow the same colour pattern:
<tr>
<td>
<div align="center">
<a>
<xsl:attribute name="href"><xsl:value-of
select="$email"/></xsl:attribute>
<b><font size="3" face="Verdana, Arial, Helvetica, sans-serif">Contact
Us</font></b>
</a>
</div>
</td>
</tr>
E.G
if odd=red and even=blue
if there were 4 products you would expect:
row 1 (red) Motorcyles
row 2 (blue) Accessories
row 3 (red) Clothing
row 4 (blue) Cars
row 5 (red) Contact Us <!-- here is the problem-->
if there were 3 products then you would expect:
row 1 (red) Motorcyles
row 2 (blue) Accessories
row 3 (red) Clothing
row 4 (blue) Contact Us <!-- here is the problem-->
Thanks.
Tanz
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list