<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL] xmlns:fo="[URL unfurl="true"]http://www.w3.org/1999/XSL/Format">[/URL]
<xsl:param name="sortYear"/>
<xsl:template match="/">
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] xml:lang="en-us">
<head>
<title>Invoices</title>
<style type="text/css"><![CDATA[ ]]></style>
<script type="text/javascript"><![CDATA[
function updateHistory() {
var xslStylesheet;
var xsltProcessor = new XSLTProcessor();
var myDOM;
var xmlDoc;
var selectBox = document.forms[0].y;
var newyear = selectBox.options[selectBox.selectedIndex].value;
alert(newyear);
//set sort by year parameter
xsltProcessor.setParameter(null, "sortYear", newyear);
// load the xslt file
var myXMLHTTPRequest = new XMLHttpRequest();
myXMLHTTPRequest.open("GET", "invoices.xsl", false);
myXMLHTTPRequest.send(null);
xslStylesheet = myXMLHTTPRequest.responseXML;
xsltProcessor.importStylesheet(xslStylesheet);
// load the xml file
myXMLHTTPRequest = new XMLHttpRequest();
myXMLHTTPRequest.open("GET", "myInvoices.xml", false);
myXMLHTTPRequest.send(null);
xmlDoc = myXMLHTTPRequest.responseXML;
var fragment = xsltProcessor.transformToFragment(xmlDoc, document);
return true;
}
]]></script>
</head>
<body>
<h1>My Invoices</h1>
[ code removed ]
<h2>History</h2>
<form id="selectyear" onsubmit="updateHistory()">
<label for="y">Tax Year: </label>
<select id="y" name="y">
<option></option>
<xsl:for-each select="//tax-year/@year">
<xsl:sort select="." order="descending"/>
<option>
<xsl:value-of select="."/>
</option>
</xsl:for-each>
</select>
<input type="submit" value="View"/>
</form>
[ code removed ]
</body>
</html>
</xsl:template>
</xsl:stylesheet>