[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Multiply


Subject: RE: [xsl] 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: [xsl] 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
  • [xsl] Multiply
    • Jo Kong HO - Wed, 7 Feb 2001 11:53:10 -0000
      • <Possible follow-ups>
      • Ben Robb - Wed, 7 Feb 2001 12:25:30 -0000
      • Jo Kong HO - Wed, 7 Feb 2001 12:29:27 -0000
      • Linda van den Brink - Wed, 7 Feb 2001 14:23:01 +0100 <=
Keywords
xml