Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » how to get object instead of the auto-generated code from the value of XMIReferenceAttribute in uml
how to get object instead of the auto-generated code from the value of XMIReferenceAttribute in uml [message #756524] Mon, 14 November 2011 08:18
binghu79448981 is currently offline binghu79448981Friend
Messages: 1
Registered: November 2011
Junior Member
I want transform a UML model with stereotypes to a custom-formatted text file, using Eclipse plugin of IBM MTF(Model Transformation Framework).
My Profile is shown as Picture.1. There are two Stereotypes in my Profile. The first stereotype named "A" is extended from UML::Class. The second stereotype named "B" is extended from uml:DataType. The stereotype "A" has a stereotypeProperty named tag, which type is testProfile::B.

index.php/fa/6124/0/

Then I create an uml model, which is shown in Picture.2. There is a class named "class1" with stereotype "A" applied and a datyType named "datatype1" with stereotype "B" appied in my uml model. As "class1" apply stereotype "A", it has an stereotypeProperty named "Tag". I choose <<B>><DataType>datatype1 as the value of stereotypeProperty "tag". The uml model file is as follow.

index.php/fa/6125/0/


<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.1" xmlns:xmi="....schema.omg.org/spec/XMI/2.1" xmlns:xsi="....www.w3.org/2001/XMLSchema-instance" xmlns:ecore="....www.eclipse.org/emf/2002/Ecore" xmlns:testProfile="....schemas/testProfile/_P6SGMA6NEeGw4Yx38G5qQg/0" xmlns:uml="....www.eclipse.org/uml2/2.0.0/UML" xsi:schemaLocation="....schemas/testProfile/_P6SGMA6NEeGw4Yx38G5qQg/0 testProfile.profile.uml#_P6SGMg6NEeGw4Yx38G5qQg">
<uml:Model xmi:id="_L9_20A6NEeGw4Yx38G5qQg" name="test">
<packagedElement xmi:type="uml:Class" xmi:id="_VPhFgA6NEeGw4Yx38G5qQg" name="class1"/>
<packagedElement xmi:type="uml:DataType" xmi:id="_ZU4YYA6NEeGw4Yx38G5qQg" name="datatype1"/>
<profileApplication xmi:id="_XdFJQA6NEeGw4Yx38G5qQg">
<eAnnotations xmi:id="_XdFJQQ6NEeGw4Yx38G5qQg" source="....www.eclipse.org/uml2/2.0.0/UML">
<references xmi:type="ecore:EPackage" href="testProfile.profile.uml#_P6SGMg6NEeGw4Yx38G5qQg"/>
</eAnnotations>
<appliedProfile href="testProfile.profile.uml#_PijYIQ6MEeGw4Yx38G5qQg"/>
</profileApplication>
</uml:Model>
<testProfile:A xmi:id="_YJVLQA6NEeGw4Yx38G5qQg" base_Class="_VPhFgA6NEeGw4Yx38G5qQg" tag="_bHBrcA6NEeGw4Yx38G5qQg"/>
<testProfile:B xmi:id="_bHBrcA6NEeGw4Yx38G5qQg" base_DataType="_ZU4YYA6NEeGw4Yx38G5qQg"/>
</xmi:XMI>

I traverse the uml model to transporm it into txt file with specific format. By traverse over uml::model.packagedElement I reached <<A>><class>class1. Then traverse over class1.stereotypeProperties I reached its stereotypeProperty with name "tag". Now I want to get the value of stereotypeProperty "tag", <<B>><DataType>datatype1, and put the text "datatype1" into my txt file, but there is a problem which troubled me. When i pass the value of stereotypeProperty "tag"(abbreviated as sp1.value) into my rule function, only the parameter with type of emf::EObject can accept sp1.value, when i print out sp1.value in my rule function, I got "org.elipse .emf.ecore.impl.DynamicEObjectImple @ 101051u(eClass:org.eclipse.emf.ecore.impl.EClassImpl @ ca1a93(name:B)(instanceClassName:null)(abstract:false,interface:false))". Then I print out sp1.value.xmi_id, I got " _bHBrcA6NEeGw4Yx38G5qQg", which is the xmi_id of an testProfile:B node in my uml model file.
Then by traverse over uml::model.packagedElement I can reach <<B>><DataType>datatype1 and can get its name "datatype1" and its xmi_id is " _ZU4YYA6NEeGw4Yx38G5qQg". Then traverse over <<B>><DataType>datatype1.stereotypeProperties I reached its stereotypeProperty with name "base_DatyType". the value of stereotypeProperty "base_DatyType"(abbreviated as sp2.value) is "org.eclipse.uml2.uml.internal.impl.DataTypeImpl @ 196c8c2 (name: datatype1, visibility: <unset>) (isLeaf: false, visibility: public, isAbstract: false)", sp2.value.xmi_id is " _ZU4YYA6NEeGw4Yx38G5qQg".

My question is how can i get the DatyType name "datatype1" from the value of XMIReferenceAttribute, "sp1", or when i has "_bHBrcA6NEeGw4Yx38G5qQg", how can i get "datatype1" or "_ZU4YYA6NEeGw4Yx38G5qQg" from it. As I make sp1.value as an EObject, it only have three property, "resource","uri","xmi_id",all of can not slove my problem.
  • Attachment: 1.jpg
    (Size: 92.33KB, Downloaded 1663 times)
  • Attachment: 2.jpg
    (Size: 80.78KB, Downloaded 1663 times)

[Updated on: Mon, 14 November 2011 08:29]

Report message to a moderator

Previous Topic:[Xtend2] blog and screencast
Next Topic:[Acceleo]
Goto Forum:
  


Current Time: Fri Apr 26 22:32:23 GMT 2024

Powered by FUDForum. Page generated in 0.02971 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top