Hello there,
I found a problem when generating a XSD from a normal UML class model. While the relational data is preserved in the XSD, it places for all of the UML classes a root element. For example:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns:xs="
http://www.w3.org/2001/XMLSchema">
<xs:element name="Class1" type="Class1" /> <xs:complexType name="Class1">
<xs:sequence>
<xs:element name="Class2" type="Class2" />
<xs:element name="Class3" type="Class3" />
</xs:sequence>
</xs:complexType>
<xs:element name="Class2" type="Class2" /><xs:complexType name="Class2">
<xs:sequence />
</xs:complexType>
<xs:element name="Class3" type="Class3" /> <xs:complexType name="Class3">
<xs:sequence />
</xs:complexType>
</xs:schema>
As you can see the red colored elements are placed as a root elements. The only correct root element is the green element. First I thought it wouldn't be a problem because our messages where validating correctly, but that's because my messages started with the correct root element. If you send a message with one of the red ones, it will validate the message as 'correct' as well. So a 'wrong' message like:
<Class2><Class2/>
and
<Class3><Class3/>
go through as 'correct', eventhough the only message we had in mind as correct is:
<class1>
<class2></class2>
<class3></class3>
</class1>
I tried to use other stereotypes and associations, but even in the example of the website (
http://www.sparxsystems.com.au/resources/xml_schema_generation.html) it has the same problem. A message in this example could exists of an element like 'Employee' or 'ContactInfo' and nothing more.
What can I do about it without removing the not used root elements (the red ones) manually?