<?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"/>

<xsl:template match="/">
    <xsl:apply-templates select="/rss/channel"/>
</xsl:template>

<xsl:template match="/rss/channel">
    <div class="pageContent">
        <div  class="pageContent">
            <h3><xsl:value-of select="title"/></h3>
        </div>
        <xsl:apply-templates select="/rss/channel/image"/>
        <xsl:call-template name="display_description"/>
        <xsl:call-template name="display_properties"/>
        <xsl:if test="/rss/channel/item/title and count(/rss/channel/item)>1">
        <xsl:for-each select="/rss/channel/item">
            <xsl:call-template name="display_item">
                <xsl:with-param name="full" select="0"/>
            </xsl:call-template>
        </xsl:for-each>
        </xsl:if>
        <xsl:for-each select="/rss/channel/item">
            <xsl:call-template name="display_item">
                <xsl:with-param name="full" select="1"/>
            </xsl:call-template>
        </xsl:for-each>
    </div>
</xsl:template>

<xsl:template match="/rss/channel/image">
    <a href="{link}" title="{title}" target="_blank">
        <img alt="{title}" border="0">
            <xsl:attribute name="src"><xsl:value-of select="normalize-space(url)"/></xsl:attribute>
        </img>
    </a>
</xsl:template>

<xsl:template name="display_item">
    <xsl:param name="full"/>
    <xsl:choose>
        <xsl:when test="$full=1">
            <div class="pageContent">
                <xsl:choose>
                <xsl:when test="title">
                    <a name="item{position()}"></a>
                    <h5 class="pageContent">
                        <xsl:value-of select="position()"/> - <a href="{link}" class="pageContent" target="_blank"><xsl:value-of select="title"/></a>
                    </h5>
                 </xsl:when>
                 <xsl:otherwise>
                    <hr noshade="noshade" size="1"/>
                 </xsl:otherwise>
                 </xsl:choose>
            <xsl:call-template name="display_description"/>
            <xsl:call-template name="display_properties"/>
            </div>
        </xsl:when>
        <xsl:otherwise>
        <span class="pageContent">
            <span style="line-height:20px;"><xsl:value-of select="position()"/></span> - <a href="#item{position()}" class="pageContent"  style="line-height:20px;"><xsl:value-of select="title"/></a><br/>
        </span>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

<xsl:template name="display_description">
    <div class="pageContent">
    <p>
        <xsl:value-of select="description" disable-output-escaping="yes"/>
    </p>
    </div>
</xsl:template>

<xsl:template name="display_properties">
    <div class="pageContent">
    <p>
    <xsl:if test="pubDate!=''"><xsl:value-of select="pubDate"/></xsl:if>
    </p>
    </div>
</xsl:template>

</xsl:stylesheet>