title: Eclipse Modelling Framework (EMF): How to get the DomainModel from a Magicdraw UML2 Export
body: <p>I want to use the EMF for Code Generation, so I wrote some methods to load my UML2 File which I generated myself. This works fine with the following code:</p>
  
  <pre><code>protected void registerResources() {
      resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
  
      resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
  
      Map&lt;URI, URI&gt; uriMap = resourceSet.getURIConverter().getURIMap();
      String resourcesJarPath = Thread.currentThread().getContextClassLoader().getResource("org.eclipse.uml2.uml.resources_2.2.0.v200805131030").toExternalForm();
      URI baseUri = URI.createURI(resourcesJarPath);
      uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP), baseUri.appendSegment("libraries").appendSegment(""));
      uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP), baseUri.appendSegment("metamodels").appendSegment(""));
      uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP), baseUri.appendSegment("profiles").appendSegment(""));
  }
  
  public Package loadPackage(URI uri) {
      Resource resource = resourceSet.getResource(uri, true);
      return (Package) EcoreUtil.getObjectByType(resource.getContents(), UMLPackage.Literals.PACKAGE);
  }
  </code></pre>
  
  <p>But now, I wanted to export an Magicdraw-Domainmodel to an EMF UML2 XMI, and there I get 5 Files. One project.uml and 4 Profile Files (UML_Standard_Profile.MagicDraw_Profile.DSL_Customization.profile.uml, UML_Standard_Profile.MagicDraw_Profile.profile.uml, UML_Standard_Profile.UML_Standard_Profile.profile.uml, UML_Standard_Profile.Validation_Profile.profile.uml).
  So if I want to load the project.uml with the loadPackageclass, my Package is null.</p>
  
  <p>Does anyone have an example app, how to load an MagicDraw-exported UML DomainModel?</p>
  
  <p>Dominik</p>