Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » (Xpand) How to access ecore.ecore via Xpand code
(Xpand) How to access ecore.ecore via Xpand code [message #947995] Wed, 17 October 2012 16:50 Go to next message
Adnan AL-SOSWA is currently offline Adnan AL-SOSWAFriend
Messages: 41
Registered: May 2010
Member
Hi all ,
I have a question about Xpand language . Is it possible that Xpand access the elements of a ecore metamaodel for example ecore.ecore , which does not have model.XMI ? ,attache ecore metamodel ecore.ecore

Thanks in advance

index.php/fa/11955/0/
  • Attachment: Ecore.ecore
    (Size: 31.05KB, Downloaded 305 times)
  • Attachment: ecore.png
    (Size: 39.37KB, Downloaded 568 times)
Re: (Xpand) How to access ecore.ecore via Xpand code [message #948019 is a reply to message #947995] Wed, 17 October 2012 17:21 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,
i dont get your point. the ecore.ecore is the model.xmi

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: (Xpand) How to access ecore.ecore via Xpand code [message #948065 is a reply to message #948019] Wed, 17 October 2012 18:23 Go to previous messageGo to next message
Adnan AL-SOSWA is currently offline Adnan AL-SOSWAFriend
Messages: 41
Registered: May 2010
Member
Hi Christian,
the model.xmi is the instance of the metammodel ,by creating dynamic instance , my question is how I got all elements of metamodel via Xpand without creating model.xmi , as I want the generated code to access the metamodel elements and not the model.xmi ?



Re: (Xpand) How to access ecore.ecore via Xpand code [message #948069 is a reply to message #948065] Wed, 17 October 2012 18:24 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Can you give an example?

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: (Xpand) How to access ecore.ecore via Xpand code [message #948170 is a reply to message #948069] Wed, 17 October 2012 20:36 Go to previous messageGo to next message
Adnan AL-SOSWA is currently offline Adnan AL-SOSWAFriend
Messages: 41
Registered: May 2010
Member
Hi ,
For example in my template I want to write something like
for all elements in Ecore
Node_def(element,'attri','attri')
How I can traverse all elements with their attributes .
For the Example of xpand proposed in Eclipse when I create xpand project and choose Generate a sample EMF based on xpand project , I have the metamodel.ecore and when I want to create model.xmi , I choose Eclass "Model" and create dynamic instance from it and continue build my model.xmi accoeding to the structure of metamodel .
but in metamodel ecore.ecore I can not create Model.xmi from it .as I do not know
Which Eclass in ecore.ecore should I choose to create dynamic instance . How I can access ecore.ecore programatically via Xpand
sorry for my bad english and bad explanation Embarrassed
Re: (Xpand) How to access ecore.ecore via Xpand code [message #948181 is a reply to message #948170] Wed, 17 October 2012 20:49 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

still the question do you want to generate from ecore.ecore as model our from your.ecore an model?
in both cases read the .ecore file and write a template
that operates on EPackages EClasses ......

e.g. for the example project

«DEFINE main FOR ecore::EPackage»
«FILE name+".txt"»
EPackage «name»
EClasses «eClassifiers.typeSelect(ecore::EClass).name.toString(",")»
«ENDFILE»
«ENDDEFINE»


<?xml version="1.0"?>
<workflow>
	<property name="model" value="my.generator.project/src/metamodel/metamodel.ecore" />
	<property name="src-gen" value="src-gen" />
	
	<!-- set up EMF for standalone execution -->
	<bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" >
		<platformUri value=".."/>
	</bean>
	
	<!-- instantiate metamodel -->
	<bean id="mm_emf" class="org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel"/>

	<!-- load model and store it in slot 'model' -->
	<component class="org.eclipse.emf.mwe.utils.Reader">
		<uri value="platform:/resource/${model}" />
		<modelSlot value="model" />
	</component>


	<!--  generate code -->
	<component class="org.eclipse.xpand2.Generator">
		<metaModel idRef="mm_emf"/>
		<expand
			value="template::Template::main FOR model" />
		<outlet path="${src-gen}" >
			<postprocessor class="org.eclipse.xpand2.output.JavaBeautifier" />
		</outlet>
	</component>
</workflow>


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: (Xpand) How to access ecore.ecore via Xpand code [message #953929 is a reply to message #948181] Mon, 22 October 2012 16:49 Go to previous message
Adnan AL-SOSWA is currently offline Adnan AL-SOSWAFriend
Messages: 41
Registered: May 2010
Member
Thanks christian , yes it to generate from ecore.ecor as in your example , thanks again
Previous Topic:Model without a root object
Next Topic:How to generate/modify c code from XML?
Goto Forum:
  


Current Time: Thu Apr 25 09:08:57 GMT 2024

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

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

Back to the top