Hello!
I have an XML file with the names of players.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<doc>
<data number="1" type="x">herbert</data>
<data number="2">joe</data>
<data number="3">jean-jacques</data>
</doc>
With the following XSLT file I want to initialize each player with a random numeric value und send it to the output. The last line should contain the sum of all initial values.
Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:variable name="seed" select="2"/>
<html>
<body>
<table border="1">
<tr>
<th>Name</th>
<th>Inital Value</th>
</tr>
<xsl:for-each select="/doc/data">
<tr>
<td>
<xsl:value-of select="."/>
</td>
<td>
<xsl:value-of select="substring(substring-after($seed div (position()*string-length ()), '.'),2, 3)"/>
</td>
</tr>
</xsl:for-each>
<tr>
<td>sum</td>
<td>????</td> >
</tr>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="*|@*|text()">
</xsl:template>
</xsl:stylesheet>
The output should look like this
<html>
<body>
<table border="1">
<tr><td>herbert</td><td>857</td></tr>
<tr><td>joe</td><td>333</td></tr>
<tr><td>jean-jacques</td><td>555</td></tr>
<tr><td>Sum</td><td>1745</td></tr>
</table>
</body>
</html>
How can I calculate the sum of the random numbers
Thanks for help
herpes