just started studying xslt.just want to know how would count the number of international based players? Another thing is the average height of he international players?
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="soccer.xslt"?>
<footballclub>
<player>
<based>international</based>
<height>5.5</height >
<build>medium</build>
<age>24</age>
</player>
<player>
<based>local</based>
<height>5.5</height >
<build>medium</build>
<age>24</age>
</player>
<player>
<based>international</based>
<height>5.5</height >
<build>medium</build>
<age>24</age>
</player>
<player>
<based>local</based>
<height>5.5</height >
<build>medium</build>
<age>24</age>
</player>
</footballclub>
have tried the following;
count(//football/player/based[not(following::based='international')]) xslt:
<?xml version='1.0' encoding="utf-8"?>
<xsl:stylesheet version='1.0' xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="4.0" />
<xsl:template match="/">
<html>
<head >
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>bombers FC</title>
</head>
<body>
NUMBER OF INTERNATIONAL PLAYERS IS:<xsl:value-of select="count(//football/player/based[not(following::based='international')])"/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
the results should read : NUMBER OF INTERNATIONAL PLAYERS IS: 2
Your XPath needs to change a little...
XML Input (corrected to be well formed)
XSLT 1.0
Output