Below is a XSLT 1.0 solution with support of node-set extension function:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:common="http://exslt.org/common"
version="1.0">
<xsl:output method="text" />
<xsl:key name="by-month" match="*" use="month" />
<xsl:variable name="month-map">
<months>
<Jan>January</Jan>
<Feb>February</Feb>
<Mar>March</Mar>
<Apr>April</Apr>
<May>May</May>
<Jun>June</Jun>
<Jul>July</Jul>
<Aug>August</Aug>
<Sep>September</Sep>
<Oct>October</Oct>
<Nov>November</Nov>
<Dec>December</Dec>
</months>
</xsl:variable>
<xsl:template match="/">
<xsl:variable name="rtf">
<xsl:for-each select="rss/channel/item">
<x>
<xsl:copy-of select="title" />
<xsl:variable name="month">
<xsl:call-template name="getMonth">
<xsl:with-param name="pub-date" select="pubDate" />
</xsl:call-template>
</xsl:variable>
<month><xsl:value-of
select="common:node-set($month-map)/months/*[local-name() =
normalize-space($month)]" /></month>
</x>
</xsl:for-each>
</xsl:variable>
<xsl:for-each select="common:node-set($rtf)/x[generate-id() =
generate-id(key('by-month', month)[1])]">
<xsl:value-of select="month" /><xsl:text>
</xsl:text>
<xsl:for-each select="key('by-month', month)">
<xsl:value-of select="title" /><xsl:text>
</xsl:text>
</xsl:for-each>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
<xsl:template name="getMonth">
<xsl:param name="pub-date" />
<xsl:variable name="temp-str" select="translate($pub-date, ',', '')" />
<xsl:value-of
select="substring-before(substring-after(substring-after($temp-str,
' '), ' '), ' ')" />
</xsl:template>
</xsl:stylesheet>
On 11/9/07, Brent Wilcox <cwilly00(_at_)yahoo(_dot_)com> wrote:
Hello,
I would like to display an RSS feed grouped by month
using XSL version 1, please.
Here is my xml:
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title>My Feed</title>
<description>My feed desc</description>
<item>
<title>News 1</title>
<description>News 1</description>
<link>http://www.none.ca/1</link>
<pubDate>Thu, 8 Nov 2007 10:10:30 -0500</pubDate>
</item>
<item>
<title>News 2</title>
<description>News 2</description>
<link>http://www.none.ca/2</link>
<pubDate>Tue, 2 Oct 2007 10:10:16 -0500</pubDate>
</item>
</channel>
</rss>
Desired output:
November
News 1
October
News 2
Thank you,
Brent Wilcox
--
Regards,
Mukul Gandhi
--~------------------------------------------------------------------
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>
--~--