I've just started using xslt, and it seems straightforward enough (for now!). I am using a simple xsl template to format and display news items from an rss news feed: <xsl:template match="rss"> <xsl:apply-templates select="channel"/> </xsl:template> <xsl:template match="channel"> <xsl:apply-templates select="item"/> </xsl:template> <xsl:template match="item"> <dt> <a href="/"><xsl:value-of select="title"/></a> </dt> <dd> <ul> <li> <a><xsl:attribute name="href"><xsl:value-of select="link"/></xsl:attribute> <xsl:value-of select="description"/> </a> </li> </ul> </dd> </xsl:template> However, in another section of the site I'm building, I would like to display only the four or so most recent items of the rss feed, rather than the whole lot. Can anyone tell me how to do this using xslt functions? As you will see, at the moment my knowledge is limited to applying a blanket template to every item. Any help would be very much appreciated. Many thanks, Robin
wrote in message news:1970fd18-006d-499a-8597-4c94fb558d82@j22g2000hsf.googlegroups.com... > I've just started using xslt, and it seems straightforward enough (for > now!). I am using a simple xsl template to format and display news > items from an rss news feed: > > <xsl:template match="rss"> > <xsl:apply-templates select="channel"/> > </xsl:template> > > <xsl:template match="channel"> > <xsl:apply-templates select="item"/> > </xsl:template> > > <xsl:template match="item"> > <dt> > <a href="/"><xsl:value-of select="title"/></a> > </dt> > <dd> > <ul> > <li> > <a><xsl:attribute name="href"><xsl:value-of > select="link"/></xsl:attribute> > <xsl:value-of select="description"/> > </a> > </li> > </ul> > </dd> > </xsl:template> > > > However, in another section of the site I'm building, I would like to > display only the four or so most recent items of the rss feed, rather > than the whole lot. > > Can anyone tell me how to do this using xslt functions? As you will > see, at the moment my knowledge is limited to applying a blanket > template to every item. > > Any help would be very much appreciated. > > Many thanks, > > Robin Use the position() function in the item template: <xsl:template match="item"> <xsl:if test="position() < 5"> </xsl:if> </xsl:template> -- Joe Fawcett (MVP - XML) http://joe.fawcett.name
In addition to what Joe said in his post, you can limit the number of nodes returned by pubDate (e.g. pass the date value as a parameter). ML --- Matija Lah, SQL Server MVP http://milambda.blogspot.com/