This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Multiply




> -----Original Message-----
> From: Jo Kong HO [mailto:JoK@USWebCKS.co.uk]
> Sent: Wednesday, February 07, 2001 12:53 PM
> To: 'xsl-list@lists.mulberrytech.com'
> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]