[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Easy Key-grammar Question


Subject: Re: [xsl] Easy Key-grammar Question
From: "Bob Portnell" <simply.bobp@xxxxxxxxx>
Date: Tue, 26 Sep 2006 11:45:35 -0700

Aw, fiddle. You guys showed me how to collect items with variables, too.

Thank you, Michael. :-)

BobP

On 9/26/06, Michael Kay <mike@xxxxxxxxxxxx> wrote:
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: [xsl] 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


Current Thread