See other News & Comment articles from xslt variable assignment.
The problem is that variables are immutable in xslt After setting it is not possible to change it So you assign citizenTotal 0 Although you make another assignment of variable with the same name in foreach you are in fact declaring a new variable in scope of that cycle of loop
11 What is XSLT This specification defines the syntax and semantics of the XSLT 20 language The term stylesheet reflects the fact that one of the important roles of XSLT is to add styling information to an XML source document by transforming it into a document consisting of XSL formatting
See xslt to operate on element value before displaying for the original XML and XSL I got an answer to my question there My other question on this same XMLXSL is if I would like to capture the value of an element such as the title element in an XSL local variable and then operate on it how do I capture that value and assign it to a
This specification defines the syntax and semantics of XSLT which is a language for transforming XML documents into other XML documents XSLT is designed for use as part of XSL which is a stylesheet language for XML In addition to XSLT XSL includes an XML vocabulary for specifying formatting