Re: [xsl] Beware the count method with Muenchian grouping (was: Testing by counting or positional predicate)

Subject: Re: [xsl] Beware the count method with Muenchian grouping (was: Testing by counting or positional predicate)
From: Francis Norton <francis@xxxxxxxxxxx>
Date: Sun, 14 Jan 2001 22:38:07 +0000

Daniel Bowen wrote:
...
> 
> 
> So that's why you need the same filter as used in the "match" on the key to
> be there if you do it the count way:
> <xsl:variable
>   name="primary-textures"
>   select="//Texture
>         [0=count(preceding-sibling::Texture[1])]
>         [1=count(.|key('key-texture', concat(@texture, ':', @u, ':',
> @v))[1])]"
> />
> 
> Without the filter used in the "match" on the key, the count method will
> give you the nodes that are part of a key (the first one of each unique
> combination), plus all the other nodes matched by the XPath that aren't part
> of the key.
> 
Yes. Interesting. I didn't think through the implications of having a
predicate on the match attribute of your xsl:key. 

At the risk of stating the obvious, have you tried

<xsl:key
  name="all-texture"
  match="Texture"
  use="concat(@texture, ':', @u, ':', @v)" />
<xsl:variable
  name="primary-textures"
  select="//Texture[count(. | (key('all-texture', concat(@texture, ':',
@u, ':', @v))[1]) = 1]"
  />

- I'd really be interested in the result.

Francis.

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread