Skip to main content


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 06:47 Go to next message
Thomas B is currently offline Thomas BFriend
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 06: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 06:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
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


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [XPAND] Ecore to Text with XPand [message #846573 is a reply to message #846551] Mon, 16 April 2012 07:21 Go to previous message
Thomas B is currently offline Thomas BFriend
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: Wed Apr 24 18:36:00 GMT 2024

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

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

Back to the top