Author Topic: Logical Model to Schema - Order of elements and attributes in the XSD  (Read 5196 times)

Sparxs411

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Hello,

  I am using EA to model drive schemas. I am able to produce schemas but would like to control the order elements and attributes appear in the schemas. I know one way of doing this is using the position tag on the source of the connector however that is a rather laborious task to do for the entire model. Is there a way to make the alphabetical order the default order?

Thanks in advance.

qwerty

  • EA Guru
  • *****
  • Posts: 12445
  • Karma: +348/-291
  • I'm no guru at all
    • View Profile

Sparxs411

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Thank you for the information. Based of further evaluation it appears that the order of elements within a schema (created by EA) are driven by the order in which they were "created" in  the model. Has anyone else experienced this? Below is an example of the order of elements from an EA schema; ideally I would like these to be alphabetical order.

                        <xs:element name="architecture" type="feat:ArchitectureData" minOccurs="0" maxOccurs="1"/>
         <xs:element name="operations" type="feat:Operations" minOccurs="0" maxOccurs="1"/>
         <xs:element name="blah" type="feat:Blah" minOccurs="0" maxOccurs="1"/>


Thanks

Sparxs411

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
I have done further research on this topic. So it appears that elements related to a ComplexType are ordered in the schema based on the date the "Connector" is added (?). Or perhaps it is based on an object ID? When I deleted a connector associated with a ComplexType from the model and then added it back to the model it changed the order of the elements. Any insight into this would be appreciated or ideas on a way to make alphabetical order the default. I know one workaround is adding a position tag to the "source" of the connector, but doing this for a large model is very cumbersome.

Thanks!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 11312
  • Karma: +422/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
We have solved this (for different customers) in different ways:

- 1) only use attributes and no associations (limits some constructs such as anonymous choices)

- 2 ) use an add-in I wrote: EA Message Composer to select the message as a subset. The add-in takes care of the alphabetic order.

- 3) write a post-processing tool/script to order the resulting xsd's alphabetically.

Geert

bholtzman

  • EA User
  • **
  • Posts: 86
  • Karma: +2/-0
    • View Profile
Re: Logical Model to Schema - Order of elements and attributes in the XSD
« Reply #5 on: August 25, 2018, 03:44:36 am »
Hi Geert,
Can you elaborate on item (3)? Are you referring to post-processing within EA or something external? Is there any ability to modify and customize the generation of xsd's from within EA? Is there a way to somehow integrate scripts within EA to different EA export features?

We're trying to replace an existing post-processing tool with a method that is internal to EA.

Thanks!

Bill


We have solved this (for different customers) in different ways:

- 1) only use attributes and no associations (limits some constructs such as anonymous choices)

- 2 ) use an add-in I wrote: EA Message Composer to select the message as a subset. The add-in takes care of the alphabetic order.

- 3) write a post-processing tool/script to order the resulting xsd's alphabetically.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 12445
  • Karma: +348/-291
  • I'm no guru at all
    • View Profile
Re: Logical Model to Schema - Order of elements and attributes in the XSD
« Reply #6 on: August 25, 2018, 06:00:21 am »
It's probably setting EAElement.TreePos in the order you need it.

q.

bholtzman

  • EA User
  • **
  • Posts: 86
  • Karma: +2/-0
    • View Profile
Re: Logical Model to Schema - Order of elements and attributes in the XSD
« Reply #7 on: August 27, 2018, 07:37:31 am »
It's probably setting EAElement.TreePos in the order you need it.

q.

Thanks. I should have been clearer. It's not just the sequence of the elements that we want to process. We want to actually tailor the schema output to include reference to some information in tagged values. Is that the kind of thing you'd build an MDG for? I could also see doing it through some Access VBA but this would exist outside of EA - the Access file would link to the EA tables and then do lots of data manipulation on its own. I think you know what I mean since you encouraged me to use Access this way!

Bill

bholtzman

  • EA User
  • **
  • Posts: 86
  • Karma: +2/-0
    • View Profile
Re: Logical Model to Schema - Order of elements and attributes in the XSD
« Reply #8 on: August 27, 2018, 07:50:02 am »
By the way what is EAElement.TreePos? Is that something I can find in the database?

Bill

qwerty

  • EA Guru
  • *****
  • Posts: 12445
  • Karma: +348/-291
  • I'm no guru at all
    • View Profile
Re: Logical Model to Schema - Order of elements and attributes in the XSD
« Reply #9 on: August 27, 2018, 02:55:07 pm »
It's the API equivalent to t_object.TPos


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 11312
  • Karma: +422/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Logical Model to Schema - Order of elements and attributes in the XSD
« Reply #10 on: August 27, 2018, 06:53:38 pm »
Hi Geert,
Can you elaborate on item (3)? Are you referring to post-processing within EA or something external? Is there any ability to modify and customize the generation of xsd's from within EA? Is there a way to somehow integrate scripts within EA to different EA export features?

We're trying to replace an existing post-processing tool with a method that is internal to EA.

Thanks!

Bill


We have solved this (for different customers) in different ways:

- 1) only use attributes and no associations (limits some constructs such as anonymous choices)

- 2 ) use an add-in I wrote: EA Message Composer to select the message as a subset. The add-in takes care of the alphabetic order.

- 3) write a post-processing tool/script to order the resulting xsd's alphabetically.

Geert
Hi Bill,

I was referring to an external tool operating on the resulting XSD's. Depending on what tools/technologies you are comfortable with I guess this could be a script of some kind, an xslt, a small C# program etc...
AFAIK there is no way to customize the standard XSD generation.

Geert

bholtzman

  • EA User
  • **
  • Posts: 86
  • Karma: +2/-0
    • View Profile
Re: Logical Model to Schema - Order of elements and attributes in the XSD
« Reply #11 on: August 27, 2018, 10:19:25 pm »
Thanks, Geert. Much appreciated!

Bill

bholtzman

  • EA User
  • **
  • Posts: 86
  • Karma: +2/-0
    • View Profile
Re: Logical Model to Schema - Order of elements and attributes in the XSD
« Reply #12 on: August 27, 2018, 10:29:21 pm »
It's the API equivalent to t_object.TPos

So TPos is a parameter you can use to sort the elements in the output XSD? In my database the count looks like this:
null: 88
0: 381
1: 1
2: 1

I don't know how this field is updated within EA. Another guy on my team (who wrote the original post here) thinks that the sorting is a function of when the element was created, so maybe that is the second level in the "order by" clause? I noticed that only t_object has a "CreatedDate". t_attribute does not.

If TPos is the primary sorting field, then I could certainly add the capability to control the sequence with an Access tool. Have you done that?

Geert is that what EA Message Composer does? So option (2), the EA Message Composer, builds custom XSDs whereas the option (3) would be to take the standard XSDs generated by EA and process them?

Bill

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 11312
  • Karma: +422/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Logical Model to Schema - Order of elements and attributes in the XSD
« Reply #13 on: August 27, 2018, 10:48:29 pm »
Bill,

The position in the project browser (pos) depends on a number of things.
If it's 0 then that means it has no (user) specified order and uses the standard EA ordering logic. (Which is a bit ordering by type, and a bit of alphabetic)

The EA Message Composer add-in creates a duplicate of a (part of a) model and sets the ordering explicitly alphabetically (depending on which options you enable in the settings)
From that duplicate model you can then generate XSD using the standard XSD generation.

Geert

bholtzman

  • EA User
  • **
  • Posts: 86
  • Karma: +2/-0
    • View Profile
Re: Logical Model to Schema - Order of elements and attributes in the XSD
« Reply #14 on: August 27, 2018, 11:16:33 pm »
Geert,
So then it's safe to say I could not use the EA Message Composer to customize the XSD further to add text based on some Tagged Values, correct? Do you think that is something that could be accomplished by modifying the EA Message Composer source code, and do you offer that option? Since you didn't mention it as an option, I assume there are no MDG Technologies for something like this.

Also, does the EA Message Composer use the TPos field to set the ordering explicitly? Based on your message I'm not clear as to whether the TPos value is used in the generation of the XSD.

Sorry for all the questions!  :)

Bill