Subject: RE: [xsl] sum function From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx> Date: Fri, 16 Nov 2001 16:28:17 -0000 |
> How do I use the sum function on xml such as: > > <Amount>12,345.12</Amount> > <Amount>132,345.12</Amount> > <Amount>2,345.12</Amount> > > If I use Total Price = <xsl:value-of select="sum(//Amount)"/> > I get the > result NaN. However, if the data does not contain ',' the sum works > correctly. As a general principle, it's best to hold data in XML documents in a form that's optimised for processing rather than for display to humans. Using schemas will encourage that further. So I would say, first do a transformation to a document that holds these numbers in their canonical form (12345.12 etc), which you can achieve using translate(., ',', ''), and then apply the summation to the result. Mike Kay XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] sum function, Jeni Tennison | Thread | Re: [xsl] sum function, Jörg Heinicke |
RE: [xsl] xsl and microsoft:please , Chris Bayes | Date | Re: [xsl] xslt on server-side vs. c, cutlass |
Month |