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

FW: XSL variable out of scope

Subject: FW: XSL variable out of scope
From: "Martinez, Brian" <brian.martinez@xxxxxxxx>
Date: Thu, 23 Jan 2003 14:01:43 -0700
xsl variable out of scope
This is very odd--I was unable to reply to this at first because the filters
on our Exchange server rejected this due to the possibility I was
transmitting a list of telephone numbers.  No joke.  Anyway, I apologize for
the intentional misspellings in the following.  - b.

-----Original Message-----
From: Martinez, Brian 
Sent: Thursday, January 23, 2003 1:55 PM
To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
Subject: RE:  XSL variable out of scope


> From: Nischal Muthana [mailto:nischal_muthana@xxxxxxxxx]
> Sent: Thursday, January 23, 2003 1:04 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  XSL variable out of scope
> 
> But I get an error saying variable out of scope. And I
> know I am using a variable declared in a different
> scope. I am kinda stuck here and I dont have any more
> ideas to counter this. Can someone help me find a way
> to tackle this problem. 
> 
> < XML snipped >
>
> <xsl:for-each select="//PhxneList/Phxne">
> 	<xsl:variable name="PhUseCode"
> select="PhxneUseCode"/>
> 	<xsl:choose>
> 		<xsl:when test="$PhUseCode='HOME'">
> <xsl:variable name="HomePhxne" select="PhxneNumber"/>
> 	</xsl:when>
> 	<xsl:when test="$PhUseCode='BUS'">
> <xsl:variable name="BusPhxne" select="PhxneNumber"/>
> 	</xsl:when>
> </xsl:choose>
> </xsl:for-each>

Your xsl:variable declarations are within the xsl:for-each loop, so they go
out of scope and aren't available in the following block of code.  This is a
common error.

The structure of your stylesheet is suspect, I think.  If your intention is
to output a list of home and business phones for a group of people, then you
might try to wrap the entire block (including the table rows) in a for-each,
then your variables will be in scope for each iteration of PhxneList.  If
your XML always has just one HOME and one BUS phone, however, then the
following would be more efficient, without iteration:

<xsl:variable name="HomePhxne"
select="/PhxneList/Phxne[PhxneUseCode='HOME']/PhxneNumber"/>
<xsl:variable name="BusPhxne"
select="/PhxneList/Phxne[PhxneUseCode='BUS']/PhxneNumber"/>

Then use your table code as before.

hth,
b.

| brian martinez                              brian.martinez@xxxxxxxx |
| senior gui programmer                                  303.708.7248 |
| trip network, inc.                                 fax 303.790.9350 |
| 6436 s. racine cir.                             englewood, co 80111 |
| http://www.cheaptickets.com/                   http://www.trip.com/ |

 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.