[xsd-users] Default values for optional elements.

Boris Kolpackov boris at codesynthesis.com
Mon Feb 6 05:11:40 EST 2006


David,

Moss, David R (SELEX Comms) (UK Christchurch) <david.r.moss at selex-comm.com> writes:

> A further thought I had was, having generated these default values, to
> exclude these elements when serializing the data to file again. i.e. an
> xml file containing unspecified elements would look the same before and
> after serialisation.
>
> The only slight issue with this is that if a value was set in memory at
> runtime, overriding the default, then that value would obviously need to
> be serialized.

Right, I was thinking about exactly the same problem: if we map optional
elements with default values to the One cardinality class then we may
and up with invalid instances when serializing back to XML. So it seem
like your initial idea (return false from present() and return default
value from get()) is winning so far.

We will need to extend optional container with something like set_default
which will also require an extra flag to distinguish between the normal
value and default value cases (at the moment it's just an auto_ptr). So
things get a bit hairy and I would like to think some more about other
options. Maybe we should use another container, optional_with_default?

hth,
-boris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 652 bytes
Desc: Digital signature
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20060206/9bac6c7f/attachment.pgp


More information about the xsd-users mailing list