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: Problem with keys in for-each (?)



I wrote:


me> In the following XSLT, I have a key() function called to look
me> up a specific
me> element in the key.  If I call this alone, as it is in the
me> first line of the
me> template for "/", it works and I get the output I expect.  If
me> I do the EXACT
me> same thing within the loop, I get no output as a result of the
me> apply-templates.

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?  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, those are "different documents" - or is it just variables that
are created using document()?  

Does anyone want to give me (us) a processor implementation lesson?  Thanks
for clearing this up - I was really surprised to see the answer to this
question, and of course grateful that someone knew it. 

Don


 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]