Hi,
there are some things mixed up in your sample. to work on a concrete example i built my own ecore
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="a"
nsURI="a" nsPrefix="a">
<eSubpackages name="b" nsURI="b" nsPrefix="b">
<eSubpackages name="c" nsURI="c" nsPrefix="c">
<eClassifiers xsi:type="ecore:EClass" name="D"/>
</eSubpackages>
</eSubpackages>
</ecore:EPackage>
In your Generator class you mix up Static and dynamic emf
(there should be a warning / error on the console). i chan ged it to
public static void main(String[] args) {
OutputImpl output = new OutputImpl();
Outlet outlet = new Outlet("D:\\src-gen");
output.addOutlet(outlet);
XpandExecutionContextImpl context = new XpandExecutionContextImpl(output, null);
// register meta model
EmfMetaModel mm = new EmfMetaModel();
mm.setMetaModelPackage(CPackage.class.getName());// meta model is on build path
context.registerMetaModel(mm);
// invoke Xpand Template
XpandFacade facade = XpandFacade.create(context);
facade.evaluate("test::test", CFactory.eINSTANCE.createD()); //template is on build path
}
but you have to change the template to use only one package too,
«DEFINE test FOR c::D»
«FILE "test.txt"»
«ENDFILE»
«ENDDEFINE»
an easy possibility to use full package names is to switch to the javabeans metamodel
public static void main(String[] args) {
OutputImpl output = new OutputImpl();
Outlet outlet = new Outlet("D:\\src-gen");
output.addOutlet(outlet);
XpandExecutionContextImpl context = new XpandExecutionContextImpl(output, null);
// register meta model
context.registerMetaModel(new JavaBeansMetaModel());
// invoke Xpand Template
XpandFacade facade = XpandFacade.create(context);
facade.evaluate("test::test", CFactory.eINSTANCE.createD()); //template is on build path
}
this should be not problem since you are using static emf / emf java classes.
~Christian