RE: [xsl] Problem with keys in for-each (?)

Subject: RE: [xsl] Problem with keys in for-each (?)
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Wed, 14 Mar 2001 15:31:57 -0000
> mike> Mike Kay wrote:
>
> mike> The key() function looks for nodes that are in the same
> document as
> the
> mike> context node. Your xsl:for-each is changing the context
> node to be one
> in a
> mike> different document.
>
> Now I'm writing again:
>
> Could someone help me understand this?  I believe you Mike,
> obviously, but I
> thought that this
>
> <xsl:key name="itemKey" match="//*[local-name() = 'item']"
> 			use="ancestor-or-self::*[@type][1]/@type" />
>
> created a hash table (or something) in memory that was then
> referenced by
> name via the key() function - the idea that the context would
> somehow affect
> this is bizarre.  How is it that keys can speed up processing
> so much if
> they don't actually keep this information in memory?

It keeps one hash table for each key for each document. (Or at least, in
Saxon's case, for each document against which the key is actually used).


> Maybe I've been
> conceptualizing the idea of key being a hash table too literally.
>
> Also, given this variable:
>
> <xsl:variable name="taxonomy"
> select="document('AlteredTaxonomy.xml')" />
>
> When Mike says that the for-each on this variable changes the
> context to a
> *different document*, it means that the document I'm
> processing does not
> "include" any variables I have created during the processing of the
> stylesheet,
>

Variables belong to the stylesheet, not to any particular source document.

Mike Kay
Software AG


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


Current Thread