Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Xpand] Template could not be found
[Xpand] Template could not be found [message #639469] Tue, 16 November 2010 16:56 Go to next message
Rafael Angarita is currently offline Rafael Angarita
Messages: 94
Registered: November 2010
Member
Hello everybody,

I created a simple Xtext project and exported its three generated projects as plugins. Then, I created a Java project which adds the Xtext Nature of my plugin.

I'm able to use Xtext programmatically after loading the model this way:

private Model loadModel() {
		new org.eclipse.emf.mwe.utils.StandaloneSetup().setPlatformUri("../");
		Injector injector = new TGStandaloneSetup().createInjectorAndDoEMFRegistration();
		XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);
		resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
		
		Resource resource = resourceSet.getResource(
			    URI.createURI("platform:/resource/JavaX/src/example.tg"), true);
		
		return (Model) resource.getContents().get(0);
	


Now, I would like to generate code from my model using XpandFacade. This is my code for that:

Model model = loadModel();

        // XPand
        String outputFolder = "output";
        OutputImpl output = new OutputImpl();
        Outlet outlet = new Outlet(outputFolder);
        outlet.setOverwrite(true);
        output.addOutlet(outlet);

        EmfMetaModel metaModel = new EmfMetaModel(TGPackage.eINSTANCE);
        XpandExecutionContextImpl executionContext = new XpandExecutionContextImpl(output, null);
        executionContext.registerMetaModel(metaModel);
        
        XpandFacade facade = XpandFacade.create(executionContext);
        facade.evaluate("templates::Template::main", model.getTables().get(0));


but Im getting the next exception

Exception in thread "main" EvaluationException : No Definition templates::Template::main for tG::Table could be found!
	Internal error : element was null



That template is in the package src.templates of the org.xtext.example.tg.generator project (exported as a plugin).

I do not know if the template should be there. The other thing is that while I am able to import the org.xtext.example.tg project classes, I can't do that with org.xtext.example.tg.generator classes.

I would appreciate any help.

Thank you very much.





Re: [Xpand] Template could not be found [message #639541 is a reply to message #639469] Tue, 16 November 2010 20:20 Go to previous message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6388
Registered: July 2009
Senior Member
Hi,

are you sure the template uses the emf metamodel? xtext by default uses javabeansmetamodel for the xpand generator project.

~Christian

[Updated on: Tue, 16 November 2010 20:20]

Report message to a moderator

Previous Topic:[Acceleo] ESE2010 Tutorial
Next Topic:Incremental Gen. throws nullPointer
Goto Forum:
  


Current Time: Fri Oct 24 18:09:27 GMT 2014

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

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