﻿<xsl:transform  version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"
				exclude-result-prefixes="xsl xs">
	<xsl:output method="html"/>
	<xsl:template match="rss/channel">
		<table border="0">
		<xsl:apply-templates select="item">
			<xsl:sort select="substring-before(substring-after(description, 'SponsorshipLevel:&lt;/b&gt;'), '&lt;/div&gt;')" />
			<xsl:sort select="title" />
		</xsl:apply-templates >
		</table>
	</xsl:template>

	<xsl:template match="title">
		<xsl:value-of select="text()"/>
	</xsl:template>
	
	<xsl:template match="item">
		<tr>
			<td valign="top">
				<a>
					<xsl:attribute name="href">
						<xsl:call-template name="getWSSDescriptionField">
							<xsl:with-param name="source" select="description"/>
							<xsl:with-param name="fieldName" select="'Link'"/>
						</xsl:call-template>
					</xsl:attribute>
					<img border="0">
						<xsl:attribute name="src">
							<xsl:call-template name="getWSSDescriptionField">
								<xsl:with-param name="source" select="description"/>
								<xsl:with-param name="fieldName" select="'Logo'" />
							</xsl:call-template>
						</xsl:attribute >
						<!--				
				<xsl:variable name = "desc">
					<xsl:call-template name="getTag">
						<xsl:with-param name="source" select="description"/>
						<xsl:with-param name="before">Description:&lt;/b&gt; </xsl:with-param>
						<xsl:with-param name="after">&lt;/div&gt;</xsl:with-param>
					</xsl:call-template>
				</xsl:variable >
				-->
						<xsl:attribute name="alt">
							<!--
						<xsl:value-of select ="substring-after($desc,'&gt;')" />
						-->
							<xsl:value-of select="title"/>
						</xsl:attribute>
					</img>
				</a>
			</td>
			<td valign="top">
				<xsl:variable name="itemDescription">
					<xsl:call-template name="getWSSDescriptionField">
						<xsl:with-param name="source" select="description"/>
						<xsl:with-param name="fieldName" select="'Description'"/>
					</xsl:call-template>
				</xsl:variable>
				<xsl:value-of disable-output-escaping="yes" select ="substring-after($itemDescription,'&lt;div&gt;')"/>
			</td>
		</tr>
		<tr>
			<td colspan="2">
				<hr/>
			</td>
		</tr>
		<!--
		<xsl:value-of disable-output-escaping="yes" select="description"/>
		-->
	</xsl:template>

	<xsl:template name="getWSSDescriptionField">
		<xsl:param name="source"/>
		<xsl:param name="fieldName"/>

		<xsl:variable name="before" select="concat($fieldName,':&lt;/b&gt; ')" />
		<xsl:variable name="after" select ="'&lt;/div&gt;'" />

		<xsl:variable name = "firstChop" >
			<xsl:value-of select="substring-after($source,$before)"/>
		</xsl:variable>
		<xsl:variable name = "results">
			<xsl:value-of select = "substring-before($firstChop,$after)" />
		</xsl:variable>
		<xsl:value-of select ="$results"/>
	</xsl:template>
</xsl:transform>
