XSL: Using Calculated values in further calculations

Whisushiskbok

New Member
The following is a shortened example of my code.I want to calculate the average target_value of each entry in a group (or gid)In a simple pseudocode this would be written in the following way:\[code\]total target_value of entries with gid "001" / amount of entries with gid "001"\[/code\]However, since XML is fairly new to me, I wish to know how to reuse the values already calculated (see the XSL below) for further calculations?Is variables the most effective way to go, and if so, where/how should they be defined?XML:\[code\]<root> <entry gid ="001"> <level_1> <target_value>50</target_value> </level_1> </entry> <entry gid ="001"> <level_1> <target_value>30</target_value> </level_1> </entry></root>\[/code\]XSL:\[code\]<xsl:value-of select="sum(entry[@gid='001']/level_1/target_value)" />\[/code\]Result:80Any help would be greatly appriciated!
 
Back
Top