Does UML2 XMI Export Support Classes In Profiles?

MagicDraw OpenAPI, scripting related questions and discussions

Moderator: Moderators

Does UML2 XMI Export Support Classes In Profiles?

Postby » Thu Mar 28, 2019 2:37 am

I had the following elements in a profile:

The Stereotype has a property typed by the Class Position. This seemed to display and work fine in Magicdraw, as shown in this example:

However, when I use the UML2 XMI export (v5), the exported model in the .uml file did not have the connection shown above. Additionally I got this message in the the Notifcations Window:
[2019.03.28::02:56:04] Eclipse UML2 XMI: startingPosition value not set for InstanceSpecification TestModel::Instance1::b52_1. Type=Class afsim::Position. Value=InstanceSpecification Model::TestModel::Instance1::dsf. Reason=org.eclipse.uml2_5_0_2.uml.internal.impl.InstanceSpecificationImpl@50385eae (name: dsf, visibility: public)

The "Reason" is not very clear, so I eventually decided to read the spec and found this:
Profile-defined Types can only be used as the type of Properties in that Profile or as a general classifier of another
Profile-defined Type. They cannot be used as Types in models the Profile is applied to, such as the type of a
TypedElement, the classifier of an InstanceSpecification or the general or specific classifier in a Generalization

So my first question is, am I correct in thinking this is the cause of my issue? The spec seems pretty clear, but I still wanted to ask because it appears that Magicdraw actually does allow you to do this (and does not show any warnings or errors after running validation).

If the answer to my first quest is "yes", then my follow up question is, how can I work around this? The spec actually provides the following suggested work around:

It is however possible to define these types in separate Packages and import them as needed in both
Profiles and model Packages in order to use them for both purposes.

But I doesn't give any more details. I tried moving the Position class to a subpackage within the profile, and then manually created package import relationships, but that resulted in this new error:

Eclipse UML2 XMI: startingPosition value not set for InstanceSpecification TestModel::Instance1::b52_1. Type=Class afsim::test::Position. Value=InstanceSpecification Model::TestModel::Instance1::dsf. Reason=Stereotype (property owner) and property type are from different profiles.

Does it need to be in a completely different project? And does the containing package need to be marked with <<modelLibrary>> or something? I am running Cameo 18.5 in case it matters. Thanks for any help you can provide.
You do not have the required permissions to view the files attached to this post.
Forum Newbie
Forum Newbie
Posts: 13
Posts Rating:3
Joined: Thu Jun 29, 2017 3:40 pm

Return to Programmatic Extendibility

Who is online

Users browsing this forum: No registered users and 3 guests