I have a XML with several accounts and I'm trying to make the sum of several scores with the format score/max_score.
XML:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="accounts.xsl"?>
<accounts>
<account active="yes">
<id>1</id>
<name>James</name>
<score>50/100</score>
</account>
<account active="yes">
<id>2</id>
<name>Caty</name>
<score>10/100</score>
</account>
<account active="yes">
<id>3</id>
<name>Acacia</name>
<score>30/100</score>
</account>
<account active="yes">
<id>4</id>
<name>James</name>
<score>50/100</score>
</account>
<account active="yes">
<id>5</id>
<name>Scoot_5</name>
<score>40/100</score>
</account>
</accounts>
And XSLT:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/">
<html>
<body>
<p>
<xsl:value-of select="sum(//accounts/account/score/number(substring-before(.,'/')))"/>
</p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
However when I run the xml says it has error and does not return the sum. Why?