xsd.exe and abstract classes

  • Thread starter Thread starter Steve B.
  • Start date Start date
S

Steve B.

Hi,

I build a Xml Schema which have a node that can contains two different
elements (no restriction of the number of occurences of each):

<xs:element name="MyRootElement">
<xs:complexType>
<xs:choice>
<xs:element name="AnElement" minOccurs="0" maxOccurs="unbounded">
.... Complex type removed for lisibility ...
</xs:element>
<xs:element name="AnOtherElement" minOccurs="0" maxOccurs="unbounded">
.... Complex type removed for lisibility ...
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>

I wanted to use XSD.exe with /c parameter in order to create a serializable
class respecting this schema.
The ouputed file provide this classes :
class MyRootElement
{
object[] Items;
}

class AnElement
{
}
class AnOtherElement
{
}

It is functionnal, but the object model is not very intuitive.

I'd like to reach something like this (using base classes or Interfaces) :

class MyRootElement
{
BaseAction[] Items;
}
class BaseAction
{
}
class AnElement : BaseAction
{
}
class AnOtherElement: BaseAction
{
}

Is there any way to create "Base" types in the xsd ?
Or have I to build the classes myself ?

Thanks,
Steve
 
Back
Top