[xsl] Grouping with Xt

Subject: [xsl] Grouping with Xt
From: Brian_Williams@xxxxxx
Date: Tue, 13 Nov 2001 18:48:30 -0800
Hi,

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)

     <!-- Create a variable that contains all the Items, sorted by
PartNumber -->
     <xsl:variable name="sorted">
          <xsl:for-each select="Items">
               <xsl:sort select="@PartNumber" order="ascending" />
               <xsl:copy-of select="."/>
          </xsl:for-each>
     </xsl:variable>

     <!-- Transform the variable into a node set using special xt extension
-->
     <xsl:for-each select="xt:node-set($sorted)/Items">
          <!-- Do I have the same part number as my following sibling? -->
          <xsl:if test="not(following-sibling::Items/@PartNumber
=@PartNumber)">
               <!-- Now @PartNumber should be a unique value -->
               <xsl:for-each select="//Items[@PartNumber=current
()/@PartNumber]">
                    <!-- Here I have all Items with the same part number
-->
               </xsl:for-each>
          </xsl:if>
     </xsl:for-each>

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

Thanks,
Brian



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


Current Thread