Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [m2m-atl-dev] ATL will not produce any output

Thanks for the answer @  http://stackoverflow.com/questions/22841706/atl-transformation-empty-output
I tryed to post to the ATL forum but I cannot create any topic, somehow the Forum is not working.


But I couldn't get it to run. Maybe you could tell me how to obtain the Model & MetaModel correctly from XText so that it is linked together and I could use it correctly for ATL?
Is is generally possible to use an xtext model with ATL? I'm stuck here for some weeks with try and error :(



Whatever I try, my output is always empty:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"/>


My Code:

// init xtext & stuff
HdlStandaloneSetup dsl = new org.xtext.hal.HdlStandaloneSetup();
Injector injector = dsl.createInjectorAndDoEMFRegistration();

EMFModelFactory emfFactory = new EMFModelFactory();
XMIResourceFactoryImpl xmiFactory = new XMIResourceFactoryImpl();

EMFExtractor extractor = new EMFExtractor();
EMFInjector emfInjector = new EMFInjector();


// get DSL content from xtext
XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);
Resource resource = resourceSet.getResource(URI.createURI("HdlData.hdl"), true);


// load model
EMFReferenceModel hdlMetaModel = (EMFReferenceModel) emfFactory.newReferenceModel();
emfInjector.inject(hdlMetaModel, resourceSet.getResource(URI.createURI("org.xtext.hal/model/generated/Hdl.ecore"), true));
EMFModel hdlData = (EMFModel) emfFactory.newModel(hdlMetaModel);

EMFReferenceModel palMetaModel = (EMFReferenceModel) emfFactory.newReferenceModel();
emfInjector.inject(palMetaModel, resourceSet.getResource(URI.createFileURI("org.xtext.hal/model/Pal.ecore"), true));
EMFModel palData = (EMFModel) emfFactory.newModel(palMetaModel);


// convert xtext content to xmi
Resource xmiResource = xmiFactory.createResource(URI.createURI("org.xtext.hal/model/generated/HdlData.xmi"));
xmiResource.getContents().addAll(hdlModel.getContents());
emfInjector.inject(hdlData, xmiResource);


// transform
InputStream asm = new FileInputStream("org.xtext.hal/model/Pal.asm");

EMFVMLauncher launcher = new EMFVMLauncher();

HashMap<String,Object> options = new HashMap<String,Object>();
options.put("showSummary", "true");
options.put("step", "true");

launcher.initialize(Collections.<String, Object> emptyMap());
launcher.addInModel(hdlData, "IN", "hdl");
launcher.addOutModel(palData, "OUT", "pal");
launcher.launch(ILauncher.DEBUG_MODE, new NullProgressMonitor(), options, asm);


// output
extractor.extract(palData, "palData.xmi");

Back to the top