RE: [xsl] XPath perfomance in attributes or nodes?

Subject: RE: [xsl] XPath perfomance in attributes or nodes?
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Sat, 9 Mar 2002 09:19:51 -0000
Saxon builds the index on the first use of key() with a given keyname in a
given document. I think this is really the only feasible strategy, otherwise
you would have to build an index for every key on every document.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Jonathan
> Perret
> Sent: 07 March 2002 09:45
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re: [xsl] XPath perfomance in attributes or nodes?
>
>
> I would like to ask the XSLT implementors on this list whether their
> processors build keys lazily (i.e. on the first use of the
> key() function),
> or does <xsl:key> have a cost even when the key is not used later ?
> When is the cost of building the index offset by the
> performance gain ?
>
> For example, suppose the input is 10000 elements like so :
>
> <doc>
> <elt att="1">
> </elt>
> <elt att="2">
> </elt>
> <elt att="3">
> </elt>
> ...
> </doc>
>
> and there is an external parameter that gives the stylesheet
> an attribute value to look for. Which would be faster :
>
> <xsl:key name="idx" match="elt" use="@att" />
> <xsl:param name="param" />
>
> <xsl:template ...>
>     ...
>     <xsl:apply-templates select="key('idx',$param)" />
>     ...
> </xsl:template>
>
> Or :
>
> <xsl:param name="param" />
>
> <xsl:template ...>
>     ...
>     <xsl:apply-templates select="/doc/elt[@att=$param]" />
>     ...
> </xsl:template>
>
> Assuming the <xsl:apply-templates> above is executed
> only once, it seems to me that the key-less version
> should perform a bit faster. But as I have never implemented
> an XSLT processor I would like to have the opinion of
> masters of the subject.
>
> Cheers,
> --Jonathan
>
> ----- Original Message -----
> From: "Peter Davis" <pdavis152@xxxxxxxxx>
> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> Sent: Thursday, March 07, 2002 3:52 AM
> Subject: Re: [xsl] XPath perfomance in attributes or nodes?
>
>
> > <xsl:key name="project-uid" match="project" use="@uid"/>
> > <!-- or use="uid" -->
> > <xsl:template ...>
> >   <xsl:apply-templates select="key('project-uid',
> >      '{6A97F258-93A7-4C5E-B712-052130A5208C}')[1]"/>
> >   <!-- [1] is probably not necessary -->
> > </xsl:template>
> >
> > will be much faster than either approach.
> >
>
>
>
>  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