old-website/xsl/books.xsl

64 lines
2.2 KiB
XML

<?xml version='1.0'?>
<xsl:stylesheet version="2.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:csc="http://www.csclub.uwaterloo.ca/xslt">
<xsl:template match="all-books">
<p>The books we currently own include:</p>
<table>
<tr>
<th>Title</th>
<th>Author</th>
</tr>
<xsl:for-each select="document(concat($g_root, '/books.xml'))/booklist/book">
<xsl:variable name="class">
<xsl:choose>
<xsl:when test="position() mod 2 = 0">books1</xsl:when>
<xsl:otherwise>books2</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<tr class="{$class}" >
<td>
<a href="{$pre}office/books/{translate(@isbn, ' ', '_')}.html">
<xsl:value-of select="@title" />
<xsl:if test="@edition != ''">
(<xsl:value-of select="@edition" />)
</xsl:if>
</a>
</td>
<td>
<xsl:value-of select="@author" />
</td>
</tr>
<xsl:result-document method="xml" encoding="ISO-8859-1"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
href="{translate(concat($g_root, '/office/books/', @isbn, '.html'), ' ', '_')}">
<html>
<head>
<title>Book: <xsl:value-of select="@title" /></title>
<link rel="stylesheet" href="{$pre}default.css" type="text/css" />
</head>
<body><div>
<xsl:call-template name="header" />
<p>
<b>Title: </b> <xsl:value-of select="@title" /><br />
<b>Edition: </b> <xsl:value-of select="@edition" /><br />
<b>ISBN: </b> <xsl:value-of select="@isbn" /><br />
<b>Author: </b> <xsl:value-of select="@author" /><br />
<b>Published: </b> <xsl:value-of select="@published" /><br />
</p>
<xsl:call-template name="footer" />
</div></body>
</html>
</xsl:result-document>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>