Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I agree with the other answer posters that you should convert your dates to ISO date format.</p> <p>Having said that, if you insist on using the format as supplied in the sample document, you can use the following xsl:sort instructions ...</p> <pre><code>&lt;xsl:sort select="substring(inm:Pub_Date,8)" data-type="number" order="descending"/&gt; &lt;xsl:sort select="string-length( substring-before( 'JanFebMarAprMayJunJulAugSepOctNovDec', substring(inm:Pub_Date,4,3)))" data-type="number" order="descending"/&gt; &lt;xsl:sort select="substring-before(inm:Pub_Date,'-')" data-type="number" order="descending"/&gt; </code></pre> <p>The first sorts on year, the second on month, and then finally day.</p> <p>The style-sheet as a whole is ...</p> <pre><code> &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:inm="http://www.inmagic.com/webpublisher/query"&gt; &lt;xsl:output method="html"/&gt; &lt;xsl:template match="/"&gt; &lt;ul class="baseList newsList"&gt; &lt;xsl:for-each select="inm:Results/inm:Recordset/inm:Record" &gt; &lt;xsl:sort select="substring(inm:Pub_Date,8)" data-type="number" order="descending"/&gt; &lt;xsl:sort select="string-length( substring-before( 'JanFebMarAprMayJunJulAugSepOctNovDec', substring(inm:Pub_Date,4,3)))" data-type="number" order="descending"/&gt; &lt;xsl:sort select="substring-before(inm:Pub_Date,'-')" data-type="number" order="descending"/&gt; &lt;li&gt; &lt;span class="title"&gt; &lt;a href="#"&gt; &lt;xsl:value-of select="inm:Title" /&gt; &lt;/a&gt; &lt;/span&gt; &lt;p class="meta"&gt; &lt;span class="dateTime"&gt; &lt;xsl:value-of select="inm:Pub_Date"/&gt; &lt;/span&gt; &lt;/p&gt; &lt;/li&gt; &lt;/xsl:for-each&gt; &lt;/ul&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <hr> <h2>Update</h2> <p>Just as a helpful hint, here is a neat template you can use to convert dates from the 30-Jun-2012 format to ISO/XML format. Let me know if you can use XSLT 2.0 . The conversion gets simpler in XSLT 2.0 .</p> <pre><code>&lt;xsl:template name="format-date"&gt; &lt;xsl:param name="InDateValue" select="'01-Jan-2000'" /&gt; &lt;xsl:value-of select="concat( substring($InDateValue, 8, 4), '-')"/&gt; &lt;xsl:variable name="month" select="substring($InDateValue, 4, 3)" /&gt; &lt;xsl:value-of select="format-number( translate( $month, 'nFrylgSONDJaebMApupctov', '00240107666') + translate( $month, 'aFpugONDJnebMrAyluSctovc', '12268456'), '00')" /&gt; &lt;xsl:value-of select="concat( '-', substring($InDateValue, 1, 2))"/&gt; &lt;/xsl:template&gt; </code></pre> <p>Ok, its quiet obtuse! But I like it.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload