This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: XSL sheet Optimisation



Robert Koberg writes:
>Would it be better (faster) to create keys for all the sections and access
>the particular section with its key:
>  <xsl:apply-templates select="key('mykey', $id)"/>
>or would it be better to do something like:
>  <xsl:apply-templates select="//*[@id=$id]"/>
[The "id" attributes are not genuine IDs.]

I think the former approach ought to be way better. Have one keyspace for
all the sections if you don't care about their depth. Notice that since
the processor has no way of knowing whether "id" values repeat, the select
of "//*[@id=$id]" always has to scan the entire tree. That expression
could be improved, but I don't think it can get better than the key()
approach.

However, bear in mind that keys really begin to pay off when a given key
is used more than once. After a node is found the first time and an
entry is made in some internal table representing the keyspace, then
subsequent selects can go straight to the node(s) with that key.
.................David Marston


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]