RE: [xsl] grouping and sorting by date

Subject: RE: [xsl] grouping and sorting by date
From: Jarno.Elovirta@xxxxxxxxx
Date: Wed, 3 Mar 2004 15:12:33 +0200
Hi,

> I am trying to group and sort by date in an xslt I am
> working on going from xml to html. Specifically, I am
> trying to sort by year, month and then day on an
> event's start date. It appears that I may need to use
> keys and a sorting method to do this. I have looked
> through the FAQs and other tutorials, but I am having
> trouble grokking it. Can someone lend some help?

Didn't I or someone else here already reply to you about the sorting? Could you elaborate on exactly what do you have problems with? First declare the key to be used in the Muechian grouping

  <xsl:key name="group" match="xcal:vevent" use="substring-before(xcal:dtstart, ' ')"/>

then group and sort with

  …
  <!-- process groups -->
  <xsl:for-each select="xcal:vevent[generate-id(.) = generate-id(key('group', substring-before(xcal:dtstart, ' ')))]">
    <xsl:sort select="translate(substring-before(xcal:dtstart, ' '), '-', '')" data-type="number" />
    <!-- process group members -->
    <xsl:for-each select="key('group', substring-before(xcal:dtstart, ' '))">
      …
    </xsl:for-each>
  </xsl:for-each>
  …

Cheers,

Jarno - Chris C: Vengeance Is Mine

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


Current Thread