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

	<xsl:output
		method="html"
		/>	 
			
	<xsl:template match="/*">
		<html>
			<head>
				<title>GovTrack.us Raw Statistics - <xsl:value-of select="name()"/></title>
			</head>
			
			<body>
				<h1>GovTrack.us Raw Statistics - &lt;<xsl:value-of select="name()"/>&gt;</h1>
			
				<p>This page contains raw statistics generated by GovTrack.us.  Please consult <a href="http://www.GovTrack.us/congress/repstats.xpd">www.GovTrack.us/congress/repstats.xpd</a> for more information about this file.</p>
				
				<p>These statistics are in an XML format file so they can be easily imported into other applications or used in other projects.  This page is an XML file which has been rendered for presentation by a stylesheet.  Saving this file to disk will record the raw XML data, and not this HTML presentation.</p>
			
				<table cellpadding="3">
				<tr><th colspan="2">Summary</th></tr>
				<tr><td>N</td> <td><xsl:value-of select="count(*)"/></td></tr>
				<tr><td>Mean</td> <td><xsl:value-of select="@mean"/></td><td>(outliers removed)</td></tr>
				<tr><td>Standard Deviation</td> <td><xsl:value-of select="@stddev"/></td></tr>
				</table>
				
				<hr/>

				<table cellpadding="3">
				<tr><th colspan="2">Key</th></tr>
				<xsl:for-each select="representative[position()=1]/@*[not(name()='id' or name()='stat-z' or name()='stat-pctile')]">
					<tr valign="top">
					<td><xsl:value-of select="name()"/></td>
					<xsl:variable name="n" select="name()"/>
					<td><xsl:value-of select="/*/@*[name()=concat($n, '-Desc')]"/>
						<xsl:if test="/*/@key = name()">
						This is the column for which the mean and standard deviation (above)
						and z-score (stat-z below) are calculated, and on which the table is sorted.
						</xsl:if>
					</td>
					</tr>
				</xsl:for-each>
				<tr><td>stat-z</td><td>This column gives the z-score of the individual for the highlighted column.</td></tr>
				<tr><td>stat-pctile</td><td>This column gives the percentile of the individual for the highlighted column.</td></tr>
				</table>
				
				<hr/>
				
				<table cellpadding="3">
				<tr>
					<xsl:for-each select="representative[position()=1]/@*">
						<th><xsl:value-of select="name()"/></th>
					</xsl:for-each>
				</tr>
				
				<xsl:for-each select="representative">
					<xsl:variable name="this" select="."/>
				
					<tr>
						<xsl:for-each select="@*">
							<td>
								<xsl:if test="name() = /*/@key">
									<xsl:attribute name="style">
										background-color: #EEEEFF;
									</xsl:attribute>
								</xsl:if>
								<xsl:value-of select="."/>
							</td>
						</xsl:for-each>
					</tr>
				</xsl:for-each>
				
				</table>
			</body>
		</html>
	</xsl:template>
</xsl:stylesheet>

