<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE doc [
	<!ENTITY nbsp "&#160;">
]>

<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<xsl:template match="PhoneDogResponse">
		<style type="text/css">
			h1 {background-color:#E8E8E8;font-size:22px;}
			h2 {font-size:18px;}
			h3 {font-size:16px;color:#44870E;margin-bottom:2px;}
			#cellularitem {clear:both;margin-bottom:20px;}
			#thumb {float:left;margin-right:20px;}
			#phone {float:left;margin-right:20px;}
			#specifications {clear:both;}
			#group {background-color:#E8E8E8;font-weight:bold;clear:both;margin-top:20px;padding:2px;}
			#attribute {clear:both;border-bottom:dotted 1px #cccccc;}
			#attribute #name {width:200px;float:left;background-color:#F7F7F7;padding:2px;}
			#attribute #value {padding:2px;}
			#buyingchoices {clear:both;margin-top:20px;margin-bottom:20px;border-bottom:dotted 1px #cccccc;}
			#buyingchoices #grid {width:100%;border-left:solid 1px #cccccc;border-top:solid 1px #cccccc;margin:0px;padding:0px;}
			#buyingchoices #grid td {border-bottom:solid 1px #cccccc;border-right:solid 1px #cccccc;}
			#buyingchoices #header {font-weight:bold;background-color:#e5e5e5;}
			#userreview {margin-bottom:20px;border-bottom:dotted 1px #cccccc;}
			#userreviewheader {background-color:#F7F7F7;margin-bottom:6px;}
		</style>
		
		<xsl:apply-templates select="Errors"/>
		<xsl:apply-templates select="CellularItems"/>
	</xsl:template>

	<xsl:template match="Errors">
		<xsl:value-of select="Error"/>
		<br/>
	</xsl:template>

	<xsl:template match="CellularItems">
		<xsl:if test="@TotalPages > 1">
			<b>Total pages: </b> <xsl:value-of select="@TotalPages"/>
			<br/>
			<b>Total records: </b>
			<xsl:value-of select="@TotalRecords"/>
			<p/>
		</xsl:if>
		<xsl:apply-templates select="CellularItem "/>		
	</xsl:template>

	<xsl:template match="CellularItem ">
		<div id="cellularitem">
			<xsl:if test="ImageMedium">
				<div id="thumb">
					<xsl:element name="img">
						<xsl:attribute name="src">
							<xsl:value-of select="ImageMedium/@Url"/>
						</xsl:attribute>
					</xsl:element>
				</div>
			</xsl:if>
			<div id="phone">
				<b>DisplayName: </b>
				<xsl:value-of select="DisplayName"/>
				<br/>
				<b>ModelName: </b>
				<xsl:value-of select="ModelName"/>
				<br/>
				<b>ModelBaseName: </b>
				<xsl:value-of select="ModelBaseName"/>
				<br/>
				<b>Manufacturer: </b>
				<xsl:value-of select="Manufacturer/Name"/>
				<br/>
				<b>User rating: </b>
				<xsl:value-of select="UserRating"/>
			</div>
			<div id="description">
				<b>Description:</b>
				<br/>
				<xsl:value-of select="Description"/>
			</div>
			<xsl:if test="Specifications">
				<div id="specifications">
					<p>&nbsp;</p>
					<h1>Specifications</h1>
					<xsl:apply-templates select="Specifications/Group"/>
				</div>
			</xsl:if>
			<xsl:if test="UserReviews">
				<div id="userreviews">
					<h1>Latest user reviews</h1>
					<xsl:apply-templates select="UserReviews/UserReview"/>
				</div>
			</xsl:if>
			<xsl:if test="BuyingChoices">
				<div id="buyingchoices">
					<p>&nbsp;</p>
					<h1>Buying Choices</h1>
					<xsl:if test="BuyingChoices/BuyingChoice[@Type='phoneandplan']">
						<h2>With new service</h2>
						<table id="grid">
							<tr id="header">
								<td>Seller</td>
								<td>Carrier</td>
								<td>Base Price</td>
								<td>Rebates</td>
								<td>Final Price</td>
								<td>Buy</td>
							</tr>
							<xsl:apply-templates select="BuyingChoices/BuyingChoice[@Type='phoneandplan']"/>
						</table>
						<p/>
					</xsl:if>
					<xsl:if test="BuyingChoices/BuyingChoice[@Type='prepaid']">
						<h2>Prepaid</h2>
						<table id="grid">
							<tr id="header">
								<td>Seller</td>
								<td>Carrier</td>
								<td>Base Price</td>
								<td>Rebates</td>
								<td>Final Price</td>
								<td>Buy</td>
							</tr>
							<xsl:apply-templates select="BuyingChoices/BuyingChoice[@Type='prepaid']"/>
						</table>
						<p/>
					</xsl:if>
					<xsl:if test="BuyingChoices/BuyingChoice[@Type='phoneonly']">
						<h2>Phone only</h2>
						<table id="grid">
							<tr id="header">
								<td>Seller</td>
								<td>Base Price</td>
								<td>Rebates</td>
								<td>Final Price</td>
								<td>Buy</td>
							</tr>
							<xsl:apply-templates select="BuyingChoices/BuyingChoice[@Type='phoneonly']"/>
						</table>
					</xsl:if>
				</div>
			</xsl:if>
		</div>
	</xsl:template>

	<xsl:template match="Specifications/Group">
		<div id="group">
			<xsl:value-of select="@Name"/>
		</div>
		<xsl:apply-templates select="Attribute"/>
	</xsl:template>

	<xsl:template match="UserReviews/UserReview">
		<div id="userreview">
			<div id="userreviewheader">
				<h3>
					<xsl:value-of select="Title"/>
				</h3>
				Rating: <xsl:value-of select="Rating"/> &nbsp;&nbsp;|&nbsp;&nbsp;
				Date: <xsl:value-of select="Date"/> &nbsp;&nbsp;|&nbsp;&nbsp;
				Experience: <xsl:value-of select="Experience"/> &nbsp;&nbsp;|&nbsp;&nbsp;				
				Total votes: <xsl:value-of select="TotalVotes"/> &nbsp;&nbsp;|&nbsp;&nbsp;
				Helpful: <xsl:value-of select="HelpfulVotes"/>
			</div>
			<div id="userreviewcontent">
				<b>Pros: </b>
				<xsl:value-of select="Content/Pros"/>
				<br/>
				<b>Cons: </b>
				<xsl:value-of select="Content/Cons"/>
				<br/>
				<b>Summary: </b>
				<xsl:value-of select="Content/Summary"/>
			</div>
		</div>
	</xsl:template>

	<xsl:template match="Attribute">
		<div id="attribute">
			<div id="name">
				<xsl:value-of select="@Name"/>
			</div>
			<div id="value">
				&nbsp;<xsl:value-of select="@Value"/>
			</div>
		</div>
	</xsl:template>

	<xsl:template match="BuyingChoices/BuyingChoice[@Type='phoneandplan']">
		<tr>
			<td>
				<xsl:choose>
					<xsl:when test="Merchant/ImageSmall">
						<xsl:element name="img">
							<xsl:attribute name="src">
								<xsl:value-of select="Merchant/ImageSmall/@Url"/>
							</xsl:attribute>
						</xsl:element>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="Merchant/Name"/>
					</xsl:otherwise>
				</xsl:choose>
			</td>
			<td>
				<xsl:choose>
					<xsl:when test="Provider/ImageSmall">
						<xsl:element name="img">
							<xsl:attribute name="src">
								<xsl:value-of select="Provider/ImageSmall/@Url"/>
							</xsl:attribute>
						</xsl:element>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="Provider/Name"/>
					</xsl:otherwise>
				</xsl:choose>
			</td>
			<td>
				<xsl:value-of select="BasePrice/@Amount"/>
			</td>
			<td>
				<xsl:value-of select="RebateDescription"/>&nbsp;
			</td>
			<td>
				<xsl:value-of select="FinalPrice/@Amount"/>
			</td>
			<td>
				<xsl:element name="a">
					<xsl:attribute name="href">
						<xsl:value-of select="UrlPurchase"/>
					</xsl:attribute>
					Buy with a plan
				</xsl:element>
				<xsl:if test="UrlPurchaseWithFamilyPlan">
					<br/>
					<xsl:element name="a">
						<xsl:attribute name="href">
							<xsl:value-of select="UrlPurchaseWithFamilyPlan"/>
						</xsl:attribute>
						Buy with a family plan
					</xsl:element>
				</xsl:if>
			</td>
		</tr>
	</xsl:template>

	<xsl:template match="BuyingChoices/BuyingChoice[@Type='prepaid']">
		<tr>
			<td>
				<xsl:choose>
					<xsl:when test="Merchant/ImageSmall">
						<xsl:element name="img">
							<xsl:attribute name="src">
								<xsl:value-of select="Merchant/ImageSmall/@Url"/>
							</xsl:attribute>
						</xsl:element>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="Merchant/Name"/>
					</xsl:otherwise>
				</xsl:choose>
			</td>
			<td>
				<xsl:choose>
					<xsl:when test="Provider/ImageSmall">
						<xsl:element name="img">
							<xsl:attribute name="src">
								<xsl:value-of select="Provider/ImageSmall/@Url"/>
							</xsl:attribute>
						</xsl:element>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="Provider/Name"/>
					</xsl:otherwise>
				</xsl:choose>
			</td>
			<td>
				<xsl:value-of select="BasePrice/@Amount"/>
			</td>
			<td>
				<xsl:value-of select="RebateDescription"/>&nbsp;
			</td>
			<td>
				<xsl:value-of select="FinalPrice/@Amount"/>
			</td>
			<td>
				<xsl:element name="a">
					<xsl:attribute name="href">
						<xsl:value-of select="UrlPurchase"/>
					</xsl:attribute>
					Buy with a plan
				</xsl:element>
				<xsl:if test="UrlPurchaseWithFamilyPlan">
					<br/>
					<xsl:element name="a">
						<xsl:attribute name="href">
							<xsl:value-of select="UrlPurchaseWithFamilyPlan"/>
						</xsl:attribute>
						Buy with a family plan
					</xsl:element>
				</xsl:if>
			</td>
		</tr>
	</xsl:template>

	<xsl:template match="BuyingChoices/BuyingChoice[@Type='phoneonly']">
		<tr>
			<td>
				<xsl:choose>
					<xsl:when test="Merchant/ImageSmall">
						<xsl:element name="img">
							<xsl:attribute name="src">
								<xsl:value-of select="Merchant/ImageSmall/@Url"/>
							</xsl:attribute>
						</xsl:element>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="Merchant/Name"/>
					</xsl:otherwise>
				</xsl:choose>
		</td>
		<td>
			<xsl:value-of select="BasePrice/@Amount"/>
		</td>
		<td>
			<xsl:value-of select="RebateDescription"/>&nbsp;
			</td>
			<td>
				<xsl:value-of select="FinalPrice/@Amount"/>
			</td>
			<td>
				<xsl:element name="a">
					<xsl:attribute name="href">
						<xsl:value-of select="UrlPurchase"/>
					</xsl:attribute>
					Buy
				</xsl:element>
			</td>
		</tr>
	</xsl:template>
</xsl:stylesheet> 

