[xsd-users] RE: xsd bypasses customized types

Richard Cresswell rcresswell at gmail.com
Tue Apr 20 17:14:48 EDT 2010


Boris,

Don't we still have the same problem that we saw at the beginning of
this thread though?  The from-base class constructor is being
suppressed because it is trying to use the fundamental value
constructors.  I feel that this is inappropriate when we are deriving
from a custom type because it prevents us from extending it using our
own constructors.  We don't just need to suppress the default
constructor, we need to construct this object in the same way that the
base custom type is constructed by using the from-base constructor.

I think I might be having trouble envisioning the cases that you say
this would break.  Isn't the suppression of the from-base constructor
and its replacement by the fundamental constructors just to counter
code bloat?  Can you give an example where the functionality I
describe would break an object that is derived from a custom type?

Thanks Boris,

Richard

On Tue, Apr 20, 2010 at 3:31 PM, Boris Kolpackov
<boris at codesynthesis.com> wrote:
> 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