Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [XPAND] Ecore to Text with XPand
[XPAND] Ecore to Text with XPand [message #846544] Mon, 16 April 2012 02:47 Go to next message
Thomas B is currently offline Thomas B
Messages: 9
Registered: March 2012
Junior Member
Hello together,
is it possible, directly read a Ecore-File with XPand and generate from this Ecore-File the code?
Is there anywhere a example or can anybody give me a little code-example.

Thanks for the help.

[Updated on: Mon, 16 April 2012 02:48]

Report message to a moderator

Re: [XPAND] Ecore to Text with XPand [message #846551 is a reply to message #846544] Mon, 16 April 2012 02:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6144
Registered: July 2009
Senior Member
Hi,

i do not understand your problem.
this is a 100% straight forward task

<?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>

«IMPORT ecore»

«DEFINE main FOR EPackage»
«EXPAND javaClass FOREACH eClassifiers»
«ENDDEFINE»

«DEFINE javaClass FOR EClassifier»
	«FILE name+".java"»
		public class «name» {
			
		}
	«ENDFILE»
«ENDDEFINE»


~Christian
Re: [XPAND] Ecore to Text with XPand [message #846573 is a reply to message #846551] Mon, 16 April 2012 03:21 Go to previous message
Thomas B is currently offline Thomas B
Messages: 9
Registered: March 2012
Junior Member
Hi Christian,
thanks for your help and the example.
I see that my directory-structure was false. Now the code works.
Thanks
Previous Topic:[Acceleo] Nothing is generated
Next Topic:[Acceleo] - change file access rights from within Acceleo
Goto Forum:
  


Current Time: Thu Jul 31 15:57:36 EDT 2014

Powered by FUDForum. Page generated in 0.01736 seconds