[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

for-each loops : calculations outside the loop, using

Subject: for-each loops : calculations outside the loop, using data from i nside
From: Chris Freeman <chris.freeman@xxxxxxxxxxxxxxx>
Date: Wed, 21 Apr 2004 14:39:17 +1000
xsl loops
I'm sure this will be simple for a more experienced xsl coder. I've removed
the bulk of my code, leaving only the relevant parts.  (removed code
designated by --- )

I want to add a number from each "for-each" run-thru, to a total that will
be displayed once the loop has completed. Can't find the solution anywhere! 
See comments in code below! 

Cheers :) 


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="ptimetable">
		<html>
	--- 
	<xsl:for-each select="class">
	--- 
		<td>
			<xsl:value-of select="time/timestart"/>
		</td>
		<td>
			<xsl:value-of select="time/timeend"/> <!-- Time in
24 hour clock-->

			<xsl:variable name="temp_length"> 
			<xsl:value-of
select="(number(time/timeend)-number(time/timestart)) * 0.6"/> <!-- Calc the
time, convert to minutes-->
			</xsl:variable> 				
		</td> 
	--- 
	</xsl:for-each> <!-- end of the loop -->
	</table>

	The total time of all classes is : <xsl:variable name="cum_total"/>
<!-- How do i calculate cumulative total from data in the loop?

	<!--- HERE - I WANT TO DISPLAY THE TOTAL TIME OF ALL LISTED
"subject"s--> 
	<!--- EACH TIME THE temp_length IS CALCULATED, I NEED TO ADD IT TO A
CUMULATIVE TOTAL, PRESUMABLY OUTSIDE THE LOOP! -->
	<!--- HELP! --> 
 
		</html>
	</xsl:template>
</xsl:stylesheet>

Chris Freeman
Tolhurst Noall
29/35 Collins Street, Melbourne
03 9242 4021

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.