xsd:group Gets Lost In Translation

If an XML Schema contains an <xsd:group> definition, the contents of the <xsd:group> are embedded in the containing <xsd:complexType>. Reasonably, enough, the XSD.EXE tool mimics this behaviour, when generating a .NET class definition - <xsd:group> children become fields in the containing class.

However, the fact that these fields originated in a reusable group is lost in the generated code. The developer working with just the generated classes must spot any reusability opportunities by manual inspection.

It seems to me that one way to enhance the code-generation experience would be to have a new Serialization Attribute, e.g. XmlGroupAttribute. Such an attribute, when associated with a class (or fields of that type), would ensure that instances of the class got serialized correctly to XML inside the containing class.

I wonder whether there are other options that gives reusability of <xsd:group>s in generated code? How about in .NET 2.0?

No Comments