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

for-each loops: arithmetic functions

Subject: for-each loops: arithmetic functions
From: "Mazza, Glen" <glen.mazza@xxxxxxx>
Date: Tue, 2 Jan 2001 17:40:03 -0500
xsl arithmetic operators
Pardon the newbie question (I couldn't find an answer in the archives), but
I am trying to use arithmetic operators in the XSL for-each loops.  For
example, assume the following sample XML:

<libraries>
	<library>
		<name>City Library</name>
		<booksOverdue>124</booksOverdue>
		<totalDaysOverdue>696</totalDaysOverdue>
		<finePerDay>0.10</finePerDay>
	</library>
	<library>
		<name>Branch Library #1</name>
		<booksOverdue>53</booksOverdue>
		<totalDaysOverdue>116</totalDaysOverdue>
		<finePerDay>0.15</finePerDay>
	</library>
	<library>
		<name>Branch Library #2</name>
		<booksOverdue>73</booksOverdue>
		<totalDaysOverdue>310</totalDaysOverdue>
		<finePerDay>0.20</finePerDay>
	</library>
</libraries>

It is trivial to output the values in a listing:

<xsl:for-each select="libraries/library">
Name:		<xsl:value-of select="name"/><BR/>
# books overdue: <xsl:value-of select="booksOverdue"/><BR/>
total days overdue: <xsl:value-of select="totalDaysOverdue"/><BR/>
fine per day: 	<xsl:value-of select="finePerDay"/><BR/>
</xsl:for-each>

But I would like the average days overdue for each book (=
booksOverdue/totalDaysOverdue), , not the total.
I also would like to display the total fines collected, not the fines per
day:  (=finePerDay * totalDaysOverdue).

However, XSL doesn't appear to let me use these statements:

average days overdue: 	<xsl:value-of select="totalDaysOverdue" div
select="finePerDay"/><BR/>
total $ collected: 	<xsl:value-of select="finePerDay" *
select="totalDaysOverdue"/><BR/>

I possibly have the syntax wrong.  This appears to be a very simple problem,
but I can't seem to find the answer anywhere.

Thanks for your help,

Glen Mazza
* E-Mail:  glen.mazza@xxxxxxx



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


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.