[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: variable change in xsl:for-each

Subject: RE: variable change in xsl:for-each
From: "Jason Macki" <jmacki@xxxxxxx>
Date: Mon, 22 Jul 2002 11:27:01 -0500
xsl variable change
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.