Skip to Main Content
Developing Feeds with RSS and Atom
book

Developing Feeds with RSS and Atom

by Ben Hammersley
April 2005
Intermediate to advanced content levelIntermediate to advanced
270 pages
7h 13m
English
O'Reilly Media, Inc.
Content preview from Developing Feeds with RSS and Atom

Using XSLT

The transformation of RSS into another form of XML, using XSLT, isn’t very common at the moment, but it may soon have its time in the sun. This is because RSS—especially RSS 1.0, with its complicated relationships and masses of metadata—can be reproduced in many useful ways.

While the examples in this book are text-based and mostly XHTML, there is no reason you can’t render RSS into an SVG graphic, a PDF (via the Apache FOP tool), an MMS-SMIL message for new-generation mobile phones, or any of the hundreds of other XML-based systems. XSLT and the arcane art of writing XSLT stylesheets to take care of all of this is a subject too large for this book to cover in detail—for that, check out O’Reilly’s XSLT.

Nevertheless, I will show you some nifty stuff. Example 8-8 is an XSLT stylesheet that transforms an RSS 1.0 feed into the XHTML produced in Example 8-7.

Example 8-8. Transforming RSS 1.0 into XHTML fragments
<?xml version="1.0"?> <xsl:stylesheet version = '1.0' xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rss="http://purl.org/rss/1.0/" exclude-result-prefixes="rss rdf" > <xsl:output method="html"/> <xsl:template match="/"> <div class="channellink"> <a href="{rdf:RDF/rss:channel/rss:link}"> <xsl:value-of select="rdf:RDF/rss:channel/rss:title"/> </a> </div> <div class="linkentries"> <ul> <xsl:apply-templates select="rdf:RDF/*"/> </ul> </div> </xsl:template> <xsl:template match="rss:channel|rss:item"> <li> <a ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

How to Build an RSS 2.0 Feed

How to Build an RSS 2.0 Feed

Mark Woodman
Secrets of RSS

Secrets of RSS

Steven Holzner

Publisher Resources

ISBN: 0596008813Supplemental ContentErrata Page