Subject: Re: [xsl] Display RSS grouped by month From: Brent Wilcox <cwilly00@xxxxxxxxx> Date: Fri, 9 Nov 2007 10:28:27 -0800 (PST) |
Thank you for this! One quick question - When I use accent characters in the month names (French), I get an error: "Invalid character in the given encoding." <xsl:variable name="month-map"> <months> <Jan>Janvier</Jan> <Feb>Fivrier</Feb> <Mar>Mars</Mar> <Apr>Avril</Apr> <May>Mai</May> <Jun>Juin</Jun> <Jul>Juillet</Jul> <Aug>Ao{t</Aug> <Sep>Septembre</Sep> <Oct>Octobre</Oct> <Nov>Novembre</Nov> <Dec>Dicembre</Dec> </months> </xsl:variable> Thanks, Brent. --- Mukul Gandhi <gandhi.mukul@xxxxxxxxx> wrote: > 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@xxxxxxxxx> 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 > > Brent Wilcox __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Display RSS grouped by mo, Mukul Gandhi | Thread | Re: [xsl] Display RSS grouped by mo, Mukul Gandhi |
RE: [xsl] Is this the best way to e, Michael Kay | Date | [xsl] Unexpected result in sum, Angela Williams |
Month |