0
votes

I use standard UML within Enterprise Architect and want to generate an xsd out of a model. I know I can transform the model to have types with XSDComplexType stereotype etc. and modify it afterwards (everytime after transform?) or attach them directly but I want to be as much agnostic of xsd as possible.

This is what I get when using UML class, value is attribute:

<xs:complexType name="Longitude">
    <xs:sequence>
        <xs:element name="value" type="xs:double" minOccurs="1" maxOccurs="1"/>
    </xs:sequence>
</xs:complexType>

This is what I get when using UML enumeration:

<xs:simpleType name="Longitude">
    <!-- where to define that? e.g. to be double instead, string is default -->
    <xs:restriction base="xs:string"/>
</xs:simpleType>

This is what I want to achieve as output instead of the above:

<xs:simpleType name="Longitude">
    <xs:restriction base="xs:double">
        <minInclusive value="0.0"/>
        <maxInclusive value="359.99999999"/>        
    </xs:restriction>
</xs:simpleType>

What UML type to use and where are to "fields/tags" to use for the wanted output?

2
Try to reverse engineer from a valid XSD source and see what EA generates.qwerty_so
@Thomas Kilian This does not work. EA generates the classes with the stereotypes as they would have been produced when doing a model transformation that can be used for XSD generation (output when performing "Transform Current Package", this contains the XSD types etc.) but I want to know the UML element should look before doing the transform. I don't want to create an UML-Model containing XSD-Elements, I want to create an independent "target-agnostic" UML-Model instead, e.g. should be able to generate Code, too.Beachwalker
It's too long ago I used XSD with EA. But that time I wrote my own im-/exporter for EA. The reason was/is that there is not defined mapping between UML and XSD. Just there are a couple of conventions. Depending on how much you are doing in that direction I'd suggest to go the same way.qwerty_so
FWIW: I was able to RE the above with a schema definition and EA created a <<XSDsimpleType>>qwerty_so

2 Answers

1
votes

There is no standard usable direct UML to XML Schema translation.

To do this in EA you'll need to use the MDA transformation from UML model to XSD model and then from this XSD model generate the XML schema.

Another option is to use the Schema Composer, but that gives you even less control over the generated XSD.

0
votes

You should use stereotype XSDsimpleType (not XSDCOmplexType).Enter the restrictions to the tags values.

See more about Restrictions in EA: Simple Type and tags in Tagged Values.