[xsd-users] RE: xsd bypasses customized types

Boris Kolpackov boris at codesynthesis.com
Tue Apr 20 15:31:56 EDT 2010


Hi Richard,

Richard Cresswell <rcresswell at gmail.com> writes:

> Our base customized object is derived from a string, but is
> implemented as another type in our customized code.  The problem is
> that once we derive an object from the custom base, it creates that
> derived object with the string constructors.  Instead, we want it to
> see that it is derived from a custom object and create a from-base
> constructor:
> 
> DerivedObject::DerivedObject(BaseObject)
> 
> This way all of the custom BaseObject constructors can be used for the
> DerivedObject.
> 
> Does that make more sense?

I understand what you are trying to achieve. However, there are 
other possible (and much more common) uses of type customization
(for example, adding a data to the generated class without changing
the type's interface) that will break should we make the XSD compiler
behave the way you describe.

One way to get rid of the default c-tor is to derive your BaseObject
from a type that doesn't allow default-construction, for example
xsd:NMTOKEN, instead of xsd:string. You will still get the string
c-tors (from const char* and const std::string&) though.

Boris



More information about the xsd-users mailing list