<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:param name="mode" select="$mode"/>

<xsl:template match="resume">
\documentclass[twoside,letterpaper]{article}
\usepackage{palatcm}
\usepackage{hyperref}

\setlength{\topmargin}{0.0in}
\setlength{\oddsidemargin}{0.25in}
\setlength{\evensidemargin}{0.25in}
\setlength{\textwidth}{6.0in}
\setlength{\textheight}{8.5in}

\begin{document}
    \thispagestyle{empty}
    \begin{flushright}
	<xsl:value-of select="address/street"/> \\
	\textbf{\Large <xsl:value-of select="name"/>} \hfill
	<xsl:value-of select="address/city"/>,
	    <xsl:value-of select="address/state"/>
	    <xsl:text>  </xsl:text><xsl:value-of
		select="address/zip"/> \\
	    (formerly <xsl:value-of select="formerly"/>) \hfill
	\href{mailto:<xsl:value-of select="email"/>}{<xsl:value-of
	    select="email"/>} \\
	    Full resume at: \url{http://www.csh.rit.edu/~pat/me/resume/} \hfill
	    <xsl:value-of select="phone"/> \\
	\hrulefill
    \end{flushright}

    \begin{description}
	<xsl:choose>
	    <xsl:when test="$mode='brief'">
		<xsl:apply-templates select="objective" mode="brief"/>
	    </xsl:when>
	    <xsl:otherwise>
		<xsl:apply-templates select="objective" mode="long"/>
	    </xsl:otherwise>
	</xsl:choose>

	\item[{\large Publications}]\hfill
	    \begin{description}
		<xsl:apply-templates select="publications/*"/>
	    \end{description}

	\item[{\large Patents}]\hfill
	    \begin{description}
		<xsl:apply-templates select="patents/*"/>
	    \end{description}

	<xsl:apply-templates select="knowledge"/>

	\pagebreak[2]
	\item[{\large Work Experience}]\hfill

	    <xsl:choose>
		<xsl:when test="$mode='brief'">
		    <xsl:apply-templates select="experience/job" mode="brief"/>
		</xsl:when>
		<xsl:otherwise>
		    <xsl:apply-templates select="experience/job" mode="long"/>
		</xsl:otherwise>
	    </xsl:choose>

	\item[{\large Other Programming Activities}]\hfill

	    <xsl:choose>
		<xsl:when test="$mode='brief'">
		    <xsl:apply-templates select="activities/job" mode="brief"/>
		</xsl:when>
		<xsl:otherwise>
		    <xsl:apply-templates select="activities/job" mode="long"/>
		</xsl:otherwise>
	    </xsl:choose>


    \end{description}
\end{document}
</xsl:template>

<xsl:template match="knowledge">
    \item[{\large Technical Familiarity}]\hfill

	\textbf{Languages:~~}
	    <xsl:apply-templates select="regular/lang"/>.
	    Also:~~<xsl:apply-templates select="occasional/lang"/>.

	\textbf{Operating Systems (and hardware):~~}
	    <xsl:apply-templates select="operatingsystems/system"/>.

	\textbf{Concepts and Packages:~~}
	    <xsl:apply-templates select="concepts/concept"/>.
	    Also:~~<xsl:apply-templates select="packages/package"/>.

    \item[{\large Mathematics &amp; Computer Science Education}]\hfill

	\textit{B.S. in Computational Mathematics from the
	Rochester Institute of Technology in Rochester, NY.}

	Mathematics courses include: <xsl:apply-templates
	    select="courses/math/subject"/>.
	<xsl:text>

	</xsl:text>
	Computer Science courses include: <xsl:apply-templates
	    select="courses/computerscience/subject"/>.

</xsl:template>

<xsl:template match="objective" mode="brief">
    <xsl:if test="not(@optional='true')">
	\item[{\large Objective}]\hfill
	    <xsl:value-of select="."/>
    </xsl:if>
</xsl:template>

<xsl:template match="objective" mode="long">
    \item[{\large Objective}]\hfill
	<xsl:value-of select="."/>
</xsl:template>

<xsl:template match="lang|concept|package|subject">
    <xsl:if test="position()>1">
	<xsl:text>, </xsl:text>
    </xsl:if>
    <xsl:if test="position()=last() and last() > 1">
	<xsl:text>and </xsl:text>
    </xsl:if>
    <xsl:value-of select="."/>
</xsl:template>

<xsl:template match="system">
    <xsl:if test="position()>1">
	<xsl:text>, </xsl:text>
    </xsl:if>
    <xsl:if test="position()=last() and last() > 1">
	<xsl:text>and </xsl:text>
    </xsl:if>
    <xsl:value-of select="os"/>
    (<xsl:apply-templates select="arch"/>)</xsl:template
>

<xsl:template match="arch">
    <xsl:if test="position()>1">
	<xsl:text>, </xsl:text>
    </xsl:if>
    <xsl:value-of
select="."/></xsl:template>

<xsl:template match="job" mode="brief">
    <xsl:if test="not(@optional='true')">
	\begin{description}
	\item[<xsl:value-of select="title"/><xsl:apply-templates
	    select="titleURL"/>]\hfill

	    <xsl:apply-templates select="brief"/>

	    <xsl:apply-templates select="employer"/>

	    <xsl:apply-templates select="subjob" mode="brief"/>
	\end{description}
    </xsl:if>
</xsl:template>

<xsl:template match="job" mode="long">
    \begin{description}
    \item[<xsl:value-of select="title"/>]\hfill

	<xsl:apply-templates select="desc"/>

	<xsl:apply-templates select="employer"/>

	<xsl:apply-templates select="subjob" mode="long"/>
    \end{description}
</xsl:template>

<xsl:template match="subjob" mode="brief">
    <xsl:if test="not(@optional='true')">
	\hrulefill

	\begin{description}
	    \item[<xsl:value-of select="title"/>]\hfill

		<xsl:apply-templates select="brief"/>
	\end{description}

    </xsl:if>
    <xsl:if test="position()=last()">
	\hrulefill

    </xsl:if>
</xsl:template>

<xsl:template match="subjob" mode="long">
    \hrulefill

    \begin{description}
	\item[<xsl:value-of select="title"/>]\hfill

	    <xsl:apply-templates select="desc"/>
    \end{description}

    <xsl:if test="position()=last()">
	\hrulefill

    </xsl:if>
</xsl:template>

<xsl:template match="p">
    <xsl:apply-templates/>
</xsl:template>

<xsl:template match="ref">\href{<xsl:value-of select="link"/>}{<xsl:value-of
    select="text"/>}
</xsl:template>

<xsl:template match="titleURL">
(\url{<xsl:value-of select="." />})
</xsl:template>

<xsl:template match="filename">
    \texttt{<xsl:value-of select="."/>}
</xsl:template>

<xsl:template match="employer">

    \textit{
    \href{<xsl:value-of select="url"/>}{<xsl:value-of
	select="name"/>}, <xsl:value-of select="location"/>.  <xsl:value-of
	    select="dates"/>.}
</xsl:template>

<xsl:template match="article">
    \item \textbf{<xsl:value-of select="title"/>}.
	<xsl:value-of select="authors"/>.
	\textit{<xsl:value-of select="magazine"/>
	    (<xsl:value-of select="date"/>)}.
</xsl:template>

<xsl:template match="patent">
    \item[Patent <xsl:value-of select="number"/>:]
    \textbf{<xsl:value-of select="title"/>}.
    <xsl:value-of select="inventors"/>.
    Issued <xsl:value-of select="date"/>.
</xsl:template>

</xsl:stylesheet>
