Looping in XSLT -
i have following xml
<?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet href="sample.xsl" type="text/xsl"?> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/atom" xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005" xmlns:dc="http://purl.org/dc/elements/1.1/"> <channel xmlns:cfi="http://www.microsoft.com/schemas/rss/core/2005/internal"> <title cf:type="text">the hindu - front page</title> <link>http://www.hindu.com/</link> <description cf:type="text">the internet edition of hindu, india's national newspaper</description> <image> <url>http://www.hindu.com/hindu/hindux.gif</url> <title>hindu.com</title> <link>http://www.hindu.com/</link> </image> <item> <title cf:type="text" xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005" >isro spectrum deal under review: centre</title> </item> <item> <title cf:type="text" xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005" >response devas</title> </item> </channel> </rss>
the rss/channel/item can of count(in current case it's count 2). need display titles marquee 1 after other follows
isro spectrum deal under review: centre, response devas,....,....
how can accomplish in xslt? kindly advice
thanks
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:cfi="http://www.microsoft.com/schemas/rss/core/2005/internal" xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005" xmlns:dc="http://purl.org/dc/elements/1.1/" exclude-result-prefixes="cfi cf dc"> <xsl:output method="html" indent="yes"/> <xsl:template match="/*"> <div id="marquee"> <xsl:apply-templates select="channel/item/title"/> </div> </xsl:template> <xsl:template match="title"> <xsl:value-of select="."/> <xsl:if test="not(position() = last())">, </xsl:if> </xsl:template> </xsl:stylesheet>
result against sample:
<div id="marquee">isro spectrum deal under review: centre, response devas</div>
Comments
Post a Comment