<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:fn="http://www.w3.org/2005/02/xpath-function">

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

<xsl:template match="books">
	<html>
		<head>
			<link rel="stylesheet" type="text/css" href="schizo.css"/>
			<title>Book Log -- Adam Chlipala</title>
		</head>

		<body>
			<center><img src="img/log.png" alt="Book Log" width="389" height="158"/></center>
			<br/>

			<div class="summary">
				Here's a log of the books I've read since late 2003. <a href="books.html">More organized ratings of authors and books</a> are on another page, and you can skip to its entries for individual books by clicking on the <img src="img/entry.png"/> icons next to the entries here.
			</div>

			<div class="project">
				<xsl:for-each select="//readingNow | //rereadingNow">
					<p><b><i>Reading now</i></b>: <i>
					<xsl:choose>
						<xsl:when test="../url">
							<a href="{../url}"><xsl:value-of select="../@title"/></a>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="../@title"/>
						</xsl:otherwise>
					</xsl:choose></i>, <xsl:choose>
						<xsl:when test="../../url">
							<a href="{../../url}"><xsl:value-of select="../../@name"/></a>
						</xsl:when>
        					<xsl:when test="../../markedup">
	        					<xsl:apply-templates select="../../markedup"/>
		        			</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="../../@name"/>
						</xsl:otherwise>
					</xsl:choose></p>
				</xsl:for-each>
			<xsl:for-each select="//log">
				<xsl:sort select="../@date" order="descending"/>
				<a name="{../@title}">
				<table><tr><td><img src="img/{../@rating}.png" alt="{../@rating}"/></td>
				<td><xsl:value-of select="../@date"/>: <i><xsl:choose>
					<xsl:when test="../url">
						<a href="{../url}"><xsl:value-of select="../@title"/></a>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="../@title"/>
					</xsl:otherwise>
				</xsl:choose></i>, <xsl:choose>
					<xsl:when test="../../url">
						<a href="{../../url}"><xsl:value-of select="../../@name"/></a>
					</xsl:when>
					<xsl:when test="../../markedup">
						<xsl:apply-templates select="../../markedup"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="../../@name"/>
					</xsl:otherwise>
				</xsl:choose>:
				<xsl:apply-templates />
				<xsl:variable name="thisBook" select=".."/>
				<xsl:for-each select="ancestor::ranking">
					<a href="books.html#{$thisBook/@title}"><img border="0" src="img/entry.png"/></a>
				</xsl:for-each>
				<xsl:for-each select="ancestor::nonfiction">
					<a href="books.html#{$thisBook/@title}"><img border="0" src="img/entry.png"/></a>
				</xsl:for-each>
				</td></tr></table>
				</a>
			</xsl:for-each></div>

			<div class="summary">
				<b><u>Geek Corner</u></b>: This page is generated using XSLT. <a href="xml/">See how</a>.
			</div>
		</body>
	</html>
</xsl:template>

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

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

<xsl:template match="a">
	<a href="{@href}"><xsl:apply-templates /></a>
</xsl:template>

</xsl:stylesheet>
