Pierre
Pierre

Reputation: 21

Sparx Enterprise Architect - XSD Generation : Importing a XSDschema reference in the generated one

I'm using Sparx Enterprise Architect v10 to generate XSD schema from XML Schema graphic model.

Basically, I created 2 different XSDschema : 1 main XSDshema with my entities that are complexType :

<xs:complexType name="EntitytXT">
    <xs:annotation>
        <xs:documentation>This is the definition of an EntitytXT</xs:documentation>
    </xs:annotation>
    <xs:sequence>
        <xs:element name="element1" type="shared:StringXT" minOccurs="1" maxOccurs="1"/>
        <xs:element name="element2" type="shared:StringXT" minOccurs="1" maxOccurs="1"/>
    </xs:sequence>
</xs:complexType>

The other created XSDschema is the "shared one" and is simple with just the type StringXT; composed of things like that :

<xs:simpleType name="StringXT">
    <xs:restriction base="xs:string">
        <xs:maxLength value="5" />
    </xs:restriction>
</xs:simpleType>`

What I want to do is : Whenever I generate the first main XSD with EA, that the imported xsd "shared" path xmlns:v1shared="http://xxxx/common/v1/shared" AND that the tag

<xs:import namespace="http://xxxx/shared" schemaLocation="http:/xx/xx/common/shared.xsd"    />

are present in my generated resulting XSD.

Many thanks.

Upvotes: 1

Views: 1533

Answers (1)

Pierre
Pierre

Reputation: 21

So, after almost a day, it ended up to be fairly obvious.

I didn't find any specific answer to this practical import procedure for different XSDschema in EA.

The thing is : you have 2 XSDschema as 2 different packages. To ensure the "shared" one to be imported into the main one (with the tag <xs:import explicitly in the xsd header, you must :

  • Enter 2 different target Namespace, one concerning each XSDschema package

  • Add the "shared" (+its namespace) in the XMLNS tab within the main XSDschema properties

  • Double check the SchemaLocation Tagged value for each XSDschema package

  • And last, but not least, in the xs sequence for your main complexTypes <xs:element name="element1" type="shared:StringXT" the "type" tag must be just :StringXT (without the 'shared') in order to 'link' the main XSDschema and the shared one. You can go to the XSDschema attributes and check their tagged values. You should see something like +Attributes +from StringXT

hope it helps!

Upvotes: 1

Related Questions