Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: Guillaume on December 09, 2016, 03:11:55 am

Title: Associations order in the generated XSD file
Post by: Guillaume on December 09, 2016, 03:11:55 am
Hi,

I have a project where we defined XSDcomplexType classes to generate XSD files.
Using EA Generate XML Schema command, here is an extract of what I get on the associations created between complex types:
Code: [Select]
<xs:complexType name="ComplexType1">
             <xs:sequence>
                    <xs:element name="element1" type="xs:string" minOccurs="1" maxOccurs="1"/>
                    <xs:element name="association1" type="Association1" minOccurs="1" maxOccurs="1"/>
                    <xs:element name="association2" type="Association2" minOccurs="1" maxOccurs="1"/>
                    <xs:element name="association3" type="Association3" minOccurs="1" maxOccurs="1"/>
                    <xs:element name="association4" type="Association4" minOccurs="1" maxOccurs="1"/>
             </xs:sequence>
Having looked into details, EA uses the created order i.e. Connector ID value from t_connector table (I get association 4 before association 3, if I created associations in the order 1 / 2 / 4 / 3).
So the I'm looking for a way to let EA users change this order.

Could the Generate XML Schema in Sparx EA be improved to support that e.g. via tagged value or else?
I tried the Schema Composer which seems to apply an alphabetical order on the role name only. I also noticed that the Schema Composer doesn't generate an XSD content as complete as EA Generate XSD file.
I'm aware that a Schema Composer addin can be written to generate an XSD file and support additional tagged values. I did something similar to generate JSON files before, but the current context requires an option that's built in EA.

Could it be looked at by Sparx?

thanks
Title: Re: Associations order in the generated XSD file
Post by: Eve on December 09, 2016, 08:39:10 am
The XSD generator supports a tagged value on the associations to apply an order to them. It's largely a manual process at this time.

The schema composer doesn't have a mode that expects a model annotated with XSD stereotypes. As a result it doesn't know about anything special that the xsd uml profile offers.
Title: Re: Associations order in the generated XSD file
Post by: Guillaume on December 09, 2016, 06:50:14 pm
Hi Simon,

Sounds like what I'm looking for!
Can you advise the tagged value that needs to be created on the associations?
I tried to add position and order = 1, 2, 3... but it didn't work.

Thanks
Title: Re: Associations order in the generated XSD file
Post by: Eve on December 14, 2016, 08:49:55 am
Add a tag called 'position' to each association role, there already is one on each XSDElement.

Assign the number based on the order they should be generated.
Title: Re: Associations order in the generated XSD file
Post by: Guillaume on December 14, 2016, 06:30:46 pm
Hi Simon,

I added a position tagged value on the associations between XSDComplexType classes but it didn't change the order of the generated XSD. I can see it working on the XSD elements (attributes) within an XSD complex type class.

I'll send a sample of my EAP file to support to check if I'm doing something wrong.

Thanks
Title: Re: Associations order in the generated XSD file
Post by: Eve on December 15, 2016, 08:22:06 am
I can see it working on the XSD elements (attributes) within an XSD complex type class.
That's all it's intended to do.

Were you trying to order the complex type definitions themselves? If so, build 1309 has been updated to group the different type of things (xsdElement, xsdComplexType, xsdSimpleType etc) together and sort alphabetically within each type. It's not arbitrary sorting but it's probably more useful.
Title: Re: Associations order in the generated XSD file
Post by: Guillaume on December 21, 2016, 12:19:40 am
Hi Simon,

I need to control the order of associations in the generated XML Schema.
I can see the position tagged value exists and works on attributes. I tried to add this tagged value to the association, or even on the connector target, but it doesn't change anything in the generated XML Schema.

Do you think this requires a feature request?

Thanks
Title: Re: Associations order in the generated XSD file
Post by: Eve on December 22, 2016, 03:44:15 pm
Sorry, I did see the model you sent in. Then got too busy and passed it on to someone else to look into.

From memory, you had added the position tag to the xsdAttribute stereotyped attributes on the complex type instead of the xsdElement attributes.

From what I can see, it's just very picky about the position tags. For them to be used, the position tags for all xsdElements and association ends for a complex type have to have to form a contiguous, non-duplicating sequence starting at 1.
Title: Re: Associations order in the generated XSD file
Post by: Guillaume on January 02, 2017, 11:46:05 pm
Hi Simon,

I eventually managed to get it to work  :)
I created the "position" tagged value on the association within the Connector Source group (not the connector target).

The order I get in the generated xsd looks ok.

thanks