Re: [xsl] grouping question

Subject: Re: [xsl] grouping question
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Fri, 13 Apr 2001 10:13:06 +0100
Hi Pat,

> Addendum to my earlier question. This xsl seems to be a good start
> but I am having problems with use of "following-sibling". I am
> operating under the assumption that I can get the database to tell
> me how many tracks are in each product. I am hoping that this will
> help me.

It looks as though the problem is in:

>     <xsl:template match="row">
>         <product>
>             <xsl:for-each select="current() | following-sibling::row[1]" >
>             <track>
>                 <xsl:copy-of select="."/>
>             </track>
>             </xsl:for-each>
>         </product>
>     </xsl:template>

Here, within the product element that you're creating, you're
iterating over a number of rows, making a track element for each.  But
from the looks of it, you're only getting the current row (the first
from that album) and its immediately following sibling (the second
from that album).  You want to get *all* the rows following the
current row that have the same album as the current row.  So try:

  <xsl:for-each select="current() |
                        following-sibling::row[album = current()/album]">
     <track><xsl:copy-of select="node()" /></track>

I put select="node()" rather than select="." in the above because I
think you probably want the result to look like:


rather than having a row element nested within the track element.

I hope that helps,


Jeni Tennison

 XSL-List info and archive:

Current Thread