﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
	version="1.0"
	xmlns:am="http://www.ani-mayhem.com/"
	xmlns:db="http://www.ani-mayhem.com/database"
	xmlns:g="http://www.ani-mayhem.com/guide"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns="http://www.w3.org/1999/xhtml"
	exclude-result-prefixes="am g db xsl">
	<xsl:output method="xml" encoding="utf-8" indent="yes" omit-xml-declaration="no" doctype-public="-//W3C//DTD XHTML 1.1//EN" doctype-system="http://www.w3.org/MarkUp/DTD/xhtml11.dtd"/>
	<xsl:variable name="cgi">http://www.ani-mayhem.com/cardcatalog.aspx?xmlid=</xsl:variable>
	<xsl:template match="/">
		<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
			<head>
				<title>Ani-Mayhem Online - Guide</title>
				<link rel="stylesheet" href="http://www.ani-mayhem.com/ani-mayhem.css" type="text/css"/>
				<link rel="stylesheet" href="http://www.ani-mayhem.com/guide/guide.css" type="text/css"/>
				<link rel="shortcut icon" href="http://www.ani-mayhem.com/ani-mayhem.ico" type="image/x-icon"/>
			</head>
			<body id="guide">
				<h1>
					<a href="http://www.ani-mayhem.com/">
						<img src="http://www.ani-mayhem.com/ani-mayhem.png" alt="Ani-Mayhem Online" />
					</a>
				</h1>
				<hr />
				<h2 class="location">
					<span class="h2">
						<span class="title">Guide</span>
						<span class="date">February 2, 2012</span>
					</span>
				</h2>
				<xsl:apply-templates/>
			</body>
		</html>
	</xsl:template>
	<xsl:template match="am:ani-mayhem">
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="am:card">
		<div class="border" id="{@xml:id}">
			<xsl:apply-templates/>
		</div>
		<hr />
	</xsl:template>
	<xsl:template match="g:Character | g:Enhancement | g:Equipment | g:Haven | g:Item | g:Location">
		<p class="{translate(local-name(), 'CEHIL', 'cehil')}">
			<xsl:call-template name="dbName"/>
			<span class="type">
				<xsl:value-of select="local-name()"/>
			</span>
		</p>
		<table>
			<xsl:apply-templates/>
		</table>
	</xsl:template>
	<xsl:template match="g:FlashEffect">
		<p class="flasheffect">
			<xsl:call-template name="dbName"/>
			<span class="type">
				Flash Effect
			</span>
		</p>
		<table>
			<xsl:apply-templates/>
		</table>
	</xsl:template>
	<xsl:template match="g:GlobalEffect">
		<p class="globaleffect">
			<xsl:call-template name="dbName"/>
			<span class="type">
				Global Effect
			</span>
		</p>
		<table>
			<xsl:apply-templates/>
		</table>
	</xsl:template>
	<xsl:template match="g:MajorDisaster">
		<p class="majordisaster">
			<xsl:call-template name="dbName"/>
			<span class="type">
				Major Disaster
			</span>
		</p>
		<table>
			<xsl:apply-templates/>
		</table>
	</xsl:template>
	<xsl:template match="g:MinorDisaster">
		<p class="minordisaster">
			<xsl:call-template name="dbName"/>
			<span class="type">
				Minor Disaster
			</span>
		</p>
		<table>
			<xsl:apply-templates/>
		</table>
	</xsl:template>
	<xsl:template match="g:Combat">
		<p class="combat">
			<span class="name">
				<a>
					<xsl:attribute name="href"><xsl:value-of select="$cgi"/><xsl:value-of select="..//@xml:id"/></xsl:attribute>
					<xsl:value-of select="substring-before(db:Name, ' /')"/>
				</a>
				<xsl:text> / </xsl:text>
				<a>
					<xsl:attribute name="href"><xsl:value-of select="$cgi"/><xsl:value-of select="substring-after(@g:Transform, 'Combat ')"/></xsl:attribute>
					<xsl:value-of select="substring-after(db:Name, '/ ')"/>
				</a>
			</span>
			<span class="type">
				Combat
			</span>
		</p>
		<table>
			<xsl:apply-templates/>
		</table>
	</xsl:template>
	<xsl:template match="g:CharmCombat">
		<p class="charmcombat">
			<span class="name">
				<a>
					<xsl:attribute name="href"><xsl:value-of select="$cgi"/><xsl:value-of select="..//@xml:id"/></xsl:attribute>
					<xsl:value-of select="substring-before(db:Name, ' /')"/>
				</a>
				<xsl:text> / </xsl:text>
				<a>
					<xsl:attribute name="href"><xsl:value-of select="$cgi"/><xsl:value-of select="substring-after(@g:Transform, 'Combat ')"/></xsl:attribute>
					<xsl:value-of select="substring-after(db:Name, '/ ')"/>
				</a>
			</span>
			<span class="type">
				Charm Combat
			</span>
		</p>
		<table>
			<xsl:apply-templates/>
		</table>
	</xsl:template>
	<xsl:template match="db:Name"/>
	<xsl:template name="dbName">
		<span class="name">
			<a>
				<xsl:attribute name="href"><xsl:value-of select="$cgi"/><xsl:value-of select="..//@xml:id"/></xsl:attribute>
				<xsl:value-of select="db:Name"/>
			</a>
		</span>
	</xsl:template>
	<xsl:template match="g:Categories">
		<tr>
			<td>
				Categories:
			</td>
			<td>
				<xsl:if test="count(./*) &gt;= 1"><xsl:apply-templates select="./*[1]" mode="g:Keyword"/></xsl:if>
				<xsl:if test="count(./*) &gt;= 2">, <xsl:apply-templates select="./*[2]" mode="g:Keyword"/></xsl:if>
				<xsl:if test="count(./*) &gt;= 3">, <xsl:apply-templates select="./*[3]" mode="g:Keyword"/></xsl:if>
				<xsl:if test="count(./*) &gt;= 4">, <xsl:apply-templates select="./*[4]" mode="g:Keyword"/></xsl:if>
			</td>
		</tr>
	</xsl:template>
	<xsl:template match="g:Abilities | g:Cost | g:Bonus | g:Gender | g:Uses | g:Instruction | g:Text | g:Quote | g:Skills">
		<tr>
			<td>
				<xsl:value-of select="local-name()"/>:
			</td>
			<td>
				<xsl:apply-templates/>
			</td>
		</tr>
	</xsl:template>
	<xsl:template match="g:Attack | g:Defense | g:Movement | g:Charm | g:Energy">
		<xsl:value-of select="local-name()"/> = <xsl:apply-templates/><br/>
	</xsl:template>
	<xsl:template match="g:Skills/*">
		<xsl:apply-templates select="." mode="g:Keyword"/>
		<xsl:call-template name="value"><xsl:with-param name="value" select="."/></xsl:call-template>
		<xsl:if test="position() != last()"><br/></xsl:if>
	</xsl:template>
	<xsl:template match="g:Requirements">
		<tr>
			<td>
				Requirements:
			</td>
			<td class="requirements">
				<xsl:apply-templates select="g:Requirement[1]/*[1]"/>
				<xsl:if test="g:Requirement[1]/*[2]">
					&amp;
					<xsl:apply-templates select="g:Requirement[1]/*[2]"/>
					<xsl:if test="g:Requirement[1]/*[3]">
						&amp;
						<xsl:apply-templates select="g:Requirement[1]/*[3]"/>
						<xsl:if test="g:Requirement[1]/*[4]">
							&amp;
							<xsl:apply-templates select="g:Requirement[1]/*[4]"/>
						</xsl:if>
					</xsl:if>
				</xsl:if>
				<xsl:if test="g:Requirement[2]">
					<br/>
					<span class="or">
						or
					</span>
					<br/>
					<xsl:apply-templates select="g:Requirement[2]/*[1]"/>
					<xsl:if test="g:Requirement[2]/*[2]">
						&amp;
						<xsl:apply-templates select="g:Requirement[2]/*[2]"/>
						<xsl:if test="g:Requirement[2]/*[3]">
							&amp;
							<xsl:apply-templates select="g:Requirement[2]/*[3]"/>
							<xsl:if test="g:Requirement[2]/*[4]">
								&amp;
								<xsl:apply-templates select="g:Requirement[2]/*[4]"/>
							</xsl:if>
						</xsl:if>
					</xsl:if>
				</xsl:if>
				<xsl:if test="g:Requirement[3]">
					<br/>
					<span class="or">
						or
					</span>
					<br/>
					<xsl:apply-templates select="g:Requirement[3]/*[1]"/>
					<xsl:if test="g:Requirement[3]/*[2]">
						&amp;
						<xsl:apply-templates select="g:Requirement[3]/*[2]"/>
						<xsl:if test="g:Requirement[3]/*[3]">
							&amp;
							<xsl:apply-templates select="g:Requirement[3]/*[3]"/>
							<xsl:if test="g:Requirement[3]/*[4]">
								&amp;
								<xsl:apply-templates select="g:Requirement[3]/*[4]"/>
							</xsl:if>
						</xsl:if>
					</xsl:if>
				</xsl:if>
				<xsl:if test="g:Requirement[4]">
					<br/>
					<span class="or">
						or
					</span>
					<br/>
					<xsl:apply-templates select="g:Requirement[4]/*[1]"/>
					<xsl:if test="g:Requirement[4]/*[2]">
						&amp;
						<xsl:apply-templates select="g:Requirement[4]/*[2]"/>
							<xsl:if test="g:Requirement[4]/*[3]">
							&amp;
							<xsl:apply-templates select="g:Requirement[4]/*[3]"/>
							<xsl:if test="g:Requirement[4]/*[4]">
								&amp;
								<xsl:apply-templates select="g:Requirement[4]/*[4]"/>
							</xsl:if>
						</xsl:if>
					</xsl:if>
				</xsl:if>
			</td>
		</tr>
	</xsl:template>
	<xsl:template match="g:Requirement/*">
		<xsl:apply-templates select="." mode="g:Keyword"/>
		<xsl:call-template name="value">
			<xsl:with-param name="value" select="."/>
		</xsl:call-template>
	</xsl:template>
	<xsl:template match="g:Gender/*">
		<xsl:value-of select="local-name()"/>
	</xsl:template>
	<xsl:template match="g:line">
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template name="value">
		<xsl:param name="value"/>
		<xsl:choose>
			<xsl:when test="$value &gt; 1">
				<xsl:text> x</xsl:text><xsl:value-of select="$value"/>
			</xsl:when>
			<xsl:when test="$value &lt; 0">
				<xsl:text> </xsl:text><xsl:value-of select="$value"/>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
	<xsl:template match="*" mode="g:Keyword">
		<xsl:choose>
			<xsl:when test="name() = 'g:AirElement'">Air Element</xsl:when>
			<xsl:when test="name() = 'g:AnySkill'">*Any Skill</xsl:when>
			<xsl:when test="name() = 'g:AnyElement'">Any Element</xsl:when>
			<xsl:when test="name() = 'g:BlindLuck'">Blind Luck</xsl:when>
			<xsl:when test="name() = 'g:DarkTribe'">Dark Tribe</xsl:when>
			<xsl:when test="name() = 'g:FireElement'">Fire Element</xsl:when>
			<xsl:when test="name() = 'g:FlyingVehicle'">Flying Vehicle</xsl:when>
			<xsl:when test="name() = 'g:HalfSaiyan'">Half-Saiyan</xsl:when>
			<xsl:when test="name() = 'g:HandHeldWeapon'">Hand-held Weapon</xsl:when>
			<xsl:when test="name() = 'g:HotTub'">Hot Tub</xsl:when>
			<xsl:when test="name() = 'g:MartialArts'">Martial Arts</xsl:when>
			<xsl:when test="name() = 'g:Movement3'">Movement 3+</xsl:when>
			<xsl:when test="name() = 'g:Movement4'">Movement 4+</xsl:when>
			<xsl:when test="name() = 'g:NonFlyingVehicle'">Non-flying Vehicle</xsl:when>
			<xsl:when test="name() = 'g:PlanetaryVehicle'">Planetary Vehicle</xsl:when>
			<xsl:when test="name() = 'g:PureHeart'">Pure Heart</xsl:when>
			<xsl:when test="name() = 'g:SavoirFaire'">Savoir-Faire</xsl:when>
			<xsl:when test="name() = 'g:ShapeChange'">Shape Change</xsl:when>
			<xsl:when test="name() = 'g:Strength4'">Strength 4+</xsl:when>
			<xsl:when test="name() = 'g:WaterElement'">Water Element</xsl:when>
			<xsl:otherwise><xsl:value-of select="local-name()"/></xsl:otherwise>
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet>