[xsl] Accumulating Sum

Subject: [xsl] Accumulating Sum
From: "KUMAR NINGASHETTY" <kningashetty@xxxxxxxxxxxxxxxx>
Date: Tue, 02 Apr 2002 14:15:52 -0500
HI, 

Sample XML
―----------------------

<data>
<company>
 	<vehicle id="768">
		<region id="204">
			<region_name><![CDATA[Region 4]]></region_name>
		</region>
		<company_name><![CDATA[ABC Inc.]]></company_name>
		<status><![CDATA[t]]></status>
	</vehicle>
	<vehicle id="232">
		<region id="204">
			<region_name><![CDATA[Region 4]]></region_name>
		</region>
		<company_name><![CDATA[BBC Inc.]]></company_name>
		<status><![CDATA[f]]></status>
	</vehicle>
</company>

<review>
	<vehicle idref="768">
		<count type="N"><![CDATA[1]]></review_count>
		<count type="U"><![CDATA[2]]></review_count>
		<count type="Y"><![CDATA[3]]></review_count>
	</vehicle>
	<vehicle idref="232">
		<count type="N"><![CDATA[4]]></count>
		<count type="U"><![CDATA[5]]></count>
		<count type="Y"><![CDATA[6]]></count>
	</vehicle>
</review>
</data>

―-----------------------------------------

HTML O/P should look lilke follows after applying XSL
―-----------------------------------------------------------------------------------
 
Region 4

       Comp        stat	  typN    Total
        -----	-        -----	  ----        -----
      ABCInc        t	   1	5 
      BBCInc        f	   4	5	

Problem :  I could populate first 3 columns..To populate the 4th column 'Total' which is sum frm each row of column 'typeN'
	

Detailed Explanation in case :
I have put together a sample XML above and the html output it should look like ...
I have used xsl:key and have grouped by regions to get the first 4 columns data  and it works fine .. I have problem getting the 4 th column which is Total which  is total from all the rows under column typeN.....This is huge XML data and i have just put together to rows of XML data onto html .  My problem is to get the Total  and printing it on the Total column.  I have tough  time accumulating the average sum inspite if using recursive methods...Let me know if anyone has any ways...

Thanx in advance ...

- kumar





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


Current Thread