<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:template match="/">
		<HTML>
			<head>
				<title>Visitor Usage Info</title>
			</head>
			<BODY style="background-color: LightBlue">
				<div style="font-size: 22pt; font-weight: bold">Library Average Use Statistics</div>
				<div style="font-size: 12pt; text-indent: 30px">
					<ul>
						<li><xsl:value-of select="sum(library_info/library/visitor_usage/open_day/visitors)"/> total 							visitors at all libraries each week</li>
						<li><xsl:value-of select="sum(library_info/library/visitor_usage/open_day/books_borrowed) + 							sum(library_info/library/visitor_usage/open_day/dvds_borrowed) + 							sum(library_info/library/visitor_usage/open_day/cds_borrowed)"/> items 							borrowed from all libraries each week</li>
					</ul>
				</div>
				<xsl:for-each select="library_info/library">
					<xsl:apply-templates select="library_name"/>
					<xsl:apply-templates select="visitor_usage"/>
				</xsl:for-each>
				
			</BODY>
		</HTML>
	</xsl:template>
	<xsl:template match="library_name">
		<p style="font-size: 16pt; font-weight: bold; text-decoration:underline">The <xsl:value-of select="."/> Visitor Statistics</p>
	</xsl:template>
	<xsl:template match="visitor_usage">
		<ul style="text-indent: 25">
			<li><xsl:value-of select="sum(open_day/visitors)"/> visitors each week</li>
		
			<li><xsl:value-of select="sum(open_day/books_borrowed) + sum(open_day/dvds_borrowed) + 				sum(open_day/cds_borrowed)"/> items borrowed each week</li>
		</ul>
		<div style="font-weight: bold; text-indent: 25px; font-size: 14pt">Average Daily Usage</div>
		<table style="display: table;border-collapse:collapse; border-width: thin; margin-left: 25px">
			<tr style="font-weight: bold">
				<td style="border-style: solid; border-width: thin">Day</td>
				<td style="border-style: solid; border-width: thin; text-align: center; padding-left: 5px; padding-right: 5px">Books Borrowed</td>
				<td style="border-style: solid; border-width: thin; text-align: center; padding-left: 5px; padding-right: 5px">DVDs Borrowed</td>
				<td style="border-style: solid; border-width: thin; text-align: center; padding-left: 5px; padding-right: 5px">CDs Borrowed</td>
			</tr>	
			<xsl:for-each select="open_day">
				<tr>
					<td style="border-style: solid; border-width: thin"><xsl:value-of select="day_name"/></td>
					<td style="border-style: solid; border-width: thin; text-align: center"><xsl:value-of select="books_borrowed"/></td>
					<td style="border-style: solid; border-width: thin; text-align: center"><xsl:value-of select="dvds_borrowed"/></td>
					<td style="border-style: solid; border-width: thin; text-align: center"><xsl:value-of select="cds_borrowed"/></td>
				</tr>
			</xsl:for-each>
			<tr style="font-weight: bold">
				<td style="border-style: solid; border-width: thin">Totals</td>
				<td style="border-style: solid; border-width: thin; text-align: center; padding-left: 5px; padding-right: 5px"><xsl:value-of 				select="sum(open_day/books_borrowed)"/></td>
				<td style="border-style: solid; border-width: thin; text-align: center; padding-left: 5px; padding-right: 5px"><xsl:value-of 				select="sum(open_day/dvds_borrowed)"/></td>
				<td style="border-style: solid; border-width: thin; text-align: center; padding-left: 5px; padding-right: 5px"><xsl:value-of 				select="sum(open_day/cds_borrowed)"/></td>
			</tr>
		</table><br/><br/>
	</xsl:template>
</xsl:stylesheet>