|
Definetly agree with the use of UML contraints to model XSD (WXS?!) facets. They're a natural fit.
However, don't think model groups (ie. all | sequence | choice) can be adequately modelled using association connections. Sequences etc are "anonymous" containers which need to be modelled as classes. The following two example illustrate the problems that arise with using associations.
Element MyElement contains a sequence. If the sequence contains multiple complex items, it is easy enough to model each using a separate association connected to the item in question. The many connections all belong to the same sequence.
<xsd:element name='MyElement'>
<xsd:complexType>
<xsd:sequence>
<!-- some conent... -->
</xsd:sequence>
</xsd:complexType>
</xsd:element>
However, what happens if we now add another sequence...
<xsd:element name='MyElement'>
<xsd:complexType>
<xsd:sequence>
<!-- some content... -->
</xsd:sequence>
<xsd:sequence>
<!-- some more content... -->
</xsd:sequence>
</xsd:complexType>
</xsd:element>
We can continue to add an association for each complex item, however, we start to lose track of which items belong to which sequence. We could of course label each connector "sequence1" or "sequence2" but it all starts to get a bit messy.
In the second example, MyOtherElement has a nested sequence:
<xsd:element name='MyOtherElement'>
<xsd:complexType>
<xsd:sequence>
<!-- some conent... -->
<xsd:sequence>
<!-- some more conent... -->
</xsd:sequence>
</xsd:sequence>
<xsd:complexType>
</xsd:element>
Again, it's difficult to model this in UML using only association connections - how do we show the source of the inner most sequence?
I encountered these problems whilst writing a stylesheet to transform our "legacy" schemas into XMI (for rendering as UML). The solution I decided upon was to map all model group elements, except the immediate children of complexTypes, to anonymous nested classes labeled with an appropriate stereotype. To avoid uneccessary clutter, the immediate children of complexTypes are represented by adding an appropriate tagged value to the parent.
Note also that tagged values can be used to indicate position in sequences.
|