xsd.exe and abstract classes

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top