Re: [xsl] Grouping

Subject: Re: [xsl] Grouping
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 14 Feb 2001 11:51:04 +0000
Hi Chris,

> Many of the <item>s in my file have multiple <subject_ref> tags. I'm
> trying (with no success) to find a way to group them by
> subject_ref/@reference, but with no luck. I've gone through the
> archives, and found reference to a solution by Steve Muench
> involving the use of keys. I've (very unsuccessfully) tried to make
> the following work:
>          <xsl:key name="group" match="subject_ref" use="@reference"/>
>          [...]
>          <xsl:for-each 
> select="//subject_ref[generate-id(.)=generate-id(key('group', 
>          [...]
> Do I have a problem because of the fact that I have more than one 
> <subject_ref > child for many of the <subjects> nodes in my xml?

The select expression that you're using:

   //subject_ref[generate-id() =
                 generate-id(key('group', @reference)[1])

looks fine for getting all the unique subject_refs in the document, so
the problem that you're experiencing is probably to do with some of
the code that you haven't included, in particular the content of the
xsl:for-each.  Remember that you're selecting subject_ref elements,
and you need to go up the tree to get from there to information about
the item itself.

If you show us more of your XSLT we might be more able to help.



Jeni Tennison

 XSL-List info and archive:

Current Thread