It really should be that easy, but unfortunately it isn't.
In xslt you can't change a variable once it is declared. I did something similar to what you are describing above a couple of years ago by calling a template with a parameter but I can't find the code.
add a value to a container/variable
Hello.
i need to get the total number from several documents.
Lets imagine i have like 4 documents and each of these container a property called AmountJobs.
First doc, AmountJobs: 2.
Second doc, AmountJobs: 1
Third doc, AmountJobs: 4
Fourth doc, AmountJobs: 1
The total number of AmountJobs from all documents is: 8.
How can i get that number?
<xsl:variable name="amountJobs" select="0" />
<xsl:for-each select="*">
<xsl:variable name="amountJobs" select="$amountJobs + number(AmountJobs)" />
</xsl:for-each>
<xsl:value-of select="$amountJobs" />
This is the code i have, but i cant do that. I cant use a variable.
Hi Mathias,
You use the sum() function for that, e.g. to get the amount of jobs for the current page and its siblings:
/Chriztian
It really should be that easy, but unfortunately it isn't.
In xslt you can't change a variable once it is declared. I did something similar to what you are describing above a couple of years ago by calling a template with a parameter but I can't find the code.
Is using Razor an option?
Or just do it the way Chriztian describes ;)
Thanks Chriztian, nice one and it worked perfectly
is working on a reply...