[xsl] XSL Sorting Question - Meunchian Method

Subject: [xsl] XSL Sorting Question - Meunchian Method
From: "Magick, Brian" <Brian.Magick@xxxxxxxxxx>
Date: Wed, 7 Nov 2001 15:15:30 -0600
I've been reading Jenni Tennisons's web site and looking at the grouping
examples to help solve a problem.  One example uses the following XML
and XSL to output something similar to this:

Customer 1 
* Project 1 
* Project 2 
Customer 2 
* Project 1 

Based on this XSL:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
      <xsl:output method="xml" version="1.0" encoding="UTF-8"
      <xsl:key name="rows" match="PROROW" use="name"/>
      <xsl:template match="PROJECTS">
            <xsl:apply-templates select="PROROW[generate-id(.) =
generate-id(key('rows', name)[1])]"/>
      <xsl:template match="PROROW">
                  <xsl:value-of select="name"/>
    <xsl:for-each select="key('rows', name)/project_name">
        <a href="projects_results.xml?project={../id}">
          <xsl:value-of select="." />

and this XML: (which differs slightly from the XML on her web page)

<?xml version="1.0" encoding="UTF-8"?>
            <name>Customer 1</name>
            <project_name>Project 1</project_name>
            <project_name>Project 2</project_name>
            <name>Customer 2</name>
            <project_name>Project 1</project_name>
I would like to mix this up a bit and sort by project_name outputting a
list of customers per project like this:

Project 1
     *Customer 1
     *Customer 2
Project 2
     *Customer 1
I think the change is very subtle and minor to get here but so far I've
been unsuccessful.  Any pointers?

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

Current Thread