[xsde-users] Default notation for float

Boris Kolpackov boris at codesynthesis.com
Tue Jun 28 09:56:52 EDT 2011


Hi Klaus,

Cinibulk, Klaus <klaus.cinibulk at siemens.com> writes:

> I'm using XSD/e and I have noticed that the default notiation for 
> float types is "%.6g".
> 
> My question is how to change the default notation to %.6f globally 
> for my generated code.

There is a way to do this but in XSD/e 3.2.0 it can only be done during 
the construction of the serializer. This makes it difficult if you are 
using aggregates in the C++/Hybrid mapping.

To fix this I have added modifiers to the float, double, and decimal
serializers so that this can be changed after the aggregate has been
constructed. This fix will appear in XSD/e 3.3.0 and I also prepared
a patch for XSD/e 3.2.0 (simply override the file in your XSD/e 3.2.0
with the ones in the archive):

http://www.codesynthesis.com/~boris/tmp/xsde-3.2.0-fp-format.tar.gz

With this fix you can change the notation and precision of the float
serializer in the aggregate, for example:

root_saggr root_s;

root_s.float_s_.format (xml_schema::float_simpl::notation_fixed, 6);

You can also create a custom aggregate class which will encapsulate
this customization:

struct my_root_saggr: root_saggr
{
  my_root_saggr ()
  {
    float_s_.format (xml_schema::float_simpl::notation_fixed, 6);
  }
};

Boris



More information about the xsde-users mailing list