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

Re: variable binding

Subject: Re: variable binding
From: "Sam Byland" <shbyland@xxxxxxxxxxx>
Date: Wed, 5 Nov 2003 17:35:45 -0500
 Re: variable binding
>
> but when I try to run it, it tells me that the variable branch has not
> been declared, even though it should first have processed the first
> daughter of ng, where it has been declared.
>

This is because you've only defined branch within the priority="5" template,
so it will only be scoped there.  You also need to scope it within the
priority="4" template:

<xsl:template match="s//ng//*" priority="4">
  <xsl:variable name="branch">right</xsl:variable>
  <xsl:copy>
    <xsl:attribute name="branch"><xsl:value-of
select="$branch"/></xsl:attribute>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

Question:  is $branch always equal to "right"?  If so, you can define the
variable at the "top" i.e. as a direct child of the xsl:stylesheet element.
Then it will be scoped throughout...

...sam


 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.