Re: [xsl] Grouping with Xt

Subject: Re: [xsl] Grouping with Xt
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 14 Nov 2001 14:30:49 +0000
Hi Brian,

> Is this going to do what I *want* it to do?  8^)
>
> Specifically, pick all the Items that have the same PartNumber as
> the current node? (see inner comments)

Yes, I think so. Since when you're processing the Items they're in
PartNumber order, you could do it slightly more efficiently (I think)
with:

  <xsl:for-each select="xt:node-set($sorted)/Items
                          [preceding-sibling::Items[1]/@PartNumber !=
                           @PartNumber]">
    <!-- this is done once per unique value -->
    ...
    <xsl:for-each select="following-sibling::Items
                            [@PartNumber = current()/@PartNumber]">
      <!-- this is done for each Items element in the group -->
      ...
    </xsl:for-each>
    ...
  </xsl:for-each>

This should be more efficient because it only checks the
immediately-preceding sibling of each Items element to see if the
Items element starts (rather than ends) a new group. Plus it only
looks at the following siblings to find other Items with the same
PartNumber value, rather than *all* the Items elements in the sorted
list.

> I'm sure I'm not the only one forced to use Xt and required to do
> grouping. :-)

Out of interest, why are you being forced to use xt?

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


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


Current Thread