Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » problem with multiple template files
problem with multiple template files [message #512057] Wed, 03 February 2010 13:31 Go to next message
Matthieu  is currently offline Matthieu
Messages: 10
Registered: February 2010
Junior Member
Hello,
I'm a new Xpand user and I try to describe Xpand tasks in several files.
Here is what I put in my workflow file :

<workflow>
	<bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" platformUri=".."/>
	
	<component class="org.eclipse.emf.mwe.utils.DirectoryCleaner" directory="src-gen"/>
	
	<component class="org.eclipse.xtext.MweReader" uri="classpath:/model/MyModel.pck">
		<!-- this class will be generated by the xtext generator -->
		<register class="fr.ifsic.m1info.PckDslStandaloneSetup"/>
	</component>
	
	<component class="org.eclipse.xpand2.Generator">
		<metaModel class="org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel"/>
		<fileEncoding value="UTF-8"/>
		 <expand value="templates::MemoryContext::memorycontext FOR model"/>
		 <expand value="templates::Format::formats FOR model"/>
		 <expand value="templates::Instruction::instructions FOR model"/>
		 <expand value="templates::Pipeline::pipeline FOR model"/>
		 <expand value="templates::Simulator::simulator FOR model"/>
		 <expand value="templates::Assembler::assembler FOR model"/>
		<genPath value="src-gen"/>
	</component>
</workflow>

so I have 6 files named Format.xpt, Instruction.xpt, Pipeline.xpt, Simulator.xpt and Assembler.xpt but it seems that, even if every file is read, only the last one generates something (does each task erase the results of the previous one ?).

Well, if someone can help me; it's more readable using several files than using one big template with a lot of definition. Is their simply a way to use in a particular file a definition described in another one, or something like that ? It would help...

Thanks !
Re: problem with multiple template files [message #512063 is a reply to message #512057] Wed, 03 February 2010 09:00 Go to previous messageGo to next message
Erhard Weinell is currently offline Erhard Weinell
Messages: 39
Registered: January 2010
Location: Kassel, Germany
Member
Hello Matthieu,

technically, all your expand invocations write to the same output (which
can be changed), so your observation is correct.

Simple solution: Add a "main"-template which invokes the other ones.
This way, all code generation aspects including the order of template
invocation can be controlled from the templates.

Best regards,
Erhard weinell
Re: problem with multiple template files [message #512078 is a reply to message #512057] Wed, 03 February 2010 15:09 Go to previous message
Matthieu  is currently offline Matthieu
Messages: 10
Registered: February 2010
Junior Member
Hello,

Thanks a lot for the solution, it works fine !

Regards,
Matthieu
Previous Topic:[Xpand]: FeatureNotFoundException in workflow when metamodel references Ecore metamodel
Next Topic:Neebee question: XMLBeautifier
Goto Forum:
  


Current Time: Tue Jul 22 23:58:58 EDT 2014

Powered by FUDForum. Page generated in 0.02620 seconds