[xsd-users] How to get rid of "P0Y" as default zero duration value

Boris Kolpackov boris at codesynthesis.com
Thu May 28 10:30:32 EDT 2020


Cihan-Kaya.Guenduez <Cihan-Kaya.Guenduez at l3harris.com> writes:

> For example the definition of xs:dayTimeDuration uses a restriction pattern:
> <xs:simpleType name="dayTimeDuration">
>     <xs:restriction base="xs:duration">
>         <xs:pattern id="dayTimeDuration.pattern" value="[^YM]*(T.*)?"/>
>     </xs:restriction>
> </xs:simpleType>
>
>
> Using the generated serialization functions (cxx/tree/serialization into
> output stream), a zero dayTimDuration always yield in "P0Y" and violates the
> restriction pattern.

I think the best way to do this is to customize the dayTimeDuration
generated C++ type and provide custom serialization implementation
that does what you want.

You can read about type customization in C++/Tree here:

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

There is also a bunch of examples in the examples/cxx/tree/custom/
directory of XSD distribution that show how to do this (the 'double' 
and 'contacts' are probably the most relevant to your case).



More information about the xsd-users mailing list