[xsde-users] SimpleType with restriction creates object with empty constructor

Andrea Tessadri tessadriandrea at gmail.com
Fri Mar 29 11:17:47 EDT 2019


Excellent!
Thanks a lot, it works.

On Fri, Mar 29, 2019 at 4:01 PM Boris Kolpackov <boris at codesynthesis.com>
wrote:

> Andrea Tessadri <tessadriandrea at gmail.com> writes:
>
> > <xs:simpleType name="CountryCodeISO">
> >       <xs:restriction base="xs:string">
> >           <xs:pattern value="[A-Z][A-Z]"/>
> >       </xs:restriction>
> > </xs:simpleType>
> >
> > class CountryCodeISO: public ::std::string
> > {
> >   public:
> >   CountryCodeISO ();
> > };
> >
> > In such case there is no way to create an object of type CountryCodeISO
> > containing a string, since the only constructor available is the empty
> one.
>
> In an effort to be minimal and to support usage without exceptions,
> XSD/e employs the "default-construct then assign" approach for
> initializing  the object model. So you can do this:
>
> CountryCodeISO x;
> x = "ZA";
>
> Or:
>
> x.assign ("ZA");
>
> If you would like to use a more modern approach with proper constructors,
> then you may want to consider using XSD.
>


More information about the xsde-users mailing list