Book a Demo

Author Topic: Generating a XSD from UML, root element problem  (Read 3706 times)

Koning

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Generating a XSD from UML, root element problem
« on: April 04, 2006, 07:37:25 am »
Hello there,

I found a problem when generating a XSD from a normal UML class model. While the relational data is preserved in the XSD, it places for all of the UML classes a root element. For example:

 <?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
 <xs:element name="Class1" type="Class1" />
<xs:complexType name="Class1">
<xs:sequence>
 <xs:element name="Class2" type="Class2" />
 <xs:element name="Class3" type="Class3" />
 </xs:sequence>
 </xs:complexType>
 <xs:element name="Class2" type="Class2" />
<xs:complexType name="Class2">
 <xs:sequence />
 </xs:complexType>
 <xs:element name="Class3" type="Class3" />
<xs:complexType name="Class3">
 <xs:sequence />
 </xs:complexType>
</xs:schema>

As you can see the red colored elements are placed as a root elements. The only correct root element is the green element. First I thought it wouldn't be a problem because our messages where validating correctly, but that's because my messages started with the correct root element. If you send a message with one of the red ones, it will validate the message as 'correct' as well.  So a 'wrong' message like:

<Class2><Class2/>

and

<Class3><Class3/>

go through as 'correct', eventhough the only message we had in mind as correct is:

<class1>
<class2></class2>
<class3></class3>
</class1>

I tried to use other stereotypes and associations, but even in the example of the website (http://www.sparxsystems.com.au/resources/xml_schema_generation.html) it has the same problem. A message in this example could exists of an element like 'Employee' or 'ContactInfo' and nothing more.

What can I do about it without removing the not used root elements (the red ones) manually?


Joost

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
  • What can't be done has never happened
    • View Profile
Re: Generating a XSD from UML, root element proble
« Reply #1 on: April 10, 2006, 12:05:40 am »
I have this exact problem. Have you found a solution yet?

SF_lt

  • EA User
  • **
  • Posts: 216
  • Karma: +1/-0
  • The Truth Is Out There
    • View Profile
Re: Generating a XSD from UML, root element proble
« Reply #2 on: April 10, 2006, 03:33:02 am »
report this bug with the link to this thread
registertm everything to SparX

Yahraas

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Generating a XSD from UML, root element proble
« Reply #3 on: April 11, 2006, 02:35:51 am »
Hi, just to let you know that I've also faced this same problem and have reported the bug to EA.

Koning

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Generating a XSD from UML, root element proble
« Reply #4 on: April 12, 2006, 01:26:10 am »
I've got this reaction from the support team:

<Hello Koning,

Thanks for the note.

EA uses a style called "Garden of Eden" for generating Schemas. In this style, all the elements and types are declared globally like :

<xs:element name="Class1" type="Class1"/>
<xs:complexType name="Class1">
   <xs:sequence/>
</xs:complexType>

This style, hence, allows both elements and types to be reusable in schema which imports this one.
Currently, it is not possible to change this behaviour and hence you will have to manually delete all the roots which are not used.
But we will consider your issue as a feature request.

Hope this clarifies your issue. If you have any further issues, feel free to write-in.>