Subject: Re: [xsl] A question on optimization From: David Carlisle <davidc@xxxxxxxxx> Date: Tue, 2 Nov 2004 15:08:01 GMT |
> You are most probably right. I'd possibly better quote my actual loop: <xsl:for-each select="//justus:choice"> <xsl:element name="TR"> <xsl:variable name="current" select="."/> <xsl:for-each select="//justus:part[@visible='true']"> oops two occurrences of // // means "please take ages traversing my entire document tree to its full depth looking for nodes of this form". You are doing that inside a loop so this is massively expensive. <xsl:for-each select="//justus:choice"> <xsl:element name="tr"> <xsl:element name="td"><xsl:value-of select="a1"/></xsl:element> <xsl:element name="td"><xsl:value-of select="a2"/></xsl:element> ... </xsl:element> even that is expensive if your justus:choice elements have any element content, you may know that there are no nested elements of that name and none inside yourjustus:part elements but the system doesn't. If they are all at the same level of the tree it's much better to say <xsl:for-each select="/a/b/c/justus:choice"> for whatever values of a b c you need. back to your original loop. you have <xsl:for-each select="//justus:part[@visible='true']"> which is a) expensive and (b) inside your justus:choice loop and (c) doesn't depend on the current node so will give the same result each time. so you could move this outside the loop: <xsl:variable name="x" select="/a/b/justus:part[@visible='true']"> and then use <xsl:for-each select="$x"> ... which might be quicker, or it might be just the same, if your xslt system noticed that that was a constant expression and so optimised it out of the outer loop automatically. I don't really have a picture of your input format in my head so probably this won't work out of the box, but you probably want to use a key (whicj basically tells the processor to make some kind of hash table which can dramitacally improve access times rather than seraching an entire document repeatedly) it seems like the things you need to get to fast are justus:part so <xsl:key name="j" match="justus:part" use="@visisble"/> then <xsl:for-each select="/a/b/justus:choice"> <xsl:variable name="current" select="."/> <tr> <xsl:variable name="current" select="."/> <xsl:for-each select="key('j','true')"> <xsl:variable name="dbfeld" select="."/> <td> <xsl:value-of select="$current/@*[name()=$dbfeld/@dbfeld]"> </td> </xsl:for-each> </tr> </xsl:for-each> ________________________________________________________________________ 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] A question on optimizatio, Jochen Wiedmann | Thread | Re: [xsl] A question on optimizatio, Geert Josten |
Re: [xsl] A question on optimizatio, Jochen Wiedmann | Date | [xsl] XSLT string substituion, Ann Marie Rubin |
Month |