RE: performance issues
> If I have lots of templates all in one file like this, is it > likely to > cause any performance issues? Or are the templates only > loaded as and when they are needed? The templates are likely to be "loaded" in all cases (how does the system know when they are needed?) but that's not likely to cause any performance problems. The potential problem is that the system may have to search more template rules than necessary each time you do an apply-templates. Whether this is expensive depends (a) on the strategy used by your XSLT processor, and (b) on the form of the match patterns. I would expect that if the match patterns use an element name, and the element name doesn't appear in your source document, then for most XSLT processors the overhead would be minimal. But a pattern such as match="*[.//fred='5'] could slow things down a lot. > > Likewise, if I set up a variable which is effectively a pointer to an > external document via the document() function, like so: > > <xsl:variable name = "testDoc" > select="document('/www/xml/testDoc.xml')/root/> > > Does this cause the processor to load the contents of the > document into > memory, or will it not actually do that untill I make a > futher attempt to > try and acces some information from this document like so: > > <xsl:value-of select="$testDoc/item[@id = $id]/@name"/> > That's very processor-dependent. Many processors will use a lazy evaluation strategy, but you certainly can't rely on it. Saxon will eliminate a variable at compile time if there are no references to it(*), and if there are references then in most situations it will delay evaluating the variable until the first reference is encountered. Michael Kay http://www.saxonica.com/ (*) as people have discovered who try to call extension functions that have side-effects.
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