Load Mof / XMI files into Eclipse via EMF

I want to import / download a mof based xmi file that is exported by Enterprise Architect 8.

 ResourceSet resourceSet_xmi = new ResourceSetImpl();
resourceSet_xmi.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new EMOFResourceFactoryImpl());

File file = new File(fileName);
URI uri = file.isFile() ? URI.createFileURI(file.getAbsolutePath()) : URI.createURI("D:\\Documents and Settings\\broehl_w\\My Documents\\test.xmi");

try {
  // Demand load resource for this file.
  //
  Resource resource = resourceSet_xmi.getResource(uri, true);
  System.out.println("Loaded " + uri);
  resource.save(System.out, null);
}
catch (Exception exception) {
  System.out.println("Problem loading " + uri);
  exception.printStackTrace();
}

      

But it ends up with an exception:

 org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri 'null' not found.

      

Observe the actual XMI file (which was exposed) does not contain the uri.

Do I need this guide, but what uri?

Thanks in advance!

+3


source to share





All Articles