This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Re: for-each loops: arithmetic functions
- To: xsl-list at lists dot mulberrytech dot com
- Subject: RE: Re: [xsl] for-each loops: arithmetic functions
- From: "Mazza, Glen" <glen dot mazza at eds dot com>
- Date: Wed, 3 Jan 2001 11:43:53 -0500
- Reply-To: xsl-list at lists dot mulberrytech dot com
>
> Date: Tue, 2 Jan 2001 16:21:09 -0700 (MST)
> From: Mike Brown <mike@skew.org>
> Subject: Re: [xsl] for-each loops: arithmetic functions
>
> > average days overdue: <xsl:value-of
> select="totalDaysOverdue" div
> > select="finePerDay"/>
>
> <xsl:value-of select="totalDaysOverdue div finePerDay"/>
>
> > total $ collected: <xsl:value-of select="finePerDay" *
> > select="totalDaysOverdue"/><BR/>
>
> <xsl:value-of select="finePerDay * totalDaysOverdue"/>
>
> Kicking yourself yet? :)
>
Not yet, Mike (also David)--I wish I were! I copied and pasted your text
(actually, we made a trivial error with "average days overdue", but anyway)
into the xsl file. The IE 5.5 browser is complaining about both.
XML stub:
> <libraries>
> <library>
> <name>Branch Library #2</name>
> <booksOverdue>73</booksOverdue>
> <totalDaysOverdue>310</totalDaysOverdue>
> <finePerDay>0.20</finePerDay>
> </library>
> </libraries>
XSL file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<HTML><BODY>
<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/>
total $ collected: <xsl:value-of select="finePerDay * totalDaysOverdue"/>
<BR/>
avg. days overdue: <xsl:value-of select="totalDaysOverdue div
booksOverdue"/> <BR/>
</xsl:for-each>
</BODY></HTML>
</xsl:template>
</xsl:stylesheet>
This works fine if I don't insert the last two statements that have
arithmetic expressions.
error message when I insert "total $ collected" line alone:
Expected token 'eof' found '*'. finePerDay -->*<-- totalDaysOverdue
error message when I insert "avg. days overdue" line alone:
Expected token 'eof' found 'NAME'. totalDaysOverdue -->div<-- booksOverdue
I must be making a stupid syntactical error somewhere, but I've tried every
permutation that comes to mind.
Thanks,
Glen
glen.mazza@eds.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list