[xsd-users] Tree-Mapping and xsd:decimal several problems

Boris Kolpackov boris at codesynthesis.com
Wed Sep 19 04:05:49 EDT 2007


Hi Michael,

Forstner Michael <Michael.Forstner at cpg.de> writes:

> After parsing a XML-File with following content in a CurrencyAndAmount
> field, the internal double-value of the generated cxx-tree-class is
> still uninitialized:
>
> <TtlIntrBkSttlmAmt Ccy="EUR">288.35</TtlIntrBkSttlmAmt>
>
> After serializing to a XML-File, the decimal point is ',' instead of '.'

I think your default locale has decimal point facet set to ','
instead of '.'. Since the spec prescribes that the decimal point
should always be '.', irrespective of the locale, this is a bug
in our parsing/serialization code. I've applied a fix to the
3.0.0 codebase which sets the stream's locale that is used internally
by parsing and serialization code to locale::classic (). This locale
corresponds to the "C" locale and always has decimal point as '.'.

This fix will appear in the next version of XSD (3.1.0). I've also
uploaded the changes that can be used with 3.0.0:

http://www.codesynthesis.com/~boris/tmp/libxsd-3.0.0-float-locale.tar.gz

Simply replace the two files in libxsd with the versions provided in
the archive.


> and the setting 'fractionDigits value="2"' is ignored:
>
> <sw8:TtlIntrBkSttlmAmt Ccy="EUR">278,35000000000002</sw8:TtlIntrBkSttlmAmt>

The fractionDigits faced is not yet supported in the generated code.
One way to overcome this is to customize the generated CurrencyAndAmount
class to serialize only 2 fraction digits. For an example on how to
customize the generated types, see the custom/ directory in
example/cxx/tree/ as well as the C++/Tree Mapping Customization Guide:

http://wiki.codesynthesis.com/Tree/Customization_guide

In particular, the wildcard example shows how to customize the
serialization operator. Also let me know if you would like me to
implement the custom CurrencyAndAmount type for you.

Boris




More information about the xsd-users mailing list