﻿<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">

	<xsl:decimal-format NaN=""/>
				<xsl:param name="dvt_apos">'</xsl:param>

				<xsl:template match="/" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:SharePoint="Microsoft.SharePoint.WebControls">
								<xsl:call-template name="Sales_Opportunities"/>
	</xsl:template>

				<xsl:template name="Sales_Opportunities">
								<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>
		<table border="0" width="100%" cellpadding="2" cellspacing="0">
			<tr valign="top">
				<th class="ms-vh" nowrap="">Title</th>
				<th class="ms-vh" nowrap="">Potential Value</th>
				<th class="ms-vh" nowrap="">Color</th>
				<th class="ms-vh" nowrap="">ColorHTML</th>
				<th class="ms-vh" nowrap="">Converted ColorHTML</th>
			</tr>
						<xsl:for-each select="$Rows">
										<xsl:call-template name="Sales_Opportunities.rowview"/>
			</xsl:for-each>
		</table>
	</xsl:template>

				<xsl:template name="Sales_Opportunities.rowview">
		<tr>
			<td class="ms-vb">
				<xsl:value-of select="@Title"/>
			</td>
			<td class="ms-vb">
				<xsl:value-of select="format-number(@Potential_x0020_Value, '#,##0.00;-#,##0.00')"/>
			</td>
			<td class="ms-vb">
				<xsl:value-of select="@Color"/>
			</td>
			<td class="ms-vb">
				<xsl:value-of select="@ColorHTML" disable-output-escaping="yes"/>
			</td>
			<td class="ms-vb">
				<xsl:call-template name="ConvertEscaped">
				    			<xsl:with-param name="ConvertValue" select="@ColorHTML"/>
				</xsl:call-template>
			</td>
		</tr>
	</xsl:template>
	
				<xsl:template name="ConvertEscaped">
								<xsl:param name="ConvertValue"/>
								<xsl:param name="LT"><xsl:text><![CDATA[&lt;]]></xsl:text></xsl:param>
								<xsl:param name="GT"><xsl:text><![CDATA[&gt;]]></xsl:text></xsl:param>
								<xsl:param name="APOS"><xsl:text><![CDATA[&#39;]]></xsl:text></xsl:param>
								<xsl:choose>
		    									<xsl:when test="contains($ConvertValue, $LT)">
		        												<xsl:call-template name="ConvertEscaped">
		            															<xsl:with-param name="ConvertValue" select="concat(substring-before($ConvertValue, $LT), '&lt;', substring-after($ConvertValue, $LT))"/>
		        												</xsl:call-template>	
		    </xsl:when>
		    									<xsl:when test="contains($ConvertValue, $GT)">
		        												<xsl:call-template name="ConvertEscaped">
		            															<xsl:with-param name="ConvertValue" select="concat(substring-before($ConvertValue, $GT), '&gt;', substring-after($ConvertValue, $GT))"/>
		        												</xsl:call-template>	
		    </xsl:when>
		    									<xsl:when test="contains($ConvertValue, $APOS)">
		        												<xsl:call-template name="ConvertEscaped">
		            															<xsl:with-param name="ConvertValue" select="concat(substring-before($ConvertValue, $APOS), $dvt_apos, substring-after($ConvertValue, $APOS))"/>
		        												</xsl:call-template>	
		    </xsl:when>
		    									<xsl:otherwise>
		    	<xsl:value-of select="$ConvertValue" disable-output-escaping="yes"/>
		    </xsl:otherwise>
								</xsl:choose>
	</xsl:template>

</xsl:stylesheet>