[xsl] Something similar to managing behavior with a variable

Subject: [xsl] Something similar to managing behavior with a variable
From: "Luke Shannon" <lshannon@xxxxxxxxxxxxxxx>
Date: Tue, 5 Apr 2005 13:57:27 -0400
Hello;

I'm creating a UI that writes rows of data. The background of the row needs
to changes every second row. I was doing it like this:

<tr align="left" valign="middle" class="grey1ColumnText">
<xsl:choose>
<xsl:when test='number($position) mod 2 != 0'>
<xsl:attribute name="class">grey1ColumnText</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class">grey2ColumnText</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</tr>

My problem now is now have a condition that determines when a row is to be
written. So, in a collection of 5 items maybe only 1 and 4 get written. I
still need a way to figure out how to alternate the background for the rows
that actually get written. Position no longer does the trick.

I thought I could keep the previous background in a variable like below:

<tr align="left" valign="middle" class="grey1ColumnText">
<xsl:choose>
<xsl:when test="$resultBK = 'grey1ColumnText'">
<xsl:attribute name="class">grey2ColumnText</xsl:attribute>
<xsl:variable name="resultBK" select="string('grey2ColumnText')"/>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class">grey1ColumnText</xsl:attribute>
<xsl:variable name="resultBK" select="string('grey1ColumnText')"/>
</xsl:otherwise>
</xsl:choose>
</tr>

But I have just found out you can't change the contents of a global variable
(resultBK) after it has been defined. How can I handle this?

Thanks,

Luke

Luke Shannon | Software Developer
FutureBrand Toronto

207 Queen's Quay, Suite 400
Toronto, ON, M5J 1A7
416 642 7935 (office)

Current Thread