Re: [xsl] A problem using the xsl:key facility

Subject: Re: [xsl] A problem using the xsl:key facility
From: Lars Huttar <lars_huttar@xxxxxxx>
Date: Tue, 20 Jul 2010 16:31:36 -0500
On 7/20/2010 3:30 PM, Michael Kay wrote:
> On 20/07/2010 21:17, Nathan Potter wrote:
>
> The key() function, when called with two arguments, always searches
> within the current document (more accurately, the document containing
> the context node). Your xsl:for-each changes the current document, so
> you are searching the wrong thing. In XSLT 2.0 you can use the third
> argument of the key() function to indicate which document you want to
> search.

Maybe this should go on the list of common XSLT mistakes.
http://saxonica.blogharbor.com/blog/_archives/2010/6/11/4550606.html

Even if it's not as common as others, this mistake is one that is hard
to debug because there's a context dependency in the key() that one
often doesn't think about (affected by a context change in the for-each
that one often doesn't think about).

Usually they "just work" fine, but when they don't, it's mysterious,
even baffling.

Lars

Current Thread