I still fits anchor to the individual election districts
let's
with a template I can not do anything because there is no attribute are to be found to this xml file
Code:
<xsl:variable name="redcell">
<td>
<xsl:value-of select="@red" />
</td>
</xsl:variable>
<xsl:variable name="bluecell">
<td>
<xsl:value-of select="@blue" />
</td>
</xsl:variable>
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN" doctype-system="_http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="/">
<html>
<style title="text/css">table {
border: 2px solid black;
width:60%
}
th,td{
border: 2px solid black;
}
tr{
text-align: right;
}
tr.head{
background-color:#ff0000;
}
tr.tot{
background-color:#0000ff;
}
tr.odd{
background-color:#ff9900;
}
tr.even{
background-color:#ff0099;
}
.num{
width:30%
}
.pro{
width:30%
}</style>
<head>
<title>Election Night Results</title>
</head>
<body>
<a name="top"></a>
<div id="intro">
<p>
<img src="logo.jpg" alt="Election Day Results"/>
</p>
<a href="#">Election Home Page</a>
<a href="#">President</a>
<a href="#">Senate Races</a>
<a href="#">Congressional Races</a>
<a href="#">State Senate</a>
<a href="#">State House</a>
<a href="#">Local Races</a>
<a href="#">Judicial</a>
<a href="#">Referendums</a>
</div>
<div id="results">
<h1>Congressional Races</h1>
<xsl:apply-templates select="polls/race" mode="href"/>
<xsl:apply-templates select="polls/race"/>
</div>
</body>
</html>
</xsl:template>
<xsl:template match="race">
<xsl:variable name="sum" select="sum(.//votes)"/>
<h2>
<a name="{title}">
<xsl:value-of select="title"/>
</a>
<a href="#top"> Top</a>
</h2>
<table cellpadding="1" cellspacing="1">
<tr class="head">
<th>Candidate</th>
<th class="num">Votes</th>
<th class="pos">Procent</th>
</tr>
<xsl:apply-templates select="candidate">
<xsl:with-param name="sum" select="$sum"/>
</xsl:apply-templates>
<tr class="tot">
<td>total</td>
<td>
<xsl:value-of select="$sum"/>
</td>
<td> </td>
</tr>
</table>
</xsl:template>
<xsl:template match="candidate">
<xsl:param name="sum"/>
<tr>
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="position() mod 2 =0">
<xsl:text>even</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>odd</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<td class="name">
<xsl:value-of select="name"/>(<xsl:value-of select="party"/>)</td>
<td class="num">
<xsl:value-of select="format-number(votes, '#,##0')"/>
</td>
<td class="pro">
<xsl:value-of select="format-number(votes div $sum, '#0.000%')"/>
</td>
</tr>
</xsl:template>
<xsl:template match="race" mode="href">
<p>
<a href="#{title}">
goto <xsl:value-of select="title"/>
</a>
</p>
</xsl:template>
</xsl:stylesheet>
result
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "_http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<style title="text/css">table {
border: 2px solid black;
width:60%
}
th,td{
border: 2px solid black;
}
tr{
text-align: right;
}
tr.head{
background-color:#ff0000;
}
tr.tot{
background-color:#0000ff;
}
tr.odd{
background-color:#ff9900;
}
tr.even{
background-color:#ff0099;
}
.num{
width:30%
}
.pro{
width:30%
}
</style>
<head>
<meta http-equiv="Content-Type" content="text/html">
<title>Election Night Results</title>
</head>
<body>
<a name="top"></a>
<div id="intro">
<p>
<img src="logo.jpg" alt="Election Day Results">
</p>
<a href="#">Election Home Page</a>
<a href="#">President</a>
<a href="#">Senate Races</a>
<a href="#">Congressional Races</a>
<a href="#">State Senate</a>
<a href="#">State House</a>
<a href="#">Local Races</a>
<a href="#">Judicial</a>
<a href="#">Referendums</a>
</div>
<div id="results">
<h1>Congressional Races</h1>
<p>
<a href="#1st Congressional District">
goto 1st Congressional District
</a>
</p>
<p>
<a href="#2nd Congressional District">
goto 2nd Congressional District
</a>
</p>
<p>
<a href="#3rd Congressional District">
goto 3rd Congressional District
</a>
</p>
<p>
<a href="#4th Congressional District">
goto 4th Congressional District
</a>
</p>
<p>
<a href="#5th Congressional District">
goto 5th Congressional District
</a>
</p>
<h2>
<a name="1st Congressional District">1st Congressional District</a>
<a href="#top"> Top</a>
</h2>
<table cellpadding="1" cellspacing="1">
<tr class="head">
<th>Candidate</th>
<th class="num">Votes</th>
<th class="pos">Procent</th>
</tr>
<tr class="odd">
<td class="name">Sarah Carlson(D)</td>
<td class="num">45,125</td>
<td class="pro">47.617%</td>
</tr>
<tr class="even">
<td class="name">Pete deJesus(R)</td>
<td class="num">44,498</td>
<td class="pro">46.956%</td>
</tr>
<tr class="odd">
<td class="name">Alan Tompkins(I)</td>
<td class="num">5,143</td>
<td class="pro">5.427%</td>
</tr>
<tr class="tot">
<td>total</td>
<td>94766</td>
<td> </td>
</tr>
</table>
<h2>
<a name="2nd Congressional District">2nd Congressional District</a>
<a href="#top"> Top</a>
</h2>
<table cellpadding="1" cellspacing="1">
<tr class="head">
<th>Candidate</th>
<th class="num">Votes</th>
<th class="pos">Procent</th>
</tr>
<tr class="odd">
<td class="name">Gary Griffin(D)</td>
<td class="num">69,505</td>
<td class="pro">41.188%</td>
</tr>
<tr class="even">
<td class="name">Frank Brown(R)</td>
<td class="num">78,133</td>
<td class="pro">46.301%</td>
</tr>
<tr class="odd">
<td class="name">Roland Washington(G)</td>
<td class="num">8,109</td>
<td class="pro">4.805%</td>
</tr>
<tr class="even">
<td class="name">Karen Reese(L)</td>
<td class="num">13,004</td>
<td class="pro">7.706%</td>
</tr>
<tr class="tot">
<td>total</td>
<td>168751</td>
<td> </td>
</tr>
</table>
<h2>
<a name="3rd Congressional District">3rd Congressional District</a>
<a href="#top"> Top</a>
</h2>
<table cellpadding="1" cellspacing="1">
<tr class="head">
<th>Candidate</th>
<th class="num">Votes</th>
<th class="pos">Procent</th>
</tr>
<tr class="odd">
<td class="name">Anne Sanchez(D)</td>
<td class="num">65,203</td>
<td class="pro">55.972%</td>
</tr>
<tr class="even">
<td class="name">Cynthia Thomas(R)</td>
<td class="num">51,289</td>
<td class="pro">44.028%</td>
</tr>
<tr class="tot">
<td>total</td>
<td>116492</td>
<td> </td>
</tr>
</table>
<h2>
<a name="4th Congressional District">4th Congressional District</a>
<a href="#top"> Top</a>
</h2>
<table cellpadding="1" cellspacing="1">
<tr class="head">
<th>Candidate</th>
<th class="num">Votes</th>
<th class="pos">Procent</th>
</tr>
<tr class="odd">
<td class="name">Jerry Wilkes(D)</td>
<td class="num">49,201</td>
<td class="pro">44.120%</td>
</tr>
<tr class="even">
<td class="name">Barry Mitchell(R)</td>
<td class="num">58,414</td>
<td class="pro">52.382%</td>
</tr>
<tr class="odd">
<td class="name">Paula Wellton(I)</td>
<td class="num">3,901</td>
<td class="pro">3.498%</td>
</tr>
<tr class="tot">
<td>total</td>
<td>111516</td>
<td> </td>
</tr>
</table>
<h2>
<a name="5th Congressional District">5th Congressional District</a>
<a href="#top"> Top</a>
</h2>
<table cellpadding="1" cellspacing="1">
<tr class="head">
<th>Candidate</th>
<th class="num">Votes</th>
<th class="pos">Procent</th>
</tr>
<tr class="odd">
<td class="name">Pete Grimbold(D)</td>
<td class="num">42,105</td>
<td class="pro">48.477%</td>
</tr>
<tr class="even">
<td class="name">Carol Ives(R)</td>
<td class="num">43,349</td>
<td class="pro">49.910%</td>
</tr>
<tr class="odd">
<td class="name">Michael Dorn(G)</td>
<td class="num">1,401</td>
<td class="pro">1.613%</td>
</tr>
<tr class="tot">
<td>total</td>
<td>86855</td>
<td> </td>
</tr>
</table>
</div>
</body>
</html>
Bookmarks