xsl-list
[Top] [All Lists]

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

2010-07-20 16:31:52
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


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>