| Home | News | Products | Buy online | Solutions | Contact us | |
| Sitemap | About | Download | Support | Services | Feedback |
How to generate a viewable XML index page for an RSS feed.
If you have an RSS data file, you can create an XML file that will load the RSS file and display it's content in the way you like.
For example, create a small XML file that renders the myRSSfile.rss file by transforming it using the mystylesheet.xsl stylesheet:
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" title="My Stylesheet" href="mystylesheet.xsl" ?> <page> <rss src="myrssfile.rss" simple='yes'/> </page>
Then add the following to your mystylesheet.xsl file:
<xsl:template match="rss">
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<xsl:variable name="docsrc"><xsl:value-of select="@src"/></xsl:variable>
<xsl:variable name="headlinesonly"><xsl:value-of select="@simple"/></xsl:variable>
<documentdata>
<xsl:for-each select="document($docsrc)//item">
<tr>
<td valign="top">
<b><a href="{./link}" class="stdlink"><xsl:value-of select="./title"/></a></b>
<xsl:choose>
<xsl:when test="$headlinesonly='yes'"/>
<xsl:otherwise>
<p><xsl:value-of select="./description"/></p>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:for-each>
</documentdata>
<tr>
<td valign="top" style="padding-top:20px;">
RSS source feed: <a href="{@src}" class="stdlink"><xsl:value-of select="@src"/></a>.<br/><br/>
</td>
</tr>
</table>
</xsl:template>
A complete stylesheet is provided here for reference:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:preserve-space elements="p"/>
<xsl:output method="html" encoding="UTF-8"/>
<xsl:template match="rss">
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<xsl:variable name="docsrc"><xsl:value-of select="@src"/></xsl:variable>
<xsl:variable name="headlinesonly"><xsl:value-of select="@simple"/></xsl:variable>
<documentdata>
<xsl:for-each select="document($docsrc)//item">
<tr>
<td valign="top">
<b><a href="{./link}" class="stdlink"><xsl:value-of select="./title"/></a></b>
<xsl:choose>
<xsl:when test="$headlinesonly='yes'"/>
<xsl:otherwise>
<p><xsl:value-of select="./description"/></p>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:for-each>
</documentdata>
<tr>
<td valign="top" style="padding-top:20px;">
RSS source feed: <a href="{@src}" class="stdlink"><xsl:value-of select="@src"/></a>.<br/><br/>
</td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>
--------------------------------------------------------------------------------
(c) 2004 Nicolai Kjaer, Spinner Software B.V.
http://www.spinnersoftware.com
Copyright 1997-2004 Spinner Software BV (www.spinnersoftware.com).
Home | Products | Buy Online | Privacy statement | Price policy | About Spinner | Contact Us | Search
This page is fully HTML 4.01 and CSS compliant. Please email the webmaster if you encounter any problems with this site.