[ATL] XSD to ECORE ATL transformation [message #985913] |
Fri, 16 November 2012 11:34 |
Eclipse User |
|
|
|
Hi,
I have an ATL transformation that works just fine under the ATL run configuration with these informations:
As input Metamodel i have a XSD file
As output Metamodel a Ecore Metamodel
The problem is when i try to launch the ATL transformation programmatically within a Java application it does not work.
here is the java code i use:
/****************************
try {
CoreService.registerLauncher("EMF-specific VM", EMFVMLauncher.class);
CoreService.registerFactory("EMF", EMFModelFactory.class);
CoreService.registerExtractor("EMF", EMFExtractor.class);
CoreService.registerInjector("EMF", EMFInjector.class);
injector = CoreService.getInjector("EMF");
extractor = CoreService.getExtractor("EMF");
} catch (ATLCoreException e) {
e.printStackTrace();
}
ModelFactory factory = CoreService.getModelFactory("EMF");
sourceMetamodel = factory.newReferenceModel();
targetMetamodel = factory.newReferenceModel();
injector.inject(sourceMetamodel, sourceFilepath);
injector.inject(targetMetamodel, targetFilepath);
ILauncher launcher = null;
launcher = (EMFVMLauncher)CoreService.getLauncher("EMF-specific VM");
launcher.initialize(Collections.<String, Object> emptyMap());
IModel sourceModel = factory.newModel(sourceMetamodel);
IModel targetModel = factory.newModel(targetMetamodel);
injector.inject(sourceModel, dataSourceFilepath);
launcher.addInModel(sourceModel, LauncherATLIn, LauncherInMMName);
launcher.addOutModel(targetModel, LauncherATLOut, LauncherOutMMName);
URL asmFile = new File(transformationFilepath).toURI().toURL();
Object loadedModule = launcher.loadModule(asmFile.openStream());
launcher.launch(ILauncher.RUN_MODE, new NullProgressMonitor(), Collections.<String, Object> emptyMap(), loadedModule);
extractor.extract(targetModel, dataTargetfilepath);
}
/****************************
It works just fine when i have only Ecores as Metamodels (input and output), but it does not work when i use an XSD as input. I know i should change something to specify that i am using an XSD and not an ECORE but i do not know what to change ? (I suppose that i should change the registerLauncher or/and the model factory parameter from EMF to something but what ?)
Any ideas ?
Thank you in advance.
|
|
|
Powered by
FUDForum. Page generated in 0.02878 seconds