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

RE: Scope of variables

Subject: RE: Scope of variables
From: "Passin, Tom" <tpassin@xxxxxxxxxxxx>
Date: Thu, 8 May 2003 15:20:21 -0400
scope of variables
[ Karl J. Stubsjoen]

> 1)  If I define a variable at the top of a template rule and 
> then later try
> to update the value of this variable later down in the 
> template, I always
> get the error "Can't define variable twice...".  So how do 
> you reassign a
> value to a variable.

Karl, Google is your friend - the first hit with this search is a useful
page -

xslt faq variable scope

This first hit is 

> 
> 2) About scope:  Within a for-each loop I have a choose.  In 
> the choose I
> have a single test and an otherwise.  The result of the 
> choose is setting
> the value of a variable.  Just below this choose logic I am 
> referencing the
> value but am getting the error "A reference to variable or parameter
> 'currentVAL' cannot be resolved".  Where did I lose scopE on 
> this variable
> (currentVAL)?
> Here is a bit of the code from this template:
> 
> BEGIN SNIPPET...
> 
>  <xsl:for-each select="$xmTmplt/FLDS/FLD">
>  <xsl:variable name="innerFLD" select="@name" />
>     <!-- DETERMINE IF TEMPLATE DOC HAS A DEFAULT VALUE SET -->
>         <xsl:choose>
>      <xsl:when test="'a'='a'">
>       <xsl:variable name="currentVAL">TESTING</xsl:variable>
>         </xsl:when>
>         <xsl:otherwise>
>       <xsl:variable name="currentVAL" 
> select="$outerCurrent/@*[name() =
> $innerFLD]"/>
>         </xsl:otherwise>
>         </xsl:choose>
>     <xsl:if test="@viewable='true' or not(@viewable)">
>            <tr>
>             <td><!-- lookup text for display in xml template -->
>             <xsl:value-of select="@text"/></td>
>          <td>
>             <xsl:choose>
>                 <xsl:when
> test="$xmTmplt/FLDS/FLD[@name=$innerFLD]/@edit='true'">
>                 <!-- make edit fields -->
>              <xsl:call-template name="MAKE_INPUT_BOX">
>                 <xsl:with-param name="input_name"><xsl:value-of
> select="$innerFLD"/></xsl:with-param>
>                 <xsl:with-param name="input_value"><xsl:value-of
> select="$currentVAL"/></xsl:with-param>
> 
> .... END SNIPPET
> 
> Thanks for the help,
> Karl
> 
> 
>  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.