Hi All,
I'm having a lot of trouble generating XSD schema from my data model, and hope you can help out.
I have the following simple classes: Order and Item. I then setup a Composite association joing Item to Order, so that I have the following diagram:
+----------+
|Order |
+----------+
| +orderId |
+----------+
/\
# 1 +Items
\/
|
|
| 0..*
+----------+
|Item |
+----------+
| +itemId |
+----------+
I then use the XSD transformation to generate an XSD model for me (I have already imported the XSD Profile). The XSD model is very similar to above, but has the XSD stereotypes applied to it.
I then export the model as XML schema. However, the schema is not what I expected at all. I get:
<xs:complexType name="Order">
<xs:sequence>
<xs:element name="OrderId" type="xs:int"/>
<xs:element name="Item" type="Item" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
when I expect to see:
<xs:complexType name="Order">
<xs:sequence>
<xs:element name="OrderId" type="xs:int"/>
<xs:element name="Items">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="Item" type="Item"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
I'm certain this is to do with the way I am modelling the association. (I'm not even certain if this is syntactically correct UML).
I notice in the XSD model that none of the items is marked with an XSDsequence stereotype, so I am really confused as to how this should work (the example docs seem to be out of sync with the profile, so they are not much help).
It's not beyond me to customize the XSD transform if needed - but I have to understand how schema generation should work in the first place!
Any pointers would be appreciated.
Pete