Thread: Sorting?
View Single Post
  #2 (permalink)  
Old October 27th, 2003, 11:06 AM
pgtips pgtips is offline
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Looks like just a straightforward sorting problem. Take a look at this stylesheet which applies the same sort twice - once for the summary and once for the detail. (Note that I had to add an <Events> container node to the XML you posted to make it a valid XML document, and that is reflected in the path used in the xsl:for-each).

Also, it would be easier to see that the sort is working correctly if you didn't have the same address in each Event ;)

Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
  <xsl:template match="/">
    <html>
      <head>
        <title>Events</title>
      </head>
      <body>

        <xsl:for-each select="Events/Event">
          <xsl:sort select="AirDateTime"/>
          <xsl:sort select="ArriveTime"/>
          <xsl:value-of select="AirDateTime"/> - <xsl:value-of select="Location"/>
          <br/>
        </xsl:for-each>
        <br/>
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        <br/><br/>

        <xsl:for-each select="Events/Event">
          <xsl:sort select="AirDateTime"/>
          <xsl:sort select="ArriveTime"/>
          <xsl:value-of select="AirDateTime"/> - <xsl:value-of select="ArriveTime"/>
          <br/>
          <xsl:value-of select="Location"/>
          <br/>
          <xsl:value-of select="Street"/>
          <br/>
          <xsl:value-of select="City"/>, <xsl:value-of select="State"/>
          <br/>
          <br/>
        </xsl:for-each>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>
hth
Phil
Reply With Quote