If you are on the subvertex
relation, you must be on a Region
. The xmi:type
is the way XMI handles polymorphic references. As subvertex
is defined as Vertex [*]
, 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 (using oclIsTypeOf
or oclIsKindOf
)
So, from a Region
:
[template public test(r : Region)]
[r.subvertex->filter(State)/] --> filter all States from the subvertex collection
which is equ. to
[r.subvertex->select(oclIsKindOf(State))/]
and if you want only the State elements (no subclasses)
[r.subvertex->select(oclIsTypeOf(State))/]
[/template]
Also, you can handle them in different templates by adding template guard:
[template public test(r : Region)]
[r.subvertex.test2()/]
[/template]
[template public test2(s : Vertex) ? (oclIsKindOf(State))]
[s/] is a state for sure
[/template]
you can also avoid guard by rewriting the above templates as this:
[template public test(r : Region)]
[r.subvertex.test2()/]
[/template]
[template public test2(v : Vertex)/]
[template public test2(s : State)]
[s/] is a state for sure
[/template]
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:
...
[s.eClass().name/] -> result as String, s.eClass() gets the EClass
...