I'm having trouble grouping a set of nodes.
I've found an article that does work with grouping and i have tested it and it works on a small test stylesheet i have
I now need to use it in my stylesheet where I only want to select node sets that have a specific value.
What I want to do in my stylesheet is select all users who have a userlevel of 2 then to
group them by
the volunteer region.
What happens at
the minute is that it gets
the right amount of users with userlevel 2 but doesn't print them. It just repeats
the first user in
the xml file.
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="volunteers-by-region" match="volunteer" use="region" />
<xsl:template name="hoo" match="/">
<html>
<head>
<title>Registered Volunteers</title>
<link rel="stylesheet" type="text/css" href="volunteer.css" />
</head>
<body>
<h1>Registered Volunteers</h1>
<h3>Ordered by
the username ascending</h3>
<xsl:for-each select="folktask/member[user/account/userlevel='2']">
<xsl:for-each select="volunteer[count(. | key('volunteers-by-region', region)[1]) = 1]">
<xsl:sort select="region" />
<xsl:for-each select="key('volunteers-by-region', region)">
<xsl:sort select="folktask/member/user/personal/name" />
<div class="userdiv">
<xsl:call-template name="member_userid">
<xsl:with-param name="myid" select="/folktask/member/user/@id" />
</xsl:call-template>
<xsl:call-template name="volunteer_volid">
<xsl:with-param name="volid" select="/folktask/member/volunteer/@id" />
</xsl:call-template>
<xsl:call-template name="volunteer_role">
<xsl:with-param name="volrole" select="/folktask/member/volunteer/roles" />
</xsl:call-template>
<xsl:call-template name="volunteer_region">
<xsl:with-param name="volloc" select="/folktask/member/volunteer/region" />
</xsl:call-template>
</div>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
<xsl:if test="position()=last()">
<div class="count"><h2>Total number of volunteers: <xsl:value-of select="count(/folktask/member/user/account/userlevel[text()=2])"/></h2></div>
</xsl:if>
</body>
</html>
</xsl:template>
<xsl:template name="member_userid">
<xsl:param name="myid" select="'Not Available'" />
<div class="heading bold"><h2>USER ID: <xsl:value-of select="$myid" /></h2></div>
</xsl:template>
<xsl:template name="volunteer_volid">
<xsl:param name="volid" select="'Not Available'" />
<div class="heading2 bold"><h2>VOLUNTEER ID: <xsl:value-of select="$volid" /></h2></div>
</xsl:template>
<xsl:template name="volunteer_role">
<xsl:param name="volrole" select="'Not Available'" />
<div class="small bold">ROLES:</div>
<div class="large">
<xsl:choose>
<xsl:when test="string-length($volrole)!=0">
<xsl:value-of select="$volrole" />
</xsl:when>
<xsl:otherwise>
<xsl:text> </xsl:text>
</xsl:otherwise>
</xsl:choose>
</div>
</xsl:template>
<xsl:template name="volunteer_region">
<xsl:param name="volloc" select="'Not Available'" />
<div class="small bold">REGION:</div>
<div class="large"><xsl:value-of select="$volloc" /></div>
</xsl:template>
</xsl:stylesheet>
here is my full xml file
<?xml version="1.0" encoding="ISO-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="volunteers.xsl"?>
<folktask xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="folktask.xsd">
<member>
<user id="1">
<personal>
<name>Abbie Hunt</name>
<sex>Female</sex>
<address1>108 Access Road</address1>
<address2></address2>
<city>Wells</city>
<county>Somerset</county>
<postcode>BA5 8GH</postcode>
<telephone>01528927616</telephone>
<mobile>07085252492</mobile>
<email>
[email protected]</email>
</personal>
<account>
<username>AdRock</username>
<password>269eb625e2f0cf6fae9a29434c12a89f</password>
<userlevel>4</userlevel>
<signupdate>2010-03-26T09:23:50</signupdate>
</account>
</user>
<volunteer id="1">
<roles></roles>
<region>South West</region>
</volunteer>
</member>
<member>
<user id="2">
<personal>
<name>Aidan Harris</name>
<sex>Male</sex>
<address1>103 Aiken Street</address1>
<address2></address2>
<city>Chichester</city>
<county>Sussex</county>
<postcode>PO19 4DS</postcode>
<telephone>01905149894</telephone>
<mobile>07784467941</mobile>
<email>
[email protected]</email>
</personal>
<account>
<username>AmbientExpert</username>
<password>8e64214160e9dd14ae2a6d9f700004a6</password>
<userlevel>2</userlevel>
<signupdate>2010-03-26T09:23:50</signupdate>
</account>
</user>
<volunteer id="2">
<roles>Van Driver,gas Fitter</roles>
<region>South Central</region>
</volunteer>
</member>
<member>
<user id="3">
<personal>
<name>Skye Saunders</name>
<sex>Female</sex>
<address1>31 Anns Court</address1>
<address2></address2>
<city>Cirencester</city>
<county>Gloucestershire</county>
<postcode>GL7 1JG</postcode>
<telephone>01958303514</telephone>
<mobile>07260491667</mobile>
<email>
[email protected]</email>
</personal>
<account>
<username>BigUndecided</username>
<password>ea297847f80e046ca24a8621f4068594</password>
<userlevel>2</userlevel>
<signupdate>2010-03-26T09:23:50</signupdate>
</account>
</user>
<volunteer id="3">
<roles>Scaffold Erector</roles>
<region>South West</region>
</volunteer>
</member>
<member>
<user id="4">
<personal>
<name>Connor Lawson</name>
<sex>Male</sex>
<address1>12 Ash Way</address1>
<address2></address2>
<city>Swindon</city>
<county>Wiltshire</county>
<postcode>SN3 6GS</postcode>
<telephone>01791928119</telephone>
<mobile>07338695664</mobile>
<email>
[email protected]</email>
</personal>
<account>
<username>iTuneStinker</username>
<password>3a1f5fda21a07bfff20c41272bae7192</password>
<userlevel>3</userlevel>
<signupdate>2010-03-26T09:23:50</signupdate>
</account>
</user>
<festival id="1">
<event>
<eventname>Oxford Folk Festival</eventname>
<url>http://www.oxfordfolkfestival.com/</url>
<datefrom>2010-04-07</datefrom>
<dateto>2010-04-09</dateto>
<location>Oxford</location>
<eventpostcode>OX1 9BE</eventpostcode>
<additional>Oxford Folk Festival is going into it's third year in 2006. As well as needing volunteers to steward for
the event on
the weekend itself, we would be delighted to hear from people willing to help in year round festival work such as stuffing envelopes for mailings, poster and leaflet distribution, and stewarding duties at festival pre-events.</additional>
<coords>
<lat>51.735640</lat>
<lng>-1.276136</lng>
</coords>
</event>
<contact>
<conname>Stuart Vincent</conname>
<conaddress1>P.O. Box 642</conaddress1>
<conaddress2></conaddress2>
<concity>Oxford</concity>
<concounty>Bedfordshire</concounty>
<conpostcode>OX1 3BY</conpostcode>
<contelephone>01865 79073</contelephone>
<conmobile></conmobile>
<fax></fax>
<conemail>
[email protected]</conemail>
</contact>
</festival>
</member>
<member>
<user id="5">
<personal>
<name>Lewis King</name>
<sex>Male</sex>
<address1>67 Arbors Way</address1>
<address2></address2>
<city>Sherborne</city>
<county>Dorset</county>
<postcode>DT9 0GS</postcode>
<telephone>01446139701</telephone>
<mobile>07292614033</mobile>
<email>
[email protected]</email>
</personal>
<account>
<username>Runninglife</username>
<password>98fab0a27c34ddb2b0618bc184d4331d</password>
<userlevel>2</userlevel>
<signupdate>2010-03-26T09:23:50</signupdate>
</account>
</user>
<volunteer id="4">
<roles>Van Driver</roles>
<region>South West</region>
</volunteer>
</member>
<member>
<user id="6">
<personal>
<name>Cameron Lee</name>
<sex>Male</sex>
<address1>77 Arrington Road</address1>
<address2></address2>
<city>Solihull</city>
<county>Warwickshire</county>
<postcode>B90 6FG</postcode>
<telephone>01435158624</telephone>
<mobile>07789503179</mobile>
<email>
[email protected]</email>
</personal>
<account>
<username>love2Mixer</username>
<password>1df752d54876928639cea07ce036a9c0</password>
<userlevel>2</userlevel>
<signupdate>2010-03-26T09:23:50</signupdate>
</account>
</user>
<volunteer id="5">
<roles>Fire Warden</roles>
<region>Midlands</region>
</volunteer>
</member>
<member>
<user id="7">
<personal>
<name>Lexie Dean</name>
<sex>Female</sex>
<address1>38 Bloomfield Court</address1>
<address2></address2>
<city>Windermere</city>
<county>Westmorland</county>
<postcode>LA23 8BM</postcode>
<telephone>01781207188</telephone>
<mobile>07127461231</mobile>
<email>
[email protected]</email>
</personal>
<account>
<username>MailNetworker</username>
<password>0e070701839e612bf46af4421db4f44b</password>
<userlevel>3</userlevel>
<signupdate>2010-03-26T09:23:50</signupdate>
</account>
</user>
<festival id="2">
<event>
<eventname>Middlewich Folk And Boat Festival</eventname>
<url>http://midfest.org.uk/mfab/</url>
<datefrom>2010-06-16</datefrom>
<dateto>2010-06-18</dateto>
<location>Middlewich</location>
<eventpostcode>CW10 9BX</eventpostcode>
<additional>We welcome stewards staying on campsite or boats.</additional>
<coords>
<lat>53.190562</lat>
<lng>-2.444926</lng>
</coords>
</event>
<contact>
<conname>Festival Committee</conname>
<conaddress1>PO Box 141</conaddress1>
<conaddress2></conaddress2>
<concity>Winsford</concity>
<concounty>Cheshire</concounty>
<conpostcode>CW10 9WB</conpostcode>
<contelephone>07092 39050</contelephone>
<conmobile>07092 39050</conmobile>
<fax></fax>
<conemail>
[email protected]</conemail>
</contact>
</festival>
</member>
<member>
<user id="8">
<personal>
<name>Liam Chapman</name>
<sex>Male</sex>
<address1>99 Black Water Drive</address1>
<address2></address2>
<city>St.Austell</city>
<county>Cornwall</county>
<postcode>PL25 3GF</postcode>
<telephone>01835629418</telephone>
<mobile>07695179069</mobile>
<email>
[email protected]</email>
</personal>
<account>
<username>GreenWimp</username>
<password>1fe3df99a841dc4f723d21af89e0990f</password>
<userlevel>1</userlevel>
<signupdate>2010-03-26T09:23:50</signupdate>
</account>
</user>
</member>
<member>
<user id="9">
<personal>
<name>Brandon Harrison</name>
<sex>Male</sex>
<address1>41 Arlington Way</address1>
<address2></address2>
<city>Dorchester</city>
<county>Dorset</county>
<postcode>DT1 3JS</postcode>
<telephone>01293626735</telephone>
<mobile>07277145760</mobile>
<email>
[email protected]</email>
</personal>
<account>
<username>LovelyStar</username>
<password>8b53b66f323aa5e6a083edb4fd44456b</password>
<userlevel>1</userlevel>
<signupdate>2010-03-26T09:23:50</signupdate>
</account>
</user>
</member>
<member>
<user id="10">
<personal>
<name>Samuel Young</name>
<sex>Male</sex>
<address1>102 Bailey Hill Road</address1>
<address2></address2>
<city>Wolverhampton</city>
<county>Staffordshire</county>
<postcode>WV7 8HS</postcode>
<telephone>01594531382</telephone>
<mobile>07544663654</mobile>
<email>
[email protected]</email>
</personal>
<account>
<username>GuruSassy</username>
<password>00da02da6c143c3d136bf60b8bfcf43e</password>
<userlevel>2</userlevel>
<signupdate>2010-03-26T09:23:50</signupdate>
</account>
</user>
<volunteer id="6">
<roles>Fire Warden</roles>
<region>Midlands</region>
</volunteer>
</member>
<member>
<user id="11">
<personal>
<name>Alexander Harris</name>
<sex>Male</sex>
<address1>93 Beguine Drive</address1>
<address2></address2>
<city>Winchester</city>
<county>Hampshire</county>
<postcode>S23 2FD</postcode>
<telephone>01452496582</telephone>
<mobile>07353867291</mobile>
<email>
[email protected]</email>
</personal>
<account>
<username>GuitarExpert</username>
<password>0102ad3740028e155925e9918ead3bde</password>
<userlevel>2</userlevel>
<signupdate>2010-03-26T09:23:50</signupdate>
</account>
</user>
<volunteer id="7">
<roles>Scaffold Erector</roles>
<region>North East</region>
</volunteer>
</member>
<member>
<user id="12">
<personal>
<name>Tyler Mcdonald</name>
<sex>Male</sex>
<address1>44 Baker Road</address1>
<address2></address2>
<city>Bromley</city>
<county>Kent</county>
<postcode>BR1 2GD</postcode>
<telephone>01918704546</telephone>
<mobile>07314062451</mobile>
<email>
[email protected]</email>
</personal>
<account>
<username>WildWish</username>
<password>073220bb5e9a12ad202bb7d94dcc86f7</password>
<userlevel>1</userlevel>
<signupdate>2010-03-26T09:23:50</signupdate>
</account>
</user>
</member>
<member>
<user id="13">
<personal>
<name>Skye Mason</name>
<sex>Female</sex>
<address1>56 Cedar Creek Church Road</address1>
<address2></address2>
<city>Bracknell</city>
<county>Berkshire</county>
<postcode>RG12 1AQ</postcode>
<telephone>01787607618</telephone>
<mobile>07540218868</mobile>
<email>
[email protected]</email>
</personal>
<account>
<username>PizzaDork</username>
<password>74c54937ee7051ee7f4ebc11296ed531</password>
<userlevel>1</userlevel>
<signupdate>2010-03-26T09:23:50</signupdate>
</account>
</user>
</member>
<member>
<user id="14">
<personal>
<name>Maryam Rose</name>
<sex>Female</sex>
<address1>98 Baptist Circle</address1>
<address2></address2>
<city>Newbury</city>
<county>Berkshire</county>
<postcode>RG14 8DF</postcode>
<telephone>01691317999</telephone>
<mobile>07212477154</mobile>
<email>
[email protected]</email>
</personal>
<account>
<username>SexTech</username>
<password>f1c21f9f1e999da97d7dc460bb876fcf</password>
<userlevel>3</userlevel>
<signupdate>2010-03-26T09:23:50</signupdate>
</account>
</user>
<festival id="3">
<event>
<eventname>Birdsedge Village Festival</eventname>
<url>http://www.birdsedge.co.uk/</url>
<datefrom>2010-07-08</datefrom>
<dateto>2010-07-09</dateto>
<location>Birdsedge</location>
<eventpostcode>HD8 8XT</eventpostcode>
<additional></additional>
<coords>
<lat>53.565644</lat>
<lng>-1.696196</lng>
</coords>
</event>
<contact>
<conname>Jacey Bedford</conname>
<conaddress1>Penistone Road</conaddress1>
<conaddress2>Birdsedge</conaddress2>
<concity>Huddersfield</concity>
<concounty>West Yorkshire</concounty>
<conpostcode>HD8 8XT</conpostcode>
<contelephone>01484 60623</contelephone>
<conmobile></conmobile>
<fax></fax>
<conemail>
[email protected]</conemail>
</contact>
</festival>
</member>
<member>
<user id="15">
<personal>
<name>Lexie Rogers</name>
<sex>Female</sex>
<address1>38 Bishop Road</address1>
<address2></address2>
<city>Matlock</city>
<county>Derbyshire</county>
<postcode>DE4 1BX</postcode>
<telephone>01961168823</telephone>
<mobile>07170855351</mobile>
<email>
[email protected]</email>
</personal>
<account>
<username>ShipBurglar</username>
<password>cc190488a95667cb117e20bc6c7c330e</password>
<userlevel>2</userlevel>
<signupdate>2010-03-26T09:23:50</signupdate>
</account>
</user>
<volunteer id="8">
<roles>Gas Fitter</roles>
<region>Midlands</region>
</volunteer>
</member>
<member>
<user id="16">
<personal>
<name>Noah Parker</name>
<sex>Male</sex>
<address1>112 Canty Road</address1>
<address2></address2>
<city>Keswick</city>
<county>Cumberland</county>
<postcode>CA12 4TR</postcode>
<telephone>01931272522</telephone>
<mobile>07610026576</mobile>
<email>
[email protected]</email>
</personal>
<account>
<username>AwsomeMoon</username>
<password>50b770539bdf08543f15778fc7a6f188</password>
<userlevel>2</userlevel>
<signupdate>2010-03-26T09:23:50</signupdate>
</account>
</user>
<volunteer id="9">
<roles>Van Driver</roles>
<region>North West</region>
</volunteer>
</member>
<member>
<user id="17">
<personal>
<name>Elliot Mitchell</name>
<sex>Male</sex>
<address1>102 Brown Loop</address1>
<address2></address2>
<city>Grimsby</city>
<county>Lincolnshire</county>
<postcode>OX16 4QP</postcode>
<telephone>01212971319</telephone>
<mobile>07544663654</mobile>
<email>
[email protected]</email>
</personal>
<account>
<username>msBasher</username>
<password>c38fad85badcdff6e3559ef38656305d</password>
<userlevel>1</userlevel>
<signupdate>2010-03-26T09:23:50</signupdate>
</account>
</user>
</member>
<member>
<user id="18">
<personal>
<name>Scarlett Rose</name>
<sex>Female</sex>
<address1>93 Cedar Lane</address1>
<address2></address2>
<city>Stourbridge</city>
<county>Warminster</county>
<postcode>DY8 4NX</postcode>
<telephone>01537477435</telephone>
<mobile>07353867291</mobile>
<email>
[email protected]</email>
</personal>
<account>
<username>MakeupWimp</username>
<password>16a9b7910fc34304c1d1a6a1b0c31502</password>
<userlevel>1</userlevel>
<signupdate>2010-03-26T09:23:50</signupdate>
</account>
</user>
</member>
<member>
<user id="19">
<personal>
<name>Katie Butler</name>
<sex>Female</sex>
<address1>44 Boulder Crest Road</address1>
<address2></address2>
<city>Bungay</city>
<county>Suffolk</county>
<postcode>NR35 1LT</postcode>
<telephone>01419124094</telephone>
<mobile>07314062451</mobile>
<email>
[email protected]</email>
</personal>
<account>
<username>TomatoCrunch</username>
<password>d7eba53443ec4ddcee69ed71b2023fc0</password>
<userlevel>1</userlevel>
<signupdate>2010-03-26T09:23:50</signupdate>
</account>
</user>
</member>
<member>
<user id="20">
<personal>
<name>Jayden Richards</name>
<sex>Male</sex>
<address1>56 Corson Trail</address1>
<address2></address2>
<city>Sandy</city>
<county>Bedfordshire</county>
<postcode>SG19 6DF</postcode>
<telephone>01882134438</telephone>
<mobile>07540218868</mobile>
<email>
[email protected]</email>
</personal>
<account>
<username>nightmareTwig</username>
<password>8a9c08c7b6473493e8a5da15dd541025</password>
<userlevel>3</userlevel>
<signupdate>2010-03-26T09:23:50</signupdate>
</account>
</user>
<festival id="4">
<event>
<eventname>East Barnet Festival</eventname>
<url>http://www.eastbarnetfestival.org.uk</url>
<datefrom>2010-07-01</datefrom>
<dateto>2010-07-03</dateto>
<location>East Barnet</location>
<eventpostcode>EN4 8TB</eventpostcode>
<additional></additional>
<coords>
<lat>51.641556</lat>
<lng>-0.163018</lng>
</coords>
</event>
<contact>
<conname>East Barnet Festival Commitee</conname>
<conaddress1>Oak Hill Park</conaddress1>
<conaddress2>Church Hill Road</conaddress2>
<concity>East Barnet</concity>
<concounty>Hertfordshire</concounty>
<conpostcode>EN4 8TB</conpostcode>
<contelephone>07071781745</contelephone>
<conmobile>07071781745</conmobile>
<fax></fax>
<conemail>
[email protected]</conemail>
</contact>
</festival>
</member>
<member>
<user id="21">
<personal>
<name>Abbie Jackson</name>
<sex>Female</sex>
<address1>98 Briarwood Lane</address1>
<address2></address2>
<city>Weymouth</city>
<county>Dorset</county>
<postcode>DT3 6TS</postcode>
<telephone>01575629969</telephone>
<mobile>07212477154</mobile>
<email>
[email protected]</email>
</personal>
<account>
<username>CrazyBlockhead</username>
<password>4ce56fb13d043be605037ace4fbd9fa5</password>
<userlevel>2</u