[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] Looping in XSLT(old question, but maybe new problem)
Subject: RE: [xsl] Looping in XSLT(old question, but maybe new problem) From: "Liu Shuai" <shuai@xxxxxxxxxxxxxxxxx> Date: Tue, 24 Jun 2003 22:35:16 -0400 |
Jeff, Sorry I didn't ask my question clearly. But I think you answered my question. If I understood it correctly, a globally scoped variable will be initialized only once. In this case, where foo-bar-temp returns a node-set, the node-set will be built once and only once. Is that correct? I asked the question because I thought there might be a performance issue if a variable like foo-bar-temp, which may potentially return a huge object, is initialized every time it is used. I thought it would make more sense a global variable is initialized only once since the value won't change anyway. Regards, LS -----Original Message----- From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Jeff Beadle Sent: Tuesday, June 24, 2003 8:49 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: [xsl] Looping in XSLT(old question, but maybe new problem) Hey Liu, You last responded with: >>... if foo-bar-temp is a global variable, is the nodeset initialized >>only once or is it generated every time foo-bar-temp is called? I'm not quite sure I understand your question, but I'll give it a whirl... Globally scoped variable elements are intialized only once, when the transform begins ... or, in essence when the stylesheet is "compiled" and intially loaded with the source xml document. I don't know off-hand what all the exact sequence rules are for processing child elements of the stylesheet element, but I'm sure you could find that at the w3c. However, my example solution doesn't have the foo-bar-xxx (et.al) variables defined at global scope, they were defined within the local scope of the root matching template. You could move them to that level of visibility ... here are some things to consider before doing that: 1. Other templates could use the node lists ... which can be a great thing, sharing objects/state can be nice. 2. They are defined only once, upon beginning the transform ... which can be a nice optimization--if consideration #1 is a factor--but, if you need to re-define them upon entering a given template, your out of luck. 3. I would only do this if there are only a few templates within the stylesheet, otherwise what if--for a given transform--depending on your use case, your xslt execution path/thread may never accesses/uses those variables? ... then you've spent needless overhead in "compiling" the stylesheet due to having to construct those globally visible variables. Also, please keep in mind this was only an example--one example--of how to accomplish your solution. Thanks, Jeff XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Looping in XSLT(old quest, Jeff Beadle | Thread | [xsl] Problems with XSLT and Memory, David Bonilla Fuerte |
RE: [xsl] Looping in XSLT(old quest, Jeff Beadle | Date | RE: [xsl] Different Colors for Alte, Schwartz, Rechell R, |
Month |