Subject: Re: [xsl] Variable scope From: David Carlisle <davidc@xxxxxxxxx> Date: Tue, 17 May 2005 09:37:01 +0100 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Variable scope, Aron Bock | Thread | [xsl] compare two unicode variables, hochen |
[xsl] time difference help, Kent Seegmiller | Date | Re: [xsl] word (not string) wrap, Dimitre Novatchev |
Month |