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

Re: Variable scope

Subject: Re: Variable scope
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 17 May 2005 09:37:01 +0100
define variable scope
  I am trying to define a local variable in the template template1,
  calculate it in another template get-var [about 30 lines]
  and pass in to another template template2.

Use xsl:with-param to pass the value, and xsl:param to declare the
parameter in the template in which it is used.

  It seems that this variable somehow gets reset to 0 in template2
  and doesn't function correctly.

  Is that how it supposed to be (that it gets out of scope) ?


The scope of a variable binding is the element in which the binding
occurs, so in particular it is local to a template unless it is global.
Actually your sketch shows that you are setting the variables inside an
xsl:when so they are local to that xsl:when clause.

  Would you recommend me to make that variable global
  (but still calculate it in template get-var),

If it is a global variable then by definition its value will be bound
globally, you may not bind it locally (although you can have a local
variable with the same name, this will mask the global variable and you
will not be able to access the global variable in teh scope of teh local
variable)


Please read the guidelines for this list which are posted regularly.
You need to describe what you are doing and post a small example of
input and expected output. Just posting some non-working fragment of xsl
and asking how it may be changed doesn't give anyone any clues they can
work with.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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.