rss and xml

Here should go questions about transforming XML with XSLT and FOP.
AnonymousDev
Posts: 1
Joined: Tue Jun 09, 2009 11:16 am

rss and xml

Post by AnonymousDev »

Hi experts,

I just begon with xml and xslt, it's going ok. But i'm stuck with something, i have made an rss (xml) but i want to limit the feeds to 5 and see a previous/next link when there are more feeds. So you can only see 5 feeds per page. And if there are more then 5 feeds I want to see the previous/next link and it will navigate to the right feeds. How can I accomplish this? I really am stuck

Code: Select all

<?xml version="1.0" encoding="ISO-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="testrss.xsl"?>
<rss version="2.0">

<channel>
<item>
<title>W3Schools Home Page</title>
<link>http://www.w3schools.com</link>
<description>Free web building tutorials</description>
</item>
<item>
<title>RSS Tutorial</title>
<link>http://www.w3schools.com/rss</link>
<description>New RSS tutorial on W3Schools</description>
</item>
<item>
<title>XML Tutorial</title>
<link>http://www.w3schools.com/xml</link>
<description>New XML tutorial on W3Schools</description>
</item>
<item>
<title>CSS Tutorial</title>
<link>http://www.w3schools.com/css</link>
<description>New CSS tutorial on W3Schools</description>
</item>
<item>
<title>JS Tutorial</title>
<link>http://www.w3schools.com/js</link>
<description>New JavaScript tutorial on W3Schools</description>
</item>
<item>
<title>Some Tutorial</title>
<link>http://www.w3schools.com/</link>
<description>New Something tutorial on W3Schools</description>
</item>
<item>
<title>Some 1 Tutorial</title>
<link>http://www.w3schools.com/</link>
<description>New Something 1 tutorial on W3Schools</description>
</item>
<item>
<title>Some 2 Tutorial</title>
<link>http://www.w3schools.com/</link>
<description>New Something 2 tutorial on W3Schools</description>
</item>
<item>
<title>Some 3 Tutorial</title>
<link>http://www.w3schools.com/</link>
<description>New Something 3 tutorial on W3Schools</description>
</item>
<item>
<title>Some 4 Tutorial</title>
<link>http://www.w3schools.com/</link>
<description>New Something 4 tutorial on W3Schools</description>
</item>
<item>
<title>Some 6 Tutorial</title>
<link>http://www.w3schools.com/</link>
<description>New Something 6 tutorial on W3Schools</description>
</item>
<item>
<title>Some 7 Tutorial</title>
<link>http://www.w3schools.com/</link>
<description>New Something 7 tutorial on W3Schools</description>
</item>
<item>
<title>Some 8 Tutorial</title>
<link>http://www.w3schools.com/</link>
<description>New Something 8 tutorial on W3Schools</description>
</item>
<item>
<title>Some 9 Tutorial</title>
<link>http://www.w3schools.com/</link>
<description>New Something 9 tutorial on W3Schools</description>
</item>
<item>
<title>Some 10 Tutorial</title>
<link>http://www.w3schools.com/</link>
<description>New Something 10 tutorial on W3Schools</description>
</item>
</channel>

</rss>

Code: Select all

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<html>
<head>
<title></title>
</head>
<body>
<xsl:for-each select="rss/channel/item">
<a>
<xsl:attribute name="href">
<xsl:value-of select="link" />
</xsl:attribute>

<xsl:value-of select="title" />
</a>
<br />
<xsl:value-of select="description" />
<br />
<br />
</xsl:for-each>

<a>
<xsl:number value="count(rss/channel/item)"/>

</a>
<br />


</body>
</html>
</xsl:template>
</xsl:stylesheet>
I though of something like this:

Code: Select all

<xsl:variable name="count">
<xsl:number value="count(rss/channel/item)"/>
</xsl:variable >
<xsl:if test="$count > 5">
show
</xsl:if>
Dan
Posts: 501
Joined: Mon Feb 03, 2003 10:56 am

Re: rss and xml

Post by Dan »

Hello,

You could try to a combination of grouping:
http://www.xml.com/lpt/a/1314
and output using xsl:result-document:
http://www.ibm.com/developerworks/xml/l ... ltxsl.html

Cheers,
Dan
Post Reply