[xsd-users] Question about code synthesis C++/Tree : serialization and XSD patterns

Boris Kolpackov boris at codesynthesis.com
Wed Sep 28 12:49:15 EDT 2016


Hi Anael,

LA FATA, Anael <anael.la-fata at capgemini.com> writes:

> Hi and thank you very much for your answer.
> 
> If I understand you well, I have no other solution that redefining <<
> operators for each type that has a specific pattern? There is no "generic"
> solution that could work for any XSD file (since I have several XSD and
> they might change in the future)?

No, if you want trailing zeros, there is no XML Schema-base solution. The
README for the example states this explicitly:

"In case we can modify the schema, a better approach would be to define the
price type as a restriction of the xsd:decimal type (always fixed notation)
and specify the fractionDigits facet to limit the number of fraction digits
to 2. However, there is no way in XML Schema to specify that there should
always be exactly 2 fraction digits. Therefore, it may still be desirable
to customize this price type to get the required serialization behavior."

Boris



More information about the xsd-users mailing list