RE: [xsl] resetting a variable

Subject: RE: [xsl] resetting a variable
From: "Martinez, Brian" <brian.martinez@xxxxxxxxxxx>
Date: Tue, 14 Oct 2003 11:03:03 -0600
> From: Aananth.S [mailto:aananth.solaiyappan@xxxxxxxxxx]
> Sent: Tuesday, October 14, 2003 10:05 AM
> Subject: [xsl] resetting a variable
> 
> Hi,
> 
>     Is there a way i can reset the value of a variable .. 
> suppose i have
> 
>        <xsl:variable name="hello" select="100"/>
>        <xsl:for-each select="//manyrows>
>              <!-- i need to set the variable to hello to the value of 
> manyrows/rowval -->
>         </xsl:for-each>
> How do i accomplish this?

VFAQ.  Once an XSLT variable is bound to a value, you can't change it.  By
moving the variable element inside your for-each loop:

<xsl:for-each select="//manyrows">
  <xsl:variable name="hello" select="manyrows/rowval"/>
  <!-- etc. -->
</xsl:for-each>

you can then have a new value for $hello in each iteration.  However, this
variable will only be in scope within the for-each loop and would cease to
exist once the loop has ended.

hth,
b.

| brian martinez                           brian.martinez@xxxxxxxxxxx |
| lead gui programmer                                    303.357.3548 |
| cheap tickets, part of trip network                fax 303.357.3380 |
| 6560 greenwood plaza blvd., suite 400           englewood, co 80111 |
| cendant travel distribution services   http://www.cheaptickets.com/ |

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread