Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 23rd, 2011, 03:24 AM
Registered User
 
Join Date: Jun 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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() &lt; 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
 
Old June 23rd, 2011, 07:51 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Consider to post enough details to allow us to reproduce the problem by showing minimal but complete enough samples we can run. So post a sample of the XML, the output you get, the output you want, the XSLT you use, the extension function you use, name the XSLT processor you use.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog





Similar Threads
Thread Thread Starter Forum Replies Last Post
help with Muenchian method grouping and html table mickhughes XSLT 3 May 1st, 2008 06:24 AM
help with Muenchian method grouping... agentdz015 XSLT 1 April 7th, 2008 04:53 PM
Advanced Grouping Using the Muenchian Method Bodiam XSLT 0 August 8th, 2005 11:33 AM
nested muenchian method. Anyone? Kabe XSLT 1 March 26th, 2005 03:24 AM
Grouping XML by Muenchian Method - Urgent :-( xrow XSLT 5 September 28th, 2004 04:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.