• Get the Flash Player to see the slideshow.
  • Categories

  • Authors

  • Great Quotes

    Which is more vital fame or health? Which is more precious health or riches? Which is more harmful loss or gain? — Lao Tzu - Tao Te Ching

Get in touch...

To have a chat about
your CMS needs...

Call us 0207 193 2014
or
Email us on

XSL:Sort By Date

March 2nd, 2009 by Michael Thomas

The following  should do the work

<xsl:apply-templates select="[some repeating datum]">
<xsl:sort order="descending" select="substring(//somedate,7,4)"> <!-- year-->
<xsl:sort order="descending" select="substring(//somedate,4,2)"> <!-- month-->
<xsl:sort order="descending" select="substring(//somedate,1,2)"> <!-- day-->
</xsl:apply-templates>

This assumes the date is in the form dd/mm/yyyy: the seperators could be different as they are ignored anyway based on the substring.

The important thing to realise here is that the <xsl:sort> functions do not do anything APART from sort, so there is nothing to see at this point if debugging

The work is done in a receiving

<xsl:template match="[match repeating datum]">
 
...
 
</xsl:template>

The ensures items are delivered to this block in the correct order, what is displayed is determined in the section

Tags: , , ,

Leave a Reply

You must be logged in to post a comment.