XSL using apply templates and match instead of call template
- by AdRock
I am trying to make the transition from using call-template to using applay templates and match but i'm not getting any data displayed only what is between the volunteer tags.
When i use call template it works fine but it was suggested that i use applay-templates and match and not it doesn't work
Any ideas how to make this work? I can then applay it to all my stylesheets.
<?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>
<h3>Grouped by the region</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:apply-templates/>
<!--<xsl:call-template name="member_userid">
<xsl:with-param name="myid" select="../user/@id" />
</xsl:call-template>
<xsl:call-template name="member_name">
<xsl:with-param name="myname" select="../user/personal/name" />
</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 match="folktask/member">
<xsl:apply-templates select="user/@id"/>
<xsl:apply-templates select="user/personal/name"/>
</xsl:template>
<xsl:template match="user/@id">
<div class="heading bold"><h2>USER ID: <xsl:value-of select="." /></h2></div>
</xsl:template>
<xsl:template match="user/personal/name">
<div class="small bold">NAME:</div>
<div class="large"><xsl:value-of select="." /></div>
</xsl:template>
</xsl:stylesheet>
and my xml file
<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</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>
</folktask>