[xsl] Summing multiple attributes

Subject: [xsl] Summing multiple attributes
From: "Muse, Mike" <Mike.Muse@xxxxxxxxxx>
Date: Wed, 31 Jul 2002 11:48:38 -0500
> Hi all,
> 
> I created a table based on the XML below, that has the following columns:
> item, color, count, unitcost and sub-total (count*unitcost).  The part I'm
> having a problem with is calculating the total (i.e. sum of all sub-totals
> in a table, for a member) for the table.   I have put a subset of the XML
> below as well as a sample of what the output should look like.  The part I
> can't get is the last line of the sample output.  
> 
> I have been trying to use a recursive named template, but to no avail.  I
> have found several examples of summing one element or attribute using the
> sum method.  However, when I try to sum the product of count*unitcost, I
> get an error because the result is not a nodeset.  
> 
> Any help would be appreciated.  
> 
> XML:
> <?xml version="1.0"?>
> <?xml-stylesheet type="text/xsl" href="demo.xsl"?>
> </members>
> 	<member level="gold">
> 		<name>john smith</name>
> 		<phone type="home">555-5457</phone>
> 		<phone type="work">445-8524</phone>
> 		<phone type="cell">897-4684</phone>
> 		<street>124 pulse</street>
> 		<city>new york</city>
> 		<state>ny</state>
> 		<zip>05644</zip>
> 		<items>
> 			<item title="shirt" color="Purple" count="2"
> unitcost="24.95"/>
> 			<item title="sport socks" color="white" count="2"
> unitcost="12.95"/>
> 		</items>
> 	</member>
> 	. . .
> </members>
> 
> Sample Output:
> Item		Color	Count	UnitCost	SubTotal
> shirt		Purple	2	24.95		49.90
> sport socks	white	2	12.95		24.90
> Total						74.80
> 
> Mike Muse
> mike.muse@xxxxxxxxxx


******************************************************************
This email and any files transmitted with it from the ElPaso 
Corporation are confidential and intended solely for the 
use of the individual or entity to whom they are addressed. 
If you have received this email in error please notify the 
sender.
******************************************************************

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread