xsl-list
[Top] [All Lists]

Re: [xsl] Trouble using xsl:key under XSL 1.0

2007-12-13 10:13:24
Scott Trenda wrote:
<xsl:key name="playerResultLookupByWeek" match="playerResult[../@week=$week]" use="@player" />


A big thing to watch out for here - the xsl:key match must be a pattern,
which is required to be context-free. (Same as the match pattern in
xsl:template.) And one of the big limitations to patterns is that you
cannot have variable references inside them. Even if the variable is
top-level, and even if it's something simple like
document('')/*/someElement, it can't be used in the match pattern.

Learn to start thinking around variables in your keys, and you'll end up
banging your head against the wall less often. :)

Unless you start out with XSLT 2.0 of course, which does allow (global) variables in patterns. So leave that wall near by in case you want to switch to 2.0 anytime soon ;)

Cheers,
-- Abel Braaksma

--~------------------------------------------------------------------
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>
--~--