Book a Demo

Author Topic: Generating XSD from class model  (Read 4615 times)

MarcelSevcovic

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Generating XSD from class model
« on: August 16, 2017, 02:09:04 am »
Hi,
I have two questions related to generating XSD from class model.

1.  Because of the better clarity I have in my class model both - attributes and the same relationships. For example a class contains attribute person of type Person. And there is also association called person to the class Person. If I generate a C# or Java source code it works fine - EA generates this attribute/association as one member in my class (of course it must be the very same name and type). But if I generate a XSD everything is doubled - once from the attribute and then from the association. Is it possible somehow suppress this double generation in XSD?

2. Second question is related to the number of XSD files which are generated. If I generate XSD from a package and its child packages, EA always generates for me more XSD files (with include element). Anyway, is it possible to generate only one XSD file if I select a parent package and one or more child packages?

Thank you in advance for your answers.

Marcel

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Generating XSD from class model
« Reply #1 on: August 16, 2017, 04:49:36 am »
1.  Because of the better clarity
Actually this is not better clarity but simply unneeded redundancy. Attributes and roles on associations are different renderings for the same thing. Geert has a nice blog where he details the use of either. tl;dr; You use role names where you have class typed attributes and you use simple attributes for primitive types (int, string, enum, etc.).

FWIW: I coded my own XSD import/export which gave me the freedom of creating and understanding any XSD flavor that was needed.

q.

MarcelSevcovic

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Generating XSD from class model
« Reply #2 on: August 16, 2017, 04:34:36 pm »
Hi qwerty,

Thank you for your answer.

I wouldn't say it is unneeded redundancy. I started with the approach you are writing about, I used attributes only for primitive types and relationships for class types. I have more than 100 classes in my model. Despite that, I try to keep my diagrams simple (up to 15 classes per diagram). It means, if I have one class in more diagrams it is not good to have there all the relationships. On the other hand without all the associations and compositions I had sometimes no idea how the classes structure are complex. Moreover the EA Code generating functionality accepts this approach and behave intelligently while creating source code.

Anyway, I understood it is not possible in EA and an option is to create my own functionality. Only question I have.. should I use scripting or write my own Add-In?

Thank you

Marcel

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Generating XSD from class model
« Reply #3 on: August 16, 2017, 05:25:41 pm »
I was happy with a simple script I triggered to either import or export XSD. An add-in will give you a context menu (you probably wont need any broadcast event in your case). It's not difficult to put that on top.

q.