XSD to UML Transformation

General discussions about code engineering

Moderator: Moderators

XSD to UML Transformation

Postby srushworth@temenos.com » Mon Jun 27, 2011 9:41 am

I have an XSD file which I need to convert in to a UML model in Magicdraw (Architect evaluation version).
I can't seem to find a way to Import the file in to Magicdraw in order to run the Transformation tool.
Does Magicdraw support XSD conversion or do I need a different format?

Thanks

Sarah
srushworth@temenos.com
Forum Newbie
Forum Newbie
 
Posts: 3
Posts Rating:0
Joined: Mon Jun 27, 2011 9:38 am

Re: XSD to UML Transformation

Postby TomasJkn » Tue Jun 28, 2011 2:56 am

Hello Sarah,
This will be a two-step process.

First you need to reverse-engineer your XSD file into MagicDraw - to get the Schema model (this will be a UML model, heavily stereotyped with schema-specific stereotypes from MD's XML schema profile).

In the containment tree please find the Code Engineering Sets node. Rigtclick>new >XML schema (this creates new code engineering set).
Double-click the created set; in CE set specification dialog specify working directory (where your schema file is located), add your schema file(s) to the CE set. OK the dialog.
Then rightclick the CE set; click Reverse. Follow through dialog, choose various reversing options.

After the reversing you will have a model of your schema in MagicDraw.

Second step would be converting this platform-specific model (schema model, UML+stereotypes) into platform independent model (pure UML model).
For this, transformation can be used.
Menu Tools>Model Transformations.
Choose XML Schema -> UML transformation.
Specify the transformation source - the model part that you got after the reverse-engineering the schema.
Specify destination (e.g. create new package).
Next,Next the following two steps of transformation
Transformation will be run and result model will be placed in destination package.

Please note that transformation is not "all-powerful", "very smart". It is just a helper. Usually after transformation, some manual post-processing is still needed.

Sincerely,
Tomas Juknevicius
Senior Systems Analyst
No Magic Europe
TomasJkn
Customer Support
Customer Support
 
Posts: 63
Posts Rating:6
Joined: Mon May 10, 2010 9:24 am

Re: XSD to UML Transformation

Postby srushworth@temenos.com » Tue Jun 28, 2011 3:25 am

Thanks that works in that I get a UML model, however, I am not so sure how useful it is :(

All of the complex types have the type name followed by "_AnonymousType" and their class definitions have no attributes even though the schema file contains them. This would require a lot of hand-crafting which isn't advisable as we have a lot of schemas to convert.
Is there any way to get the complex types to transform corrctly?

Also, would I be able to do this via the command line in some way?

Thanks

Sarah
srushworth@temenos.com
Forum Newbie
Forum Newbie
 
Posts: 3
Posts Rating:0
Joined: Mon Jun 27, 2011 9:38 am

Re: XSD to UML Transformation

Postby TomasJkn » Wed Jun 29, 2011 8:19 am

Hello Sarah,

All of the complex types have the type name followed by "_AnonymousType"

Concerning the type names question:
The reversed type names are xxxxx_AnonymousType because your schema uses anonymous, ad hoc complex types for your elements.
Something like this:
Code: Select all
...
<xs:element name="gift">
<xs:complexType>   <!---- please observe that complex type has no name -->
  <xs:sequence>
   <xs:element name="birthday" type="xs:date"/>
....
  </xs:sequence>
</xs:complexType>
</xs:element>
...


If your schema would have non-anonymous, separately defined types with names, the reversed model elements would reflect that - reversed complex types would have their names set accordingly.
Example:
Code: Select all
...
<xs:complexType name="Gift">   <!---- please observe that complex type has name -->
<xs:sequence>
  <xs:element name="birthday" type="xs:date"/>
...
</xs:sequence>
</xs:complexType>
...
<xs:element name="gift" type="Gift"/>
...



and their class definitions have no attributes even though the schema file contains them.

Concerning attributes:
I am not sure what went wrong, I'd have to look at the example schema/resulting model. In theory attributes should be reversed no problem.
Are you sure that attributes did not get reversed - maybe you have reversed these to associations/association ends (these are visible as relationships in the diagram, not as properties in the box)?
If you could post an example , I'd have a look at it

Sincerely,
Tomas Juknevicius
Senior Systems Analyst
No Magic Europe
TomasJkn
Customer Support
Customer Support
 
Posts: 63
Posts Rating:6
Joined: Mon May 10, 2010 9:24 am

Re: XSD to UML Transformation

Postby srushworth@temenos.com » Thu Jun 30, 2011 3:57 am

Thanks for the reply.

Well I added the 'name' attribute to the complexType tags but I still get AnonymousType added to my names and no field attributes :(

I've attached my XSD file.
You do not have the required permissions to view the files attached to this post.
srushworth@temenos.com
Forum Newbie
Forum Newbie
 
Posts: 3
Posts Rating:0
Joined: Mon Jun 27, 2011 9:38 am


Return to Code engineering

Who is online

Users browsing this forum: No registered users and 0 guests