[xsd-users] Customize sequence and optionals

WEBER Stefan stefan.weber at efgfp.com
Wed Jan 28 02:56:02 EST 2009


Hi Boris, 
 
> Just as an aside, elements with default values in XML Schema 
> are quite a strange construct. You cannot simply ommit an 
> element with a default value. Rather, you will need to 
> specify an empty element in order for it to have the default value.
> [...]
> So am not sure how convenient elements with default values 
> will be in your situation.

Thanks for the example. This is exactly the reason why I don't want to
enforce the defaults by the schema, but by a preprocessor that creates
an empty element whenever the optional element was not specified. This
frees the consumer of the preprocessed object model to check for
presence before each and every access. Now with customizing the standard
optional behavior, I could get rid of the explicit preprocessing.

> > Now I would like to change the optional type such that 
> whenever get() 
> > would return a NULL pointer, I create an element of the 
> default value 
> > and return the newly created element.
> >  
> > In other words, instead of having a
> >  
> > typedef xsd::cxx::tree::optional<MyType> MyTypeOptional
> >  
> > I would rather provide a custom MyTypeOptional. Is this possible?
> 
> The only way to do this would be to customize the outer type 
> that contains MyTypeOptional and redefine the typedef's and 
> functions for elements with default values. 

Thanks for the hint. This indeed will require quite a bit of
customization, I'll need to check whether this is worth it. The main
concern I have with this is that it makes me redefine a non-virtual
function coming from OuterBase...

Stefan

==== The EFG Mail Gateway made the following annotation =====
This message is for the addressee only and may contain confidential or
privileged information. You must delete and not use it if you are not
the intended recipient. It may not be secure or error-free. All e-mail
communications to and from the EFG Financial Products Group may be monitored.
Processing of incoming e-mails cannot be guaranteed. Any views expressed
in this message are those of the individual sender. This message is for
information purposes only. All liability of the EFG Financial Products Group
and its entities for any damages resulting from e-mail use is excluded.
US persons are kindly requested to read the important legal information
presented at following URL: http://www.efgfp.com. If you suspect that the
message may have been intercepted or amended, please call the sender.
Should you require any further information, please contact the Compliance
Manager on compliance at efgfp.com.
=============================================================





More information about the xsd-users mailing list