Subject: RE: [xsl] sum() with decimal-separator "," From: "Michael Kay" <mhk@xxxxxxxxx> Date: Tue, 9 Sep 2003 10:20:57 +0100 |
> The problem is that I have to use a decimal format with > decimal-separator=",": > <row> > <BUCHWERTBW>43023,7</BUCHWERTBW> > </row> > Is this a wise decision? This isn't a lexical representation of any numeric data type supported by XML Schema, and therefore you're cutting yourself off from what tools will support natively. (XML Schema made the decision that XML documents shouldn't be storing data in localized formats, localization should be done at the point where the data is presented to human beings). > so the result is NaN. How can I use the function sum() with > an decimal-separator like "," ? > This is the same problem as summing over (@price*@qty), in fact over any value that is computed rather than stored. There's a range of solutions, which extend from doing it in two passes (via a temporary tree), to writing your own recursion over the elements, using a higher-order extension function such as saxon:sum(), or using Dimitre's FXSL library. In XPath 2.0 of course you can do sum(for $x in row/BUCHWERTBW return xs:decimal(translate($x, ',', '.'))) Michael Kay XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] sum() with decimal-separa, David Carlisle | Thread | Re: [xsl] sum() with decimal-separa, m . friedrich |
Re: [xsl] sum() with decimal-separa, David Carlisle | Date | Re: [xsl] sum() with decimal-separa, Dimitre Novatchev |
Month |