[xsd-users] RE: Possible Oversight
Boris Kolpackov
boris at codesynthesis.com
Wed May 28 10:39:36 EDT 2008
Hi Manav,
Manav Rathi <manav.rathi at incainformatics.com> writes:
> >...the code bloat which happens when you reference the same element with
> anonymous type in two or more other types. In this situation the same nested
> type will be generated in several places...
>
> This I did not know. So, if I use the same anonymous type within two
> different elements, then xsd will recognize it as so, and emit only a
> single instance of the common anonymous type. Nice.
Not exactly. The scenario I was referring to is the following:
<element name="e">
<complexType>
...
</complexType>
</element>
<complexType name="a">
<sequence>
<element ref="e"/>
</sequence>
</complexType>
<complexType name="b">
<sequence>
<element ref="e"/>
</sequence>
</complexType>
Here, if we generate nested classes for anonymous types, you will end
up with the following code:
class a
{
class e
{
};
};
class b
{
class e
{
};
};
The way XSD works, you will only get one (global) class e which is used
by both a and b.
Boris
More information about the xsd-users
mailing list