<!-- 
RSS 1.1 to XHTML XSLT Stylesheet
Author: Sean B. Palmer, inamidst.com 
-->

<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
   xmlns="http://www.w3.org/1999/xhtml" 
   xmlns:rss="http://purl.org/net/rss1.1#" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   xmlns:p="http://purl.org/net/rss1.1/payload#" 
   xmlns:dc="http://purl.org/dc/elements/1.1/" 
   exclude-result-prefixes="rss" version="1.0">
<xsl:output indent="yes" omit-xml-declaration="yes" method="xml"/>
<xsl:namespace-alias result-prefix="" stylesheet-prefix=""/>

<xsl:template match="/rss:Channel">
   <xsl:variable name="aboutURI" select="@rdf:about"/>
   <xsl:variable name="linkURI" select="./rss:link"/>

   <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
   <title><xsl:value-of select="./rss:title"/></title>
   <style type="text/css">
   body { margin: 1.5em 2em; font-size: 0.95em; }
   h1, h2, h3, h4, h5, h6 { 
      font-family: Arial; 
      color: #555; 
   }
   h1, h2 { font-family: Tahoma, Arial; }
   div.items { margin-left: 0.25em; }
   div.item { 
      margin-left: 0.25em; 
      padding-left: 1em; 
      border-left: 0.5em solid #e0f0f5; 
   }
   h1 a, div.item h3 a { color: #556; }
   </style>
   </head>
   <body>
   <h1><a href="{$aboutURI}"><xsl:value-of select="./rss:title"/></a></h1>
   <xsl:if test="$aboutURI != $linkURI">
      <p>Link: &lt;<a href="{$linkURI}">link</a>&gt;</p>
   </xsl:if>
   <xsl:apply-templates/>
   <xsl:if test="dc:creator">
      <address><xsl:value-of select="dc:creator"/></address>
   </xsl:if>
   </body>
   </html>
<!-- Force trailing newline -->
<xsl:text>
</xsl:text>
</xsl:template>

<xsl:template match="rss:description">
   <xsl:if test="not(../content:encoded)">
      <p><xsl:copy-of select="@xml:lang"/>
         Description: <xsl:value-of select="."/>
      </p>
   </xsl:if>
</xsl:template>

<xsl:template match="rss:Channel/rss:image">
   <img src="{./rss:url}" alt="{./rss:title}" />
</xsl:template>

<!-- @@ Extension elements -->

<xsl:template match="rss:items">
   <h2>Items</h2>
   <div class="items">
   <xsl:apply-templates/>
   </div>
</xsl:template>

<xsl:template match="rss:item">
   <div class="item">
      <h3><a href="{./rss:link}">
         <xsl:value-of select="./rss:title"/>
      </a></h3>
      <xsl:apply-templates/>
   </div>
</xsl:template>

<xsl:template match="content:encoded">
   <div class="content">
      <xsl:value-of select="." disable-output-escaping="yes" />
   </div>
</xsl:template>

<xsl:template match="p:payload">
   <div class="payload">
      <xsl:for-each select="*">
         <xsl:copy-of select="."/>
      </xsl:for-each>
   </div>
</xsl:template>

<!-- Good ol' don't-pass-text-through -->
<xsl:template match="text()|@*"/>

</xsl:transform>
