all -

i have a schema fragment as follows:


<xsd:element name="body" type="Body_T"/>
<xsd:element name="message1" type="MessageType1_T"
substitutionGroup="body"/>
<xsd:element name="message2" type="MessageType2_T"
substitutionGroup="body"/>

<xsd:complexType name="Message_T">
    <xsd:sequence>
      <xsd:element name="header" type="Header_T"/>
      <xsd:element ref="body" />
    </xsd:sequence>
</xsd:complexType>

<xsd:element name="myMessage" type="Message_T"/>


when i run the castor generator:
I get classes for Message, Body, Message1, Message2 and corresponding
abstract base classes, that correspond to the types.

Now the intent is to replace the body with either Message1 or Message2 and
hence the substitutiongroup is defined so.

I would have expected MessageType1_T,MessageType2_T  to have extended
Body_T. That is not the case in the generated code; the logic being:

If one intends an object of class type MessageType1_T to replace 'body', it
should be of the same type or extension of the type represented by 'body',
in this case Body_T.

So the question is:
a) where did i go wrong in specifying the schema?
b) what else could i do to achieve what i want to do, so that the
MessageTypes can replace the body in the instance documents.

thanks for the help
srini

Reply via email to