[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] for-each loops: arithmetic functions
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|