|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Variable scope when using imported stylesheets
Note that what David says is even true of local variables, which are bound
within their context (and thus may be different every time a template is
matched), e.g.
<xsl:template match="list"> <xsl:variable name="linecount" select="count(child::line)"/> <xsl:text>
Line count: </xsl:text> <xsl:value-of select="$linecount"/> </xsl:template> $linecount will be different for every list, but for any given match of the template (that is, for any given list), it's always the same. The variables "vary" because the context varies. As David has had to point out many times, this is just like algebra: statement: x + y = 5 context: y = 4 So x=1. But if the context gave us y=3, x would be different. (It's always 5 - y but we need to know what y is to know x; or if the context gives us x, we know y.) In XSLT, global variables are assigned within the processing context given by the document. Local variables are assigned within the processing context of the template (which could be the body of a for-each instruction). Cheers, Wendell At 09:56 AM 8/24/2004, David wrote: It's not totally clear what your requirements are but I think that you are making the mistake (common for some reason) of thinking of variables as holding Xpath expressions, they don't; they hold _values_ (node sets in your case) so if you have a variable binding such as ___&&__&_&___&_&__&&&__&_&__&__&&____&&_&___&__&_&&_____&__&__&&_____&_&&_ "Thus I make my own use of the telegraph, without consulting the directors, like the sparrows, which I perceive use it extensively for a perch." -- Thoreau
|
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
|

Cart








