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

Re: how to increment a variable in a for-each loop

Subject: Re: how to increment a variable in a for-each loop
From: "Joerg Heinicke" <joerg.heinicke@xxxxxx>
Date: Thu, 24 Jan 2002 00:33:37 +0100
xsl increment for loop
<xsl:for-each select="."> contains always only the current element, so the
position is always 1 -> red background. Remove the for-each and it will
work. A shortened version of your template:

<xsl:template match="*" mode="diff_cols">
    <fo:table-cell  background-color="red">
        <xsl:if test="position() mod 2 = 0">
            <xsl:attribute name="background-color">blue</xsl:attribute>
        </xsl:if>
        <fo:block><xsl:value-of select="."/></fo:block>
    </fo:table-cell>
</xsl:template>

Regards,

Joerg

----- Original Message -----
From: "yan bai" <bytj@xxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Thursday, January 24, 2002 12:14 AM
Subject: Re:  how to increment a variable in a for-each loop


> I have a code snippet as below:
> <xsl:template match="*" mode="diff_cols">
> <xsl:for-each select=".">
>     <xsl:if test="position() mod 2 = 1">
> <fo:table-cell  background-color="red">
> <fo:block><xsl:value-of select="."/></fo:block>
> </fo:table-cell>
>     </xsl:if>
>     <xsl:if test="position() mod 2 = 0">
> <fo:table-cell  background-color="blue">
>         <fo:block><xsl:value-of
> select="."/></fo:block>
> </fo:table-cell>
>     </xsl:if>
>     </xsl:for-each>
> </xsl:template>
>
> Unfortunately, it did not work.  The background color
> in all columns is red.
>
> Can you help to debug?
>
> Yan


 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.