<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/WD-xsl">

<!-- Root template -->
<xsl:template match="/">
	<html>
		<head>
			<title>Node Statistics</title>
			<link href="StatsReport.css" type="text/css" rel="stylesheet"/>
		</head>
		<body>
			<xsl:apply-templates select="StatsReport"/>
		</body>
	</html>
</xsl:template>

<!-- StatsReport template -->
<xsl:template match="StatsReport"><xsl:apply-templates select="NodeStatistics"/></xsl:template>

<!-- StatsReport/NodeStatistics template -->
<xsl:template match="NodeStatistics">
	<h1>Node Statistics</h1>
	<xsl:apply-templates select="Summary"/>
	<table class="tbl">
		<thead>
			<tr>
				<th class="hl">Node</th>
				<th class="hc" style="width:200px;">Percentage</th>
				<th class="hl">&#160;</th>
				<th class="hr">%</th>
				<th class="hr">Bytes</th>
				<th class="hr">Packets</th>
			</tr>
		</thead>
		<tbody>
			<xsl:apply-templates select="Stats"/>
		</tbody>
	</table>
</xsl:template>

<!-- StatsReport/NodeStatistics/Summary template -->
<xsl:template match="Summary">
	<table border="0">
		<tr>
			<td class="bg"><b>Time Saved:</b></td>
			<td class="bg"><xsl:apply-templates select="TimeSaved"/></td>
		</tr>
		<tr>
			<td class="bg"><b>Total Packets:</b></td>
			<td class="bg"><xsl:apply-templates select="Packets"/></td>
		</tr>
		<tr>
			<td class="bg"><b>Total Bytes:</b></td>
			<td class="bg"><xsl:apply-templates select="Bytes"/></td>
		</tr>
		<tr>
			<td class="bg"><b>Nodes:</b></td>
			<td class="bg"><xsl:apply-templates select="NodeCount"/></td>
		</tr>
	</table>
</xsl:template>

<!-- StatsReport/NodeStatistics/Summary/TimeSaved template -->
<xsl:template match="TimeSaved"><xsl:eval>formatDate(this.nodeTypedValue, "MMMM dd',' yyyy")</xsl:eval> <xsl:eval>formatTime(this.nodeTypedValue, "hh:mm tt")</xsl:eval></xsl:template>

<!-- StatsReport/NodeStatistics/Summary/Packets template -->
<xsl:template match="Packets"><xsl:eval>formatNumber(this.nodeTypedValue, "#,###,###,##0")</xsl:eval></xsl:template>

<!-- StatsReport/NodeStatistics/Summary/Bytes template -->
<xsl:template match="Bytes"><xsl:eval>formatNumber(this.nodeTypedValue, "#,###,###,##0")</xsl:eval></xsl:template>

<!-- StatsReport/NodeStatistics/Summary/NodeCount template -->
<xsl:template match="NodeCount"><xsl:eval>formatNumber(this.nodeTypedValue, "#,###,###,##0")</xsl:eval></xsl:template>

<!-- StatsReport/NodeStatistics/Stats template -->
<xsl:template match="Stats"><xsl:apply-templates select="NodeStat"/></xsl:template>

<!-- StatsReport/NodeStatistics/Stats/PhysNodeStat template -->
<xsl:template match="NodeStat">
	<tr>
		<td class="rl" style="color:#000000" rowspan="2"><tt><font><xsl:attribute name="color"><xsl:value-of select="Color"/></xsl:attribute><xsl:value-of select="Addr"/></font></tt></td>
		<td class="rl" colspan="1"><img src="RedBar.gif" height="11" alt="Sent %"><xsl:attribute name="width"><xsl:eval>formatNumber(this.selectSingleNode("BytesOut").nodeTypedValue / this.selectSingleNode("/StatsReport/NodeStatistics/Summary/Bytes").nodeTypedValue, "##0%")</xsl:eval></xsl:attribute></img></td>
		<td class="rl" colspan="1"><img src="RightArrow.gif" height="11" alt="Sent"/></td>
		<td class="rr"><xsl:eval>formatNumber(this.selectSingleNode("BytesOut").nodeTypedValue / this.selectSingleNode("/StatsReport/NodeStatistics/Summary/Bytes").nodeTypedValue, "##0.000%")</xsl:eval></td>
		<td class="rr"><xsl:apply-templates select="BytesOut"/></td>
		<td class="rr"><xsl:apply-templates select="PktsOut"/></td>
	</tr>
	<tr>
		<td class="rl" colspan="1"><img src="BlueBar.gif" height="11" alt="Received %"><xsl:attribute name="width"><xsl:eval>formatNumber(this.selectSingleNode("BytesIn").nodeTypedValue / this.selectSingleNode("/StatsReport/NodeStatistics/Summary/Bytes").nodeTypedValue, "##0%")</xsl:eval></xsl:attribute></img></td>
		<td class="rl" colspan="1"><img src="LeftArrow.gif" height="11" alt="Received"/></td>
		<td class="rr"><xsl:eval>formatNumber(this.selectSingleNode("BytesIn").nodeTypedValue / this.selectSingleNode("/StatsReport/NodeStatistics/Summary/Bytes").nodeTypedValue, "##0.000%")</xsl:eval></td>
		<td class="rr"><xsl:apply-templates select="BytesIn"/></td>
		<td class="rr"><xsl:apply-templates select="PktsIn"/></td>
	</tr>
	<xsl:apply-templates select="NodeStat"/>
</xsl:template>

<!-- StatsReport/NodeStatistics/Stats/PhysNodeStat/BytesOut template -->
<xsl:template match="BytesOut"><xsl:eval>formatNumber(this.nodeTypedValue, "#,###,###,##0")</xsl:eval></xsl:template>

<!-- StatsReport/NodeStatistics/Stats/PhysNodeStat/PktsOut template -->
<xsl:template match="PktsOut"><xsl:eval>formatNumber(this.nodeTypedValue, "#,###,###,##0")</xsl:eval></xsl:template>

<!-- StatsReport/NodeStatistics/Stats/PhysNodeStat/BytesIn template -->
<xsl:template match="BytesIn"><xsl:eval>formatNumber(this.nodeTypedValue, "#,###,###,##0")</xsl:eval></xsl:template>

<!-- StatsReport/NodeStatistics/Stats/PhysNodeStat/PktsIn template -->
<xsl:template match="PktsIn"><xsl:eval>formatNumber(this.nodeTypedValue, "#,###,###,##0")</xsl:eval></xsl:template>

</xsl:stylesheet>
