[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: A question on optimization

Subject: RE: A question on optimization
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 3 Nov 2004 11:10:34 -0000
kay josten
Optimization and performance depend on the processor.

As it happens, with Saxon, if you use "//x" inside a loop then Saxon will
remember the value and avoid re-evaluating it each time, while if you use
/*/x, it won't.

The moral is, don't guess - measure!

Putting the value in a variable that's set outside the loop, whatever the
expression used, is almost certainly not going to make performance any
worse.

I don't think there's likely to be any significant difference between using
a single-valued key, as shown here, and using a global variable. Using a
global variable seems much more intuitive.

But here I'm guessing.

Michael Kay
http://www.saxonica.com/
 

> -----Original Message-----
> From: Geert Josten [mailto:Geert.Josten@xxxxxxxxxxx] 
> Sent: 03 November 2004 08:57
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  A question on optimization
> 
> Hi Jochen,
> 
> >   <xsl:for-each select="//justus:choice">
> >     <xsl:element name="TR">
> >       <xsl:variable name="current" select="."/>
> >       <xsl:for-each select="//justus:part[@visible='true']">
> >         <xsl:variable name="dbfeld" select="."/>
> >         <xsl:element name="td">
> >           <xsl:for-each
> >              select="$current/@*[name()=$dbfeld/@dbfeld]">
> >             <xsl:value-of select="."/>
> >           </xsl:for-each>
> >         </xsl:element>
> >       </xsl:for-each>
> >     </xsl:element>
> >   </xsl:for-each>
> 
> ...
> 
> >    <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>
> >    </xsl:for-each>
> 
> David is right. Using // is rather expensive in terms of 
> performance. Use full paths as David 
> suggests, or try using keys if the choice and part elements 
> may occur in unpredictable locations:
> 
> <xsl:key name="choices" match="justus:choice" use="'all'" />
> <xsl:key name="parts" match="justus:part" use="'all'" />
> 
> <xsl:for-each select="key('choices', 'all')">
> 
> and
> 
> <xsl:for-each select="key('parts', 'all')[@visible='true']">
> 
> Grtz,
> Geert

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.