Xsl sum() <traffic> of <users> with the same name

Fricti0n

New Member
I'm beginner in xsl.
I need to calculate sum traffic of users with same name (name NOT "name" + "last name"), for example calculate sum of traffic of all users with name "Jonh". And xsl version should be only 1.0.
I found a topic with the same problem \[quote\] http://social.msdn.microsoft.com/Forums/eu/xmlandnetfx/thread/c9f09ba6-1c79-43df-bbc2-3966710fff23\[/quote\]I was try to use that: \[code\]<span>Total: <xsl:value-of select="sum(//user[contains(name,'Jonh')]../traffic)" /></span>\[/code\]or \[code\]<span>Total: <xsl:value-of select="sum(//user[contains(name,'Jonh')]/traffic)" /></span>\[/code\]but there is no effect. It does not calculate the sum.Can anyone help me to find a solution.XML FILE\[code\]<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet type='text/xsl' href='http://stackoverflow.com/questions/11535452/traffic.xsl'?><root> <user> <name>Jonh Connor</name> <traffic>800</traffic> </user> <user> <name>John Kennedy</name> <traffic>200</traffic> </user> <user> <name>Jack London</name> <traffic>100</traffic> </user> <user> <name>Sema Schlumberger</name> <traffic>300</traffic> </user> <user> <name>Jack Vorobey</name> <traffic>700</traffic> </user> <user> <name>John Lennon</name> <traffic>500</traffic> </user> <user> <name>John Romero</name> <traffic>4003</traffic> </user></root>\[/code\]
 
Back
Top