Customizing the Way Feeds Look using XSLT

Table of contents

Preface

The Topic, "Displaying Feeds" shows how to configure RSS Bandit to use different XSLT Formatters to customize the look and feel of the Reading Pane. If you look in the source code of RSS Bandit, you'll find a templates folder that contains various XSLT files.

This folder contains the RSS Bandit Item formatting samples. If you start experimenting with these, ensure you use your own: copy/rename the interesting one, and change it to apply your needs.

Basics

You should be familiar with XSLT to be able to get it work. The input of each XSLT stylesheet is a XML document fragment describing an RSS item. The root element will be an RSS 2.0 rss element followed by a single channel element. The subelements of the item element depend on the information provided by a particular RSS feed.

Elements

The required base elements of the channel element are provided for custom formatting.

Besides the subelements of the item element specified in the RSS 2.0 specification there may also be elements from other namespaces which correspond to various RSS 2.0 modules. Brief descriptions of such modules and elements are provided in the table below.

Module Name Description
Dublin Core The Dublin Core Metadata Element Set provides some standard metadata elements for describing published content on the web.
Content A module for the actual content of websites, in multiple formats. The most commonly used element from this module is content:encoded
Slash The Slash RSS 1.0 module augments the RSS core and Dublin Core module's metadata with channel and item-level elements specific to SlashCode-based sites
CommentAPI Describes the wfw:comment element which is used to provide the location of the CommentAPI endpoint to aggregator software.
XHTML in RSS 2.0 Specifies the use of the xhtml:body element to provide content in an RSS feed.
Easy News Topics ENT is provides a mechanism for describing how topic information can be introduced into an RSS 2.0 news feed

Best practice

At first you have to enable the usage of a custom formatter within the options dialog: select the menu File|Options... and then the tab named "Feed Items". Ensure the checkbox "Use a custom formatter" is checked. Then play with the existing formatter stylesheets.

If you are familar with the differences, or you have your own ideas born go back to the options dialog and check on the option "Formatter design mode". This option is valid as long the progam is running. The next time you start Bandit, it is checked off again. Now you can start editing the selected stylesheet with you favourite text editor. Each change will be immediatly active if you select a feed's rss item to display. Errors are reported by a message box and the display switches back to a working internal simple formatting temporary. Next time you have corrected the error, your stylesheet is used again.

Additionally the input used by your stylesheet is saved each time you select an rss item to display to your system temporary folder as a file named "RSSItem.xml" for your reference.

Your stylesheet should produce valid (X)HTML. If you want to use CSS for visual effects, ensure to use it in the embedded form to keep it with your formatting templates. Do not forget to insert a <base href="{//item/link}" /> within the HTML HEAD section to get relative links of images resolved by the browser control!

There is support to split the css stylesheet to a separate file. If your formatter stylesheet want to use that, you have to add these two prameters on the root level (child of <xsl:stylesheet>):

<xsl:param name='AppStartupPath'/>  
<xsl:param name='AppUserDataPath'/>

They are filled by RssBandit to reflect:

Now you can code a line like this:

<link rel="stylesheet" type="text/css" href="{$appstartuppath}/templates/my-new.css" />

pointing to a css file located at C:\Program Files\RssBandit\templates.

Get involved

Feel free to join the Developer community at dev.rssbandit.org by providing patches, suggestions or error reporting!
Rss Bandit users may visit our forum at www.rssbandit.org/forum.