[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"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
      <xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes"/>
      <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>
      <xsl:template match="PROROW">
            <b>
                  <xsl:value-of select="name"/>
            </b>
            <ul>
    <xsl:for-each select="key('rows', name)/project_name">
      <li>
        <a href="projects_results.xml?project={../id}">
          <xsl:value-of select="." />
        </a>
      </li>
    </xsl:for-each>
            </ul>
      </xsl:template>
</xsl:stylesheet>

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

<?xml version="1.0" encoding="UTF-8"?>
<PROJECTS>
      <PROROW>
            <id>1</id>
            <name>Customer 1</name>
            <project_name>Project 1</project_name>
            <project_name>Project 2</project_name>
      </PROROW>
      <PROROW>
            <id>2</id>
            <name>Customer 2</name>
            <project_name>Project 1</project_name>
      </PROROW>
</PROJECTS>
 
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?
 
Brian


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


Current Thread