xsl-list
[Top] [All Lists]

Re: [xsl] Sorting by date

2008-05-27 09:03:50
sudheshna iyer wrote:
I am using xsl:stylesheet version="1.0".

Here is an XSLT 1.0 stylesheet that produces the result you described. You only need to complete the "translation table" for the months:

<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:dt="http://example.com/2008/data";
  version="1.0">

  <xsl:output method="text"/>

  <data xmlns="http://example.com/2008/data";>
    <month s="Jan" n="01"/>
    <month s="Feb" n="02"/>
    <month s="Mar" n="03"/>
    <month s="Apr" n="04"/>
    <!-- add other months here -->
  </data>

  <xsl:template match="/">
    <xsl:apply-templates select="rss/channel/item">
      <xsl:sort data-type="number" order="descending"
select="concat(substring(SortDate, 13, 4), document('')/xsl:stylesheet/dt:data/dt:month[(_at_)s = substring(current()/SortDate, 9, 3)]/@n, substring(SortDate, 6, 2))"/>
    </xsl:apply-templates>
  </xsl:template>

  <xsl:template match="item">
<xsl:value-of select="concat(substring(SortDate, 13, 4), '-', document('')/xsl:stylesheet/dt:data/dt:month[(_at_)s = substring(current()/SortDate, 9, 3)]/@n, '-', substring(SortDate, 6, 2), '&#10;', title, '&#10;&#10;')"/>
  </xsl:template>

</xsl:stylesheet>


--

        Martin Honnen
        http://JavaScript.FAQTs.com/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>