﻿<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">
			<xsl:apply-templates select="item">
		</xsl:apply-templates >
		
	</xsl:template>

	<xsl:template match="title">
		<xsl:value-of select="text()"/>
		
	</xsl:template>
		
	<xsl:template match="item">
		<table border="1" cellpadding="2" cellspacing="0" width="100%">
			<tr>
				<td>
					<b>
						<xsl:value-of select="title"/>
					</b>
				</td>
			</tr>
			<tr>
				<td>
					<xsl:variable name="answer">
					<xsl:call-template name="getWSSDescriptionField">
						<xsl:with-param name="description" select="description"/>
						<xsl:with-param name="fieldName" select="'Answer'"/>
					</xsl:call-template>
					</xsl:variable>
					<xsl:value-of disable-output-escaping ="yes" select ="$answer"/>
				</td>
			</tr>
		</table>
		<br/>
		<br/>
	</xsl:template>

	<xsl:template name="getWSSDescriptionField">
		<xsl:param name="description"/>
		<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="htmlFieldStart" select ="'&lt;div class=ExternalClass'" />

		<xsl:variable name = "leftRemoved" >
			<xsl:value-of select="substring-after($description,$before)"/>
		</xsl:variable>
		<xsl:variable name = "results">
			<xsl:value-of disable-output-escaping="yes" select = "substring-before($leftRemoved,$after)" />
		</xsl:variable>

		<!-- HTML fields have extra <div>-->
		<xsl:choose>
			<xsl:when test="starts-with($results, $htmlFieldStart)">
				<xsl:value-of select = "substring-after($results,'&gt;')" />
			</xsl:when >
			<xsl:otherwise>
				<xsl:value-of select ="$results"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
</xsl:transform>
