<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
	<xsl:output method="xml" doctype-system="http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" />

	<!-- root/ = main html wrapper -->
	<xsl:template match="resume">
		<html>
			<head>
				<xsl:apply-templates select="name" mode="header" />
			</head>
			<body>
				<div id="start">
					<div id="contact">
						<xsl:apply-templates select="name" mode="contact" />
						<xsl:apply-templates select="contact" />
					</div>
					<div id="header">	
						<xsl:apply-templates select="name" mode="first" />
						<xsl:apply-templates select="description" mode="header" />
					</div>
				</div>
				<xsl:for-each select="experience|skills|distinction">
					<xsl:apply-templates select="." />
				</xsl:for-each>
				<xsl:apply-templates select="description" mode="footer" />
			</body>
		</html>
	</xsl:template>

	
	<!-- /name:header = html header -->	
	<xsl:template match="name" mode="header">
		<title><xsl:value-of select="first" /><xsl:text> </xsl:text><xsl:value-of select="last" /> | Resume</title>
		<meta name="keywords" content="{first} {last} resume"/>
		<meta name="description" content="{first} {last}'s Resume in HTML format" />
		<meta name="content" content="{first} {last}'s Resume in HTML format" />
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="Content-Language" content="en-us" />
		<meta name="author" content="{first} {last}" />
		<link href="http://www.brevpatterson.com/css/resume.css" rel="stylesheet" type="text/css" media="screen,print" title="Resume Stylesheet" />
	</xsl:template>	
	
	<!-- /name:contact = name on top of contact info -->	
	<xsl:template match="name" mode="contact">
		<h1>
			<xsl:value-of select="first" /> 
			<xsl:text> </xsl:text> 
			<xsl:value-of select="last" />
		</h1>
	</xsl:template>	
	
	<!-- /name:first = first name bold -->	
	<xsl:template match="name" mode="first">
		<strong><xsl:value-of select="first" /></strong>
	</xsl:template>	
						
	<!-- /contact = contact information -->	
	<xsl:template match="contact">
		<span id="email"><xsl:value-of select="email" /></span>
		<span id="website"><xsl:value-of select="url" /></span>
		<xsl:apply-templates select="address" />
		<div id="phone"><xsl:value-of select="phone" /></div>
	</xsl:template>

	<!-- /contact/address = address contact -->
	<xsl:template match="address">
		<div id="{name()}">
			<xsl:value-of select="street" /><br />
			<xsl:value-of select="city" />, <xsl:value-of select="state" /> 
			<xsl:text> </xsl:text>
			<xsl:value-of select="zip" />
		</div>
	</xsl:template>
	
	<!-- /description:header = resume description in header -->
	<xsl:template match="description" mode="header">
		<h2><em><xsl:value-of select="title" /></em> | <xsl:value-of select="detail" /></h2>
	</xsl:template>

	<!-- !section_header = section header -->	
	<xsl:template name="section_header">
		<div class="section_header">
			<div class="section_number"><xsl:value-of select="sort" /></div>
			<h3><xsl:value-of select="title" /></h3>
			<h4><xsl:value-of select="description" /></h4>
		</div>
	</xsl:template>


	<!-- /experience = past job experience section -->
	<xsl:template match="experience">
		<div class="section">
			<xsl:call-template name="section_header" />
			<div class="section_content" id="{name()}">
				<xsl:apply-templates select="jobs/job" />
			</div> <!--section_content-->
		</div> <!--section-->
	</xsl:template>

	<!-- /experience/jobs/job = individual job info -->	
	<xsl:template match="jobs/job">
		<div class="{name()}">	
			<xsl:apply-templates select="duration" />
			<span class="company"><xsl:value-of select="company" /></span>
			<xsl:apply-templates select="location" />
			<div class="description">
				<div class="title"><xsl:value-of select="title" /></div>
				<div class="first_column">
					<xsl:apply-templates select="details/detail" mode="first_column" />
				</div>
				<div class="second_column">
					<xsl:apply-templates select="details/detail" mode="second_column" />
				</div>
			</div> <!--description-->
		</div> <!--job-->
	</xsl:template>
	
	<!-- /experience/jobs/job/duration = duration of job -->
	<xsl:template match="duration">			
		<span class="{name()}">
			<xsl:value-of select="start" /> | 
			<xsl:choose>
				<xsl:when test="end/text()"><xsl:value-of select="end" /></xsl:when>
				<xsl:otherwise>Now</xsl:otherwise>
			</xsl:choose>
		</span>
	</xsl:template>
	
	<!-- /experience/jobs/job/location = location of job -->
	<xsl:template match="location">			
		<span class="{name()}">
			<xsl:value-of select="city" /> 
			<xsl:if test="state/text()"> | <xsl:value-of select="state" /></xsl:if>
		</span>
	</xsl:template>
	
	<!-- /experience/jobs/job/details/detail:first_column = first column of job details -->
	<xsl:template match="details/detail" mode="first_column">
		<xsl:if test="position() &lt;= round(count(../*) div 2)">
			<p><xsl:value-of select="." /></p>
		</xsl:if>
	</xsl:template>

	<!-- /experience/jobs/job/details/detail:second_column = second column of job details -->
	<xsl:template match="details/detail" mode="second_column">
		<xsl:if test="position() &gt; round(count(../*) div 2)">
			<p><xsl:value-of select="." /></p>
		</xsl:if>
	</xsl:template>


	<!-- /skills = skills section -->
	<xsl:template match="skills">
		<div class="section">
			<xsl:call-template name="section_header" />
			<div class="section_content" id="{name()}">
				<div id="first_column">
					<ul><xsl:apply-templates select="items/item" mode="first_column" /></ul>
				</div>
				<div id="second_column">
					<ul><xsl:apply-templates select="items/item" mode="second_column" /></ul>
				</div>
				<div id="third_column">
					<ul><xsl:apply-templates select="items/item" mode="third_column" /></ul>
				</div>
			</div> <!--section_content-->
		</div> <!--section-->
	</xsl:template>
	
	<!-- /skills/items/item:first_column = first column of skills list -->
	<xsl:template match="items/item" mode="first_column">
		<xsl:if test="position() &lt;= round(count(../*) div 3)">
			<li><xsl:value-of select="." /></li>
		</xsl:if>
	</xsl:template>
	
	<!-- /skills/items/item:second_column = second column of skills list -->
	<xsl:template match="items/item" mode="second_column">
		<xsl:if test="(position() &gt; round(count(../*) div 3)) and (position() &lt;= (round(count(../*) div 3)*2))">
			<li><xsl:value-of select="." /></li>
		</xsl:if>
	</xsl:template>
	
	<!-- /skills/items/item:third_column = third column of skills list -->
	<xsl:template match="items/item" mode="third_column">
		<xsl:if test="position() &gt; (round(count(../*) div 3)*2)">
			<li><xsl:value-of select="." /></li>
		</xsl:if>
	</xsl:template>


	<!-- /distinction = distinction and education section -->
	<xsl:template match="distinction">
		<div class="section">
			<xsl:call-template name="section_header" />
			<div class="section_content" id="{name()}">
				<xsl:apply-templates select="events/event" />
			</div> <!--section_content-->
		</div> <!--section-->
	</xsl:template>

	<!-- /distinction/events/event = list of events -->
	<xsl:template match="events/event">
		<div class="distinction">
			<div class="year"><xsl:value-of select="year" /></div>
			<div class="detail"><xsl:value-of select="detail" /></div>
		</div>
	</xsl:template>
	

	<!-- /description:footer = resume description in footer -->
	<xsl:template match="description" mode="footer">
		<div id="end">
			<div id="footer">
				<span id="outro"><xsl:value-of select="end" /></span>
				<strong>End</strong>
			</div>
		</div>
	</xsl:template>

</xsl:stylesheet>
