xmlxsdenterprise-architectxmlspy

Importing Class from XSD in Enterprise Architect


I have a series of XSD files which are being used as the master type definition files for a software interface specification. I am trying to import them into Enterprise Architect as class models.

For some reason, the original developer of the XSD decided to list the sequence elements as "ref" instead of directly, and the referenced definitions exist in a separate XSD file, referenced from the file in question.

So far, no issues with that, it's standard XSD syntax, an example is shown below:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="commonTestElements.xsd"/>
<xs:element name="someElementName">
    <xs:complexType>
        <xs:sequence>
            <xs:element ref="someAttributeName" minOccurs="0"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>
<xs:element name="someOtherElementName" type="xs:boolean"/>

Over in the referenced file (commonTestelements.xsd), I have the following:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
    <!-- element declarations -->
    <xs:element name="someAttributeName">       
        <xs:simpleType>
            <xs:restriction base="xs:string">
                <xs:minLength value="1"/>
                <xs:maxLength value="80"/>
                <xs:whiteSpace value="preserve"/>
            </xs:restriction>
        </xs:simpleType>
    </xs:element>
</xs:schema>

XML Spy interprets this just fine, as does Visual Studio (though VS has some undesirable quirks). However, importing this into EA yields pure garbage, as shown in the attached screen clip.

Bad Diagram
EA Class Diagram

The question is: is there a way to get EA to import this and show the class correctly, which would be two classes linked together with a named association, as shown in this manually-created diagram? (I don't know if this is exactly how EA would do it, but this would be a lot better than having a bunch of garbage names inserted into the diagram). The view from XML Spy is also acceptable.

Desired Diagram
Desired EA Diagram

Output from XML Spy
XML SPY Diagram


Solution

  • There is no 1:1 mapping between UML and XSD. The fact that a number of tools create a certain mapping does not mean that another one gets the same results. EA's importer can not be modified. So the only option you have is to write your own importer (I did that in the past and it's not that difficult).