professional-xml-08-rss2html-rss2html.xsl / xsl
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <html> <head> <title> <xsl:value-of select="rss/channel/title"/> </title> <style type="text/css" media="screen"> body { font-family: verdana, arial, sans-serif; font-size: 80%; line-height: 1.45em; } #itemWrapper {} #itemWrapperHighlight { background-color: #E0E0E0; } #itemTitle{ color: green; } #itemBody{} </style> </head> <body> <xsl:apply-templates/> </body> </html> </xsl:template> <xsl:template match="channel"> <h1> <xsl:value-of select="title"/> </h1> <div id="intro"> <xsl:value-of select="description"/> <br/> <br/> RSS (or Really Simple Syndication) is the name for a format used to share information feeds for updating content. <br/> These feeds contain content from Web sites and contain article headlines, summaries and links back to full-text articles on the web.<br/> For more information on RSS see <a href="http://en.wikipedia.org/wiki/RSS_(protocol)">this page</a> </div> <div id="items"> <xsl:apply-templates select="item"> <xsl:with-param name="maxItems" select="6"/> </xsl:apply-templates> </div> </xsl:template> <xsl:template match="item"> <xsl:param name="maxItems"/> <xsl:if test="count(preceding::item) < <div id="itemWrapper"> <xsl:if test="position() mod 2"> <xsl:attribute name="id">itemWrapperHighlight</xsl:attribute> </xsl:if> <h3 id="itemTitle"> <xsl:value-of select="title"/> </h3> <div id="itemBody"> <xsl:value-of select="description"/> <br/> <a> <xsl:attribute name="href"><xsl:value-of select="url"/></xsl:attribute> <xsl:attribute name="alt"><xsl:value-of select="title"/></xsl:attribute> Read more of this item </a> </div> </div> </xsl:if> </xsl:template> </xsl:stylesheet>
(C) Æliens 20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.