How to interact with metamodel.ecore and Model.xmi elements in one template [message #975014] |
Wed, 07 November 2012 14:26 |
Adnan AL-SOSWA Messages: 41 Registered: May 2010 |
Member |
|
|
Hello all ,
I have question concerning xpand , I have create a metamodel with the some eclasses , attributes and references . after that I create a dynamic instance of the metamodel to generate Model.xmi and I built the model.xmi according to the structure of the metamodel.My question how I can combine between the elements of the Metamodel and the Model.xmi in one template file .
Ex . I have eclass called Entity in my metamodel
and I have created three Entities Students, lectures, Lecturers in my Model.xmi
I want to generate with xpand somthing like
Entity (no , Students)
Entity (no , lectures)
Entity (no , Lecturers)
and this should be automatically , i tried some code here
«DEFINE main FOR ecore::EPackage»
«FILE name+".txt"»
«EXPAND classifier FOREACH eClassifiers.typeSelect(ecore::EClass) »
«ENDFILE»
«ENDDEFINE»
«DEFINE classifier FOR ecore::EClass»
«name» (#no ,«EXPAND class FOREACH name »
«ENDDEFINE»
«DEFINE class FOR name »
«name»
«ENDDEFINE»
I have a mistake in the second xpand statment that name is not collection , but how a can get all the entities that I defined ?
|
|
|
Re: How to interact with metamodel.ecore and Model.xmi elements in one template [message #976275 is a reply to message #975014] |
Thu, 08 November 2012 12:56 |
|
I guess you are mixing things. The Xpand definitions would not be declared for Ecore, but for concepts of your metamodel, here: Entity.
«DEFINE main FOR MyModel»
«FILE name+".txt"»
«EXPAND classifier FOREACH eAllContents.typeSelect(Entity) »
«ENDFILE»
«ENDDEFINE»
«DEFINE classifier FOR mymetamodelpackage::Entity»
«name»
«ENDDEFINE»
"name" is a single-valued attribute. FOREACH expects a collection.
Install the Xpand sample project (File / New / Xpand Project) and look as reference there.
Regards,
~Karsten
Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
[Updated on: Thu, 08 November 2012 13:01] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03721 seconds