我想导入/加载一个由 Enterprise Architect 8 导出的基于 mof 的 xmi 文件。
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 文件(已被公开)不包含 uri。
我应该手动操作,但 uri 是什么?
提前致谢!