<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<html>
   <head>
	   <title>Books by Paul Auster</title>
<link rel="stylesheet" href="total.css" type="text/css"/>
   </head>
   <body>

<div id="container">

<xsl:for-each select="collection/book">

<xsl:sort select="title" /> 


<h2 >
Title: <span class="booktitle"><xsl:value-of select="title"/></span>
</h2>

<p>
<strong>Year of first publication::</strong> <xsl:value-of select="year/."/>
</p>

<p><strong>Publisher: </strong>
<xsl:value-of select="publisher/."/>
</p>
<p>
<strong>Note:</strong> <xsl:value-of select="note/."/>
</p>
<p>
<strong>Amazon URL:</strong> <a><xsl:attribute name="href"><xsl:value-of select="amazon/."/></xsl:attribute> 
<xsl:value-of select="amazon/."/></a>
</p>

<p>
<strong>Price at Amazon:</strong> 
<xsl:choose>
<xsl:when test="amazon/@price >10.40"> 
<span title="That's expensive" class="expense">
<xsl:value-of select="amazon/@price" />
</span> 
</xsl:when>
<xsl:otherwise> 
<xsl:value-of select="amazon/@price" />
</xsl:otherwise>
</xsl:choose>
</p>

</xsl:for-each>

<hr />
<div class="total"><strong>Total Cost of all listed books with prices:
<xsl:value-of select="sum(/collection/book/amazon/@price)" /></strong>  
</div>

</div>
</body>

</html>
</xsl:template>
</xsl:stylesheet>
