[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: sum function
> 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|