Subject: RE: Multiply
From: Linda van den Brink <lvdbrink@xxxxxxx>
Date: Wed, 7 Feb 2001 14:23:01 +0100
|
> -----Original Message-----
> From: Jo Kong HO [mailto:JoK@xxxxxxxxxxxxxx]
> Sent: Wednesday, February 07, 2001 12:53 PM
> To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
> Subject: Multiply
>
>
> Hi
>
> A beginners question. If I have the following XML :
>
> <numbers>
> <one>1</one>
> <two>2</two>
> <three>3</three>
> </numbers>
>
> And I want to generate the mutilple of these numbers, How
> would I do it in
> XSLT?
To get the total of those numbers (which I assume is what you want) you can
use the sum() function:
<xsl:template match="numbers">
Total = <xsl:value-of select="sum(*)"/>
</xsl:template>
The argument to the sum function is a node-set, so in this case it adds up
the value of all the children of the numbers element.
Linda
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
- Multiply
- Jo Kong HO - Wed, 7 Feb 2001 06:53:50 -0500 (EST)
- <Possible follow-ups>
- Jo Kong HO - Wed, 7 Feb 2001 07:29:48 -0500 (EST)
- Ben Robb - Wed, 7 Feb 2001 08:15:31 -0500 (EST)
- Linda van den Brink - Wed, 7 Feb 2001 08:24:30 -0500 (EST) <=
|
|