Playing around in order to learn XSLT, I have the following XML file and XSLT stylesheet. I want to produce a list of the players ranked after the score 3*goals + 2*assists.
<?xml-stylesheet type="text/xsl" href="player_ranking.xsl"?>
<soccer xmlns="http://mysoccer.it">
<players>
<player>
<name>Pelé</name>
<goals>21</goals>
<assists>9</assists>
</player>
<player>
<name>Beckenbauer</name>
<goals>7</goals>
<assists>18</assists>
</player>
<player>
<name>Spiderman</name>
<goals>27</goals>
<assists>38</assists>
</player>
<player>
<name>Hagi</name>
<goals>13</goals>
<assists>14</assists>
</player>
<player>
<name>Laudrup</name>
<goals>11</goals>
<assists>25</assists>
</player>
<player>
<name>Gullit</name>
<goals>17</goals>
<assists>15</assists>
</player>
</players>
</soccer>
Style sheet
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soc="http://mysoccer.it"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:template match="soc:soccer">
<html>
<head>
<title>Famous players ranked</title>
</head>
<body>
<h1>Overall ranking</h1>
<xsl:apply-templates match="soc:players"/>
</body>
</html>
</xsl:template>
<xsl:template match="soc:players">
<xsl:apply-templates select="soc:player">
<xsl:sort select="soc:goals * 3 + 2 * soc:assists" order="descending"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="soc:player">
<xsl:value-of select="soc:name"/>
with score
<xsl:value-of select="soc:goals * 3 + 2 * soc:assists"/>
<br/>
</xsl:template>
</xsl:stylesheet>
In a browser (tried with both Opera and Firefox) it produces
Overall ranking
Laudrup with score 83
Pelé with score 81
Gullit with score 81
Hagi with score 67
Beckenbauer with score 57
Spiderman with score 157
Spiderman should appear on top of the list. Can someone point out my error ?
I have used version="2.0" in the style sheet as using version="1.0" gives me Error loading stylesheet: Parsing an XSLT stylesheet failed.