for-each: Sorting and Grouping

Subject: for-each: Sorting and Grouping
From: "Hyatt, Steve (IndSys, GEFanuc, TCP)" <steve.hyatt@xxxxxxxxxxxxxxxxxx>
Date: Mon, 4 Oct 1999 13:40:43 -0600
Hiya.

I have an XML file containing a list of interface names (from IDL) with each
having a user-defined class associated with them, which are basic strings.

I have built an XSL file which displays them in a single table, and are
sorted by the "sort-by" attribute in a 'for-each' tag.

The question is, how can I display this list in different tables, groupped
by this class.  What I want to do is something like:

<xsl:for-each select="Interface" order-by="+ Class"> 

<!-- If this is the first time we have seen this class, then output
     a new table which includes a class name.
-->

<!-- Output the current name -->
<tr>
	<td><xsl:value-of select="Name"/></td>
</tr>

<!-- If this is the last interface with this class in the list, end this
     table. -->

</xsl:for-each>


Is this something that can be done?  I was thinking if not, I could add the
class as an attribute to the <Interface> tag, instead of as a sub-tag, and
then doing some sort of conditional selection.  But how do you do this since
you don't know which classes there will be?

Do I need to do this in JavaScript instead?

Any help would be greatly appreciated.

Steve


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


Current Thread