Create xmi file in runtime through saving [message #1720777] |
Wed, 20 January 2016 22:39  |
Parisa Moosavi Messages: 81 Registered: June 2015 |
Member |
|
|
Hi,
I want to save xmi file from the resource in doGenerate. Actually I want to save xmi file when the xtext dsl is saved.
I have changed doGenerate like this
override void doGenerate(Resource resource, IFileSystemAccess fsa) {
Helper.saveRecourceAsXmi(resource , resource.URI.path.toString().replace('gcorell','gcore'));
}
and I have developed an helper class
public class Helper {
public static void saveRecourceAsXmi( Resource resource , String strURI) {
try {
Map<String, String> saveOptions = new HashMap<String, String>();
Resource xmiResource = new XMIResourceImpl( URI.createFileURI("filename.myextension"));
xmiResource.getContents().add(resource.getContents().get(0));
saveOptions.put(org.eclipse.emf.ecore.xmi.XMLResource.OPTION_ENCODING, "UTF-8");
xmiResource.save(saveOptions);
System.out.println("Xmi file filename.myextension saved.");
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println("Durind saving Xmi file filename.myextension error has been occued.");
e.printStackTrace();
}
}
}
But it's some how strage I can't find the file, although it is run without exception. indeed I want to save it in the same folder as the resource.URI.Path.
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02268 seconds