<?xml version="1.0"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

	<xsl:template match="/">
	
		<html><head><title>Gravitrams</title></head>
		<style type="text/css">
		body {color:#ccffcc;
			font-family:arial,sans-serif}
		table {border: thin dashed silver}
		td, h2 {color:#000066;
			background-color:#99cc99}
		td.title {color:#99cccc;
			background-color:#0066cc;
			font-weight:bold}
		</style>
		<body bgcolor="#ccffcc">
		
		<h2>Rolling Ball Machines - A Miscellany</h2>
		
		<xsl:for-each select="gravitrams/record">
	
			<table width="95%" cellpadding="7">
			<tr>
				<td rowspan="3" width="200"><xsl:apply-templates select="media/image"/></td>
				<td class="title"><xsl:value-of select="machine/machine_name"/></td></tr>
				<tr><td><p>Built in <xsl:value-of select="machine/build_year"/> by <xsl:value-of select="machine/artist"/> in <xsl:value-of select="machine/built_in"/>.</p>
					<p>
				  <xsl:if test="(count(specifications/width/*)+count(specifications/width/text()))>0">
				    <xsl:value-of select="specifications/width"/> wide by <xsl:value-of select="specifications/length"/> long by <xsl:value-of select="specifications/height"/> high, 
				  </xsl:if>
					<b><xsl:value-of select="specifications/number_balls"/> balls</b> travel through features such as a <xsl:value-of select="specifications/features"/>.</p>
				    <p><b>Currently located at </b> <xsl:value-of select="locations/current_location"/><br/>
					
			<xsl:if test="(count(locations/encounter_location/*)+count(locations/encounter_location/text()))>0">
				<b>First encountered at </b> <xsl:value-of select="locations/encounter_location"/> in <xsl:value-of select="locations/encounter_date"/>
			</xsl:if></p></td></tr>
			<tr>
				<td><xsl:apply-templates select="media/url[@type='machine']"/><br/>
				<xsl:apply-templates select="media/url[@type='artist']"/></td>
			</tr>
			</table>
			<br/>
	
		</xsl:for-each>
		
		</body>
		</html>
	
	</xsl:template>

	<xsl:template match="image">
	
		<img>
			<xsl:attribute name="src">images/<xsl:value-of select="./@src"/></xsl:attribute> 
			<xsl:attribute name="width">200</xsl:attribute> 
			<xsl:attribute name="height">300</xsl:attribute> 
		</img>
	
	</xsl:template>
	
	<xsl:template match="url[@type='machine']">
		
		<a>
		<xsl:attribute name="href"><xsl:value-of select="."/></xsl:attribute>The Machine</a>
		
	</xsl:template>
	
	
	<xsl:template match="url[@type='artist']">
		
		<a>
		<xsl:attribute name="href"><xsl:value-of select="."/></xsl:attribute>The Artist</a>
		
	</xsl:template>
	
</xsl:stylesheet>

