[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: 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 ________________________________________________________________________
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|