Subject: RE: Easy Key-grammar Question
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 26 Sep 2006 19:31:53 +0100
|
If you need to find the items with @group != 0 frequently, use a global
variable:
<xsl:variable name="nonzeroitems" select="//item[@group != 0]"/>
If you don't need them frequently, then you don't need a key.
If "0" is actually a variable, then a key isn't going to help.
Michael Kay
http://www.saxonica.com/
> -----Original Message-----
> From: Bob Portnell [mailto:simply.bobp@xxxxxxxxx]
> Sent: 26 September 2006 19:08
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Easy Key-grammar Question
>
> (And yet I don't see it clearly in the FAQ)
>
> So, I've been handed
>
> <xsl:for-each select="//item[@group != 0]">
>
> The structure cries out for a key, and conveniently I already
> have established <xsl:key name="ItemByGrp" match="item"
> use="@group" />
>
> Now, if I wanted the <item>s with @group='0', I'd use the
> function key('ItemByGrp', 0). No fuss.
>
> How do I opposite? *Can* I do the opposite, or am I better
> off leaving it alone? Should I create a more refined key
> definition thus?
>
> <xsl:key name="GroupedItems" match="item[@group !=0]" use="@group" />
>
> Curiosity abounds!
>
> Bob Portnell
> simply.bobp@xxxxxxxxx
|