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

RE: for-each loops : calculations outside the loop, us

Subject: RE: for-each loops : calculations outside the loop, using data from inside
From: "Kenny Akridge" <kenny@xxxxxxxxxxxxxxxxx>
Date: Wed, 21 Apr 2004 00:54:40 -0400
xsl calculations
My advice is to use a recursive template.  Take a look at this for help on
recursion if you need it:

http://www-106.ibm.com/developerworks/xml/library/x-xslrecur/

Also, not sure if it applies, but make sure you account for a StartTime of
2200 and an end time of 0400.  This would give you -1800.  In this case, add
2400 to 0400 and then subtract the 2200 = 600.  

-----Original Message-----
From: Chris Freeman [mailto:chris.freeman@xxxxxxxxxxxxxxx] 
Sent: Wednesday, April 21, 2004 12:39 AM
To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
Subject:  for-each loops : calculations outside the loop, using data
from inside

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.