<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:exslt="urn:schemas-microsoft-com:xslt" >
	<xsl:output method="html" encoding="ISO-8859-1" indent="yes"/>
<xsl:template match="/">
	<p>This is an analysis of Leibbrandts no longer alive for whom we have accurate birth and death dates, with a calculated age-at-death.</p>
	<p>First, a summary count by age group.</p>
	<table>
		<tr>
			<th>90's+</th><th>80's</th><th>70's</th><th>60's</th><th>50's</th><th>40's</th><th>30's</th><th>20's</th><th>teens</th><th>infants</th>
		</tr>
		<tr>
			<td><xsl:value-of select="count(persons/person[number(@age)>89])"/></td>
			<td><xsl:value-of select="count(persons/person[number(@age)>79 and number(@age)&lt;90])"/></td>
			<td><xsl:value-of select="count(persons/person[number(@age)>69 and number(@age)&lt;80])"/></td>
			<td><xsl:value-of select="count(persons/person[number(@age)>59 and number(@age)&lt;70])"/></td>
			<td><xsl:value-of select="count(persons/person[number(@age)>49 and number(@age)&lt;60])"/></td>
			<td><xsl:value-of select="count(persons/person[number(@age)>39 and number(@age)&lt;50])"/></td>
			<td><xsl:value-of select="count(persons/person[number(@age)>29 and number(@age)&lt;40])"/></td>
			<td><xsl:value-of select="count(persons/person[number(@age)>19 and number(@age)&lt;30])"/></td>
			<td><xsl:value-of select="count(persons/person[number(@age)>9 and number(@age)&lt;20])"/></td>
			<td><xsl:value-of select="count(persons/person[number(@age)&lt;10])"/></td>
		</tr>
	</table>

	<p>Here they are listed in descending order of age.</p>
	
	<table>
		<tr>
			<th>Rank</th><th>Name</th><th>ID</th><th>Lived</th><th>Gender</th><th>Age *</th>
		</tr>
		<xsl:for-each select="persons/person">
			<xsl:sort select="@age" order="descending" data-type="number"/>
			<xsl:sort select="@id"/>
			<tr><td><xsl:value-of select="position()"/></td><td><a class="big"><xsl:attribute name="href">Descendants.asp?id=<xsl:value-of select="@id"/></xsl:attribute>
	<xsl:value-of select="."/></a></td><td><xsl:value-of select="@id"/></td><td><xsl:value-of select="@born"/>-<xsl:value-of select="@died"/></td><td><xsl:value-of select="@sex"/></td><td><xsl:value-of select="@age"/></td></tr>
		</xsl:for-each>
	</table>
	<p>*Note: Calculated ages might be one year out as it is calculated using year only.  E.g. Born 01 Jan 1900, died 31 Dec 1900 is calculated as 0 years even though it is only 1 day short of a year, but born 29 Dec 1900, died 03 Jan 1901 is calculated as 1 year, even though it is only a few days. </p>
</xsl:template>

</xsl:stylesheet>

