Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Load xmi file of UML2 Model
Load xmi file of UML2 Model [message #603173] Mon, 26 March 2007 15:57
Eclipse UserFriend
Originally posted by: sliles.gmu.edu

Hello,
I cannot find any example code that explains how to load an existing
..xmi. If you have a link that can explain this read not further and send me
the link. If not read on and look at the code a cobbled together by looking
at the javadoc for UML2 and EMF. Thanks in advance!!
I have worked through the getting started with UML2 article. I
understand what is covered there. I am interested in reading an existing
model using the API then using the API to access the various parts of the
model. Specifically I will be looking through the activity diagram for
specific information and translating to another form. I think once I get it
loaded the examples for the "Getting Started with UML2" article will be much
more applicable to my application.

Here is my code for reading an xmi file that came from rational system
developer. The header is reproduced below.
<uml:Model xmi:version="2.1"
xsi:schemaLocation="http://schema.omg.org/spec/UML/2.1.1
http://www.eclipse.org/uml2/2.0.0/UML" xmi:id="_YjKpJNiXEduqsZWui7bccg"
name="SmallPrototype">

CODE for loadModel.

public Model loadModel() {
String file = "Simple.xmi";
ResourceSet resourceSet = new ResourceSetImpl();
Resource.Factory.Registry rfr = new ResourceFactoryRegistryImpl();
resourceSet.setResourceFactoryRegistry(rfr);
URI uri = URI.createFileURI(file);

rfr.getFactory(uri);
resourceSet.setResourceFactoryRegistry(rfr);
Resource resource = resourceSet.getResource(uri, true);
model = (Model)
org.eclipse.emf.ecore.util.EcoreUtil.getObjectByType(resourc e.getContents(),
org.eclipse.uml2.uml.UMLPackage.Literals.MODEL);

return model;
}//end loadModel

Thanks,
Stewart Liles
Previous Topic:Programmatically create port
Next Topic:Load xmi file of UML2 Model
Goto Forum:
  


Current Time: Wed Apr 01 15:51:57 GMT 2020

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

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

Back to the top