I am trying to generate a java program to implement a State Machine from a UML model using Acceleo.
In my model I have entries like:--
<subvertex xmi:type="uml:State" xmi:id="{BB1999-E740-4e7d-A1BE-F099BEXYD970}" name="WaitingApproval">
I want to check the value of "xmi:type" but I cannot work out how to access this from Acceleo. (I have tried every combination of gets I can think of and the type only appears as part of a longer string if I dump the whole vertex.)
If you are on the
subvertex
relation, you must be on aRegion
. Thexmi:type
is the way XMI handles polymorphic references. Assubvertex
is defined asVertex [*]
, XMI must specify the type of each element in the collection. To check this field, you simply need to test the type of the element (usingoclIsTypeOf
oroclIsKindOf
)So, from a
Region
:Also, you can handle them in different templates by adding template guard:
you can also avoid guard by rewriting the above templates as this:
EDIT
If you absolutely want the type value in a String format, you have to go check the element metaclass and ask for its name: