Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » How to save UML2 model as XMI (standalone)
How to save UML2 model as XMI (standalone) [message #625856] Mon, 07 January 2008 23:33
Eclipse UserFriend
Originally posted by: jlansing.spawar.navy.mil

When I save my Model (from a standalone Java app) I don't get the top level
xmi:XMI element. Instead, the uml:Model element is at the top level.

I've tried using both .xmi and .uml extensions. (Interesting differences
result, but this isn't one of them).

My code is this:
public void save(Model model, String pathName) {
URI uri = URI.createURI("file:///" + pathName.replace('\\', '/'));
ResourceSetImpl resourceSet = new ResourceSetImpl();
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI,
UMLPackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(Ecore2XMLResource.FILE_EXTENSION,
Ecore2XMLResource.Factory.INSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(XMI2UMLResource.FILE_EXTENSION,
XMI2UMLResource.Factory.INSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(UMLResource.FILE_EXTENSION,
UMLResource.Factory.INSTANCE);
Resource resource = resourceSet.createResource(uri);
resource.getContents().add(model);
try {
resource.save(null);
} catch (IOException e) {
e.printStackTrace();
}
}

Obviously I've tried to mash together all the examples in the documentation
and what I've found in this newsgroup, but I'm still not getting it.
Previous Topic:Re: How do I model with UML 2 in eclipse?
Next Topic:Re: How do I model with UML 2 in eclipse?
Goto Forum:
  


Current Time: Fri Aug 12 12:34:55 GMT 2022

Powered by FUDForum. Page generated in 0.01696 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top