|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Limiting the number of RSS-items shown in result t
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi Jo, XSLT 1.0 does not allow you to use <xsl:sort/> on dates. EXSLT has some support for comparing dates, noteably date:difference. If your pubDate was in the DateTime format defined in XSL Schema datatypes (http://www.w3.org/TR/xmlschema-2/#dateTime), you could use date:format-date (also EXSLT) to genereate a numerical representation you can use <xsl:sort/> on. Perhaps something like this: <xsl:for-each select='/item[position() < 11 and not(category='A')]'> <xsl:sort select='date:format-date(pubDate,"ssmmHHDD")'/> <xsl:if test='position() < 4> <!-- include --> </xsl:if> </xsl:for-each> I also noticed that in your example, the rss feed is already sorted descending by date, can you rely on that? If so, you could use position() again to get the latest elements. hth, Wolfgang jo lemen wrote: | I manage two web sites on which I want to visualize a shared RSS 2.0 feed, but only partly. The items shown depend on the contents of the RSS feed's <category> tag and I only want to show the three most recent items selected. The RSS feed contains items categorized as either 'A', 'B' or 'both'. | | On web site 1, I want to show exactly 3 items from categories 'A' and 'both' (hence: not B), on site 2 I want to show exactly 3 items from categories 'B' and 'both' (hence: not A) | | It's no problem to limit the number of input items, for example, to 10: | <xsl:if test="position() < 11"> | | and select them: | <xsl:if test="not(category='A')"> | | My question: how can I limit the result tree to the 3 most recent, selected items out of a total of 10 items? | | Parsing is done with classic asp. All files are on the same server. | | The RSS sample feed can be found at http://users.pandora.be/chunga/RSSsamplefeed.xml | | The xsl files : see http://users.pandora.be/chunga/RSSsamplefeed_notA.xsl | http://users.pandora.be/chunga/RSSsamplefeed_notB.xsl | | Hope someone can help. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (Cygwin) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFBamE/qjaicDyx8o8RAiIOAJ47u4A29nc/OLWSjqHPgZ3ZWUAOgQCggi+6 Ng5MaZE8DMSc4HF470oAUFs= =Oq+2 -----END PGP SIGNATURE-----
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








