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

<xsl:template match="/">
	<xsl:variable name="document" select="document(/azureus_server/text())"/>
	<html>
		<head>
		<title>Azureus statistics</title>
		</head>
		<xsl:apply-templates select="$document/STATS/GLOBAL"/>
		<xsl:apply-templates select="$document/STATS/DOWNLOADS"/>
	</html>
</xsl:template>

<xsl:template match="GLOBAL">
	<h1>
		<p>Azureus <xsl:value-of select="../AZUREUS_VERSION"/> statistics</p>
	</h1>
	<p>Global rates :</p>
	<ul>
		<li>download : <xsl:value-of select="DOWNLOAD_SPEED/TEXT"/></li>
		<li>upload   : <xsl:value-of select="UPLOAD_SPEED/TEXT"/></li>
	</ul>
</xsl:template>

<xsl:template match="DOWNLOADS">
	<table align="left" border="1" width="100%">
		<thead>
			<th>Name</th>
			<th>Size</th>
			<th>Status</th>
			<th>% Done</th>
			<th>Share ratio</th>
			<th>DL</th>
			<th>DL speed</th>
			<th>UL</th>
			<th>UL speed</th>
		</thead>
		<xsl:apply-templates select="DOWNLOAD"/>
	</table>
</xsl:template>

<xsl:template match="DOWNLOAD">
<xsl:variable name="temp" select="COMPLETED"/>
<xsl:variable name="percentDone" select="$temp div 10"/>
<xsl:variable name="temp2" select = "SHARE_RATIO"/>
<xsl:variable name="ratio" select="$temp2 div 1000"/>
	<xsl:element name="tr">
		<xsl:choose>
			<xsl:when test="DOWNLOAD_STATUS='Seeding'">
				<xsl:attribute name="bgcolor">#99CCFF</xsl:attribute>
			</xsl:when>
			<xsl:when test="DOWNLOAD_STATUS='Downloading'">
				<xsl:attribute name="bgcolor">#99FFCC</xsl:attribute>
			</xsl:when>
			<xsl:otherwise>
				<xsl:attribute name="bgcolor">#CCCCFF</xsl:attribute>
			</xsl:otherwise>
		</xsl:choose>
			<td><xsl:value-of select="TORRENT/NAME"/></td>
			<td><xsl:value-of select="TORRENT/SIZE/TEXT"/></td>
			<td><xsl:value-of select="DOWNLOAD_STATUS"/></td>
		<xsl:choose>
			<xsl:when test="DOWNLOAD_STATUS='Ready'">
			<td/>
			<td/>
			<td/>
			<td/>
			<td/>
			<td/>
		</xsl:when>
			<xsl:otherwise>
			<td><xsl:value-of select="$percentDone"/></td>
			<td><xsl:value-of select="$ratio"/></td>
			<td><xsl:value-of select="DOWNLOADED/TEXT"/></td>
			<td><xsl:value-of select="DOWNLOAD_SPEED/TEXT"/></td>
			<td><xsl:value-of select="UPLOADED/TEXT"/></td>
			<td><xsl:value-of select="UPLOAD_SPEED/TEXT"/></td>
		</xsl:otherwise>
		</xsl:choose>
	</xsl:element>
</xsl:template>

</xsl:stylesheet><!-- Stylus Studio meta-information - (c)1998-2002 eXcelon Corp.
<metaInformation>
<scenarios ><scenario default="yes" name="Scenario1" userelativepaths="yes" externalpreview="yes" url="azureus.cocoon.xml" htmlbaseurl="" processortype="msxml" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext=""/></scenarios><MapperInfo srcSchemaPath="" srcSchemaRoot="" srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>
</metaInformation>
-->