Muenchian Method and date sorting
Hey
In a solution that I am developing, I recieve an rss feed:
<item>
<title>Categori(1) - post</title>
<link>http://www.test.dk</link>
<guid>http://www.test.dk</guid>
<description><![CDATA[nhmnbm nm bnmnm]]></description>
<pubDate>Wed, 11 May 2011 10:48:55 GMT</pubDate>
<author>Bo Nedergaard</author>
</item>
The feed contains many "items" like this one. Each of them belongs to a certain category, stated by the title, "Category(1) - post", "Category(2) - post" and so on. This means that the feed could have many "items" with the title "Categori(1) - post", "Categori(2) - post" and so on.
At all times I want to show the top three Categories. The top three categories is the ones with the most recently published "items"(can be seen in the xml node pubdate). The html output shoul look like this one:
Categori(3) - post
17-06
Categori(1) - post
12-06
Categori(8) - post
I use the Muenchian Method to find the categories, like this:
<xsl:key name="categories" match="item" use="title" />
<xsl:template match="channel">
<xsl:for-each select="item[count(. | key('categories', title)[1]) = 1]">
<xsl:sort select="substring(myExtension:FormatDateTime(pubDa te, 'd'),7,4)" order="descending"/>
<xsl:sort select="substring(myExtension:FormatDateTime(pubDa te, 'd'),4,2)" order="descending"/>
<xsl:sort select="substring(myExtension:FormatDateTime(pubDa te, 'd'),1,2)" order="descending"/>
<xsl:choose>
<xsl:when test="position() < 4 ">
<xsl:variable name="Title"><xsl:value-of select="title"/></xsl:variable>
<xsl:variable name="Link"><xsl:value-of select="link"/></xsl:variable>
<a href="{$Link}"><xsl:value-of select="$Title"/></a><br/>
<xsl:value-of select="substring(myExtension:FormatDateTime(pubDa te, 'd'),1,5)"/><br/><br/>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:template>
It finds the categories all right, but it does not show the dates from the most recently published "items" and the date sorting is not correct. Actually it is dates from older "items".
Can anyone help me?
Best regards
Bo
|