通过EMF将Mof / XMI文件加载到Eclipse中

时间:2012-03-20 08:56:53

标签: eclipse xml-parsing enterprise-architect

我想导入/加载基于mof的xmi文件,该文件由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();
}

但它以例外结束:

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

观察实际的XMI文件(已经过期)包含no uri。

我应该这个manualy但是什么uri?

提前致谢!

0 个答案:

没有答案