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 AngaritaFriend
Messages: 94
Registered: November 2010
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/"), 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);

        EmfMetaModel metaModel = new EmfMetaModel(TGPackage.eINSTANCE);
        XpandExecutionContextImpl executionContext = new XpandExecutionContextImpl(output, null);
        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 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 project classes, I can't do that with 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 online Christian DietrichFriend
Messages: 7684
Registered: July 2009
Senior Member

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


[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 09 09:14:36 GMT 2015

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

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