<?xml version="1.0"?>
<xsl:stylesheet
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:html="http://www.w3.org/1999/xhtml"
	version="1.0">

	<!--
		Author: james.ojaste@ec.gc.ca
		License: Creative Commons Attribution-ShareAlike License
					http://creativecommons.org/licenses/by-sa/2.0/
	-->

	<xsl:output method="html"/>

	<xsl:template match="/murpg">
		<html:html xmlns="http://www.w3.org/1999/xhtml">
		<head>
			<style type="text/css">
				body { margin: 0; padding: 0; }

				td { vertical-align: top; margin: 0; padding: 2px; }
				ul, li, tr { margin: 0; padding: 0; }
				li { margin-left: 1em; }
				.text table { margin: 0; padding: 0; border: 1px solid black; }
				tr, td, th  { border-bottom: 1px solid black; }

				.options li { list-style-type: circle; }

				.toc {
					margin: 0;
					background: rgb(185,205,235);
				}

				.toc h1 {
					font-family: serif;
					font-size: 120%;
					margin: 0;
				}
				@media print {
					.toc {
						display: none;
					}
				}


				*[source=MURPG] { color: blue; }
				*[source="X-Men"] { color: red; }
				*[source="Hulk"] { color: green; }
			</style>
			<!--<style>@import 'Exalted.css';</style>-->
		</head>
		<body>
			<table border="0" cellspacing="0" cellpadding="0" width="100%">
			<tr>
				<td class="toc">
					<h1>Contents</h1>

					<ul>
					<li><a href="#Actions">Actions</a></li>
					<li><a href="#Modifiers">Modifiers</a></li>
					<li><a href="#Advantages">Power Advantages</a></li>
					<li><a href="#Challenges">Character Challenges</a></li>
					</ul>
				</td>
				<td class="text">
					<h1>MURPG Character Generation</h1>

					<h2 id="Actions">Actions</h2>
					<table width="100%" cellspacing="0">
						<tr>
							<th>Name</th>
							<th>Cost</th>
							<th>Options</th>
							<th>Rules</th>
						</tr>
						<xsl:apply-templates select="power[@type='action']">
							<xsl:sort select="name"/>
						</xsl:apply-templates>
					</table>

					<h2 id="Modifiers">Modifiers</h2>
					<table width="100%" cellspacing="0">
						<tr>
							<th>Name</th>
							<th>Cost</th>
							<th>Options</th>
							<th>Rules</th>
						</tr>
						<xsl:apply-templates select="power[@type='modifier']">
							<xsl:sort select="name"/>
						</xsl:apply-templates>
					</table>

					<h2 id="Advantages">Power Advantages and Disadvantages</h2>
					<table width="100%" cellspacing="0">
						<tr>
							<th>Name</th>
							<th>Cost Adjustment</th>
						</tr>
						<xsl:apply-templates select="advantage"/>
					</table>

					<h2 id="Challenges">Character Challenges</h2>
					<table width="100%" cellspacing="0">
						<tr>
							<th>Name</th>
							<th>Refund</th>
						</tr>
						<xsl:apply-templates select="challenge"/>
					</table>
				</td>
			</tr>
			</table>
		</body>
		</html:html>
	</xsl:template>

	<xsl:template match="power">
		<tr>
			<xsl:if test="@source != ''">
				<xsl:attribute name="source">
					<xsl:value-of select="@source"/>
				</xsl:attribute>
			</xsl:if>
			<td><xsl:value-of select="name"/></td>
			<td><xsl:value-of select="cost"/></td>
			<td class="options"><ul><xsl:apply-templates select="option"/></ul>&#160;</td>
			<td><ul><xsl:apply-templates select="rule"/></ul>&#160;</td>
		</tr>
	</xsl:template>

	<xsl:template match="advantage">
		<tr>
			<xsl:if test="@source != ''">
				<xsl:attribute name="source">
					<xsl:value-of select="@source"/>
				</xsl:attribute>
			</xsl:if>
			<td><xsl:value-of select="name"/></td>
			<td><xsl:value-of select="cost"/></td>
		</tr>
	</xsl:template>

	<xsl:template match="challenge">
		<tr>
			<xsl:if test="@source != ''">
				<xsl:attribute name="source">
					<xsl:value-of select="@source"/>
				</xsl:attribute>
			</xsl:if>
			<td><xsl:value-of select="name"/></td>
			<td><xsl:value-of select="refund"/> stones</td>
		</tr>
	</xsl:template>

	<xsl:template match="option|rule">
		<li>
			<xsl:if test="@source != ''">
				<xsl:attribute name="source">
					<xsl:value-of select="@source"/>
				</xsl:attribute>
			</xsl:if>
			<xsl:value-of select="."/>
		</li>
	</xsl:template>

</xsl:stylesheet>
