Subject: [xsl] for-each loops: arithmetic functions From: "Mazza, Glen" <glen.mazza@xxxxxxx> Date: Tue, 2 Jan 2001 17:40:03 -0500 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Theoretical question, Mike Brown | Thread | Re: [xsl] for-each loops: arithmet, Mike Brown |
RE: [xsl] Specifying element associ, Evan Lenz | Date | Re: [xsl] Theoretical question, Mike Brown |
Month |