Subject: RE: variable change in xsl:for-each
From: "Jason Macki" <jmacki@xxxxxxx>
Date: Mon, 22 Jul 2002 11:27:01 -0500
|
Hi Markus,
You can't update the content of a variable with XSLT.
In order to alternate the colour of your cell, use the position() and
mod() functions to determine if the current position is odd or even.
For example, this XML:
<rows>
<item>one</item>
<item>two</item>
<item>three</item>
</rows>
...used against this XSLT:
<xsl:for-each select="rows/item">
<xsl:choose>
<xsl:when test="(position() mod 2) = 0">Even</xsl:when>
<xsl:otherwise>Odd</xsl:otherwise>
</xsl:choose>
<br />
</xsl:for-each>
..will produce the following result:
Odd
Even
Odd
If you haven't heard of mod() before, a mod b returns the number of
times b can be subtracted from a without returning a negative result.
- Jason
-----Original Message-----
From: inchi2000@xxxxxx [mailto:inchi2000@xxxxxx]
Sent: Monday, July 22, 2002 11:06 AM
To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
Subject: variable change in xsl:for-each
Hello,
I want the background to change in each cell. But in every cell I only
get the #FFFFFF-background. I think the variable isn't updated in the
choose-procedure. But I don't know why. Hope you can help.
Thanks!
Markus
Sorry!!! I forget the subject in last mail. So I posted again
heres my xsl-file:
<xsl:variable name="xrowcolor" select="false()"/>
<xsl:variable name="rowcolor">#FFFFFF</xsl:variable>
<xsl:for-each select="//meldungen">
<xsl:choose>
<xsl:when test="$xrowcolor">
<xsl:variable name="rowcolor">#FFFFFF</xsl:variable>
<xsl:variable name="xrowcolor" select="false()"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="rowcolor">#FFFF11</xsl:variable>
<xsl:variable name="xrowcolor" select="true()"/>
</xsl:otherwise>
</xsl:choose>
<fo:table-cell>
<fo:block background-color="{$rowcolor}" font-weight="bold">
<xsl:value-of select="eingang"/>
</fo:block>
</fo:table-cell>
</fo:for-each>
--
GMX - Die Kommunikationsplattform im Internet. http://www.gmx.net
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|