[xsd-users] Default values for optional elements.

Moss, David R (SELEX Comms) (UK Christchurch) david.r.moss at selex-comm.com
Tue Feb 14 04:12:19 EST 2006



Boris,

Yes, that sounds good - catching problems caused by changes at compile
time is definitely a good idea!

I did think there may be an issue with a scenario where the in-memory
value is set to that of the default (i.e. what should be serialised) but
that should just be treated as if it was any other non-default value I
guess.

Cheers,
Dave.

Dave Moss
SELEX Communications
Grange Road
Christchurch
Dorset  BH23 4JE
United Kingdom
Tel: + 44 (0) 1202 404841
Email: david.r.moss at selex-comm.com


-----Original Message-----
From: Boris Kolpackov [mailto:boris at codesynthesis.com]
Sent: 14 February 2006 08:10
To: Moss, David R (SELEX Comms) (UK Christchurch)
Cc: xsd-users at codesynthesis.com
Subject: Re: [xsd-users] Default values for optional elements.

Hi David,

Boris Kolpackov <boris at codesynthesis.com> writes:

> 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?

I tend to think that creating a separate container (which inherits from
the optional container) with this additional logic is the best way to
go.
I also think it will make sense to use a different name for the accessor
function which has the additional, "default value" logic, something like
get_with_default. This way, when you have

return foo.bar ().get_with_default ();

and later change definition of bar not to have a default value or remove
the option that allow this behavior, you will get an error at compile-
time rather than at run-time. Any thoughts?


thanks,
-boris

********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************




More information about the xsd-users mailing list