Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Import XMI 
| Import XMI [message #88448] | 
Fri, 06 July 2007 10:59   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Originally posted by: kevin.m.meredith.lmco.com 
 
I would like to import XMI to Eclipse, specifically RSA, however this  
error appears when attempting to load it via Java code. 
 
Package with uri 'http://schema.omg.org/spec/UML/2.1.1' not found 
 
I believe that the project being created via Java is a Java project, not  
the desired UML project. 
 
Please help me to specify that my Java code will specify that a UML model  
is to be created. 
 
Here's my code: 
 
/* 
 * Main.java 
 * 
 * Created on July 5, 2007, 3:37 PM 
 * 
 * To change this template, choose Tools | Template Manager 
 * and open the template in the editor. 
 */ 
 
package loadxmi; 
import java.io.File; 
import java.io.IOException; 
//import java.net.URI; 
import org.eclipse.emf.common.util.URI; 
import java.util.Collections; 
//import org.eclipse.emf.*; 
import org.eclipse.emf.ecore.resource.*; 
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; 
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; 
import org.eclipse.emf.ecore.EAttribute; 
import org.eclipse.emf.ecore.EClass; 
import org.eclipse.emf.ecore.EPackage; 
import org.eclipse.emf.ecore.EReference; 
 
/** 
 * 
 * @author mereditk 
 */ 
public class Main { 
     
    /** Creates a new instance of Main */ 
    public Main() { 
    } 
     
    /** 
     * @param args the command line arguments 
     */ 
    public static void main(String[] args) { 
     
    // Create a resource set. 
    ResourceSet resourceSet = new ResourceSetImpl(); 
 
    // Register the default resource factory -- only needed for  
stand-alone! 
     
 resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( 
    Resource.Factory.Registry.DEFAULT_EXTENSION, new  
XMIResourceFactoryImpl()); 
 
    // Register the package -- only needed for stand-alone! 
    //LibraryPackage libraryPackage = LibraryPackage.eINSTANCE; 
 
    // Get the URI of the model file. 
    //URI fileURI = URI.createFileURI(new File("c:/documents and  
settings/mereditk/desktop/jfacc.xmi").getAbsolutePath()); 
    //URI fileURI = URI.createFileURI(new  
File("e:/tif/KevinMeredith/Samples/xmi/UPDM  
Example.xmi").getAbsolutePath()); 
    URI fileURI = URI.createFileURI(new File("C:/Documents and  
Settings/mereditk/Desktop/abc2.xmi").getAbsolutePath()); 
    // Demand load the resource for this file. 
     Resource resource = resourceSet.getResource(fileURI, true);     
            
	   // Print the contents of the resource to System.out. 
	   try 
	   { 
	     resource.save(System.out, Collections.EMPTY_MAP); 
	   } 
	   catch (IOException e) {} 
    } 
     
}
 |  
 |  
  |  
| Re: Import XMI [message #88464 is a reply to message #88448] | 
Fri, 06 July 2007 11:07    | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Originally posted by: merks.ca.ibm.com 
 
Kevin, 
 
Please use the UML2 newsgroup for questions about UML.  I've added it to  
the "to" list of the reply, so there's no need to repost the question.   
I'm pretty sure they have migration documentation that describes how to  
do this, so be sure to check out what's available:   
http://wiki.eclipse.org/index.php/MDT-UML2 
 
 
 
Kevin M wrote: 
> I would like to import XMI to Eclipse, specifically RSA, however this  
> error appears when attempting to load it via Java code. 
> 
> Package with uri 'http://schema.omg.org/spec/UML/2.1.1' not found 
> 
> I believe that the project being created via Java is a Java project,  
> not the desired UML project. 
> 
> Please help me to specify that my Java code will specify that a UML  
> model is to be created. 
> 
> Here's my code: 
> 
> /* 
> * Main.java 
> * 
> * Created on July 5, 2007, 3:37 PM 
> * 
> * To change this template, choose Tools | Template Manager 
> * and open the template in the editor. 
> */ 
> 
> package loadxmi; 
> import java.io.File; 
> import java.io.IOException; 
> //import java.net.URI; 
> import org.eclipse.emf.common.util.URI; 
> import java.util.Collections; 
> //import org.eclipse.emf.*; 
> import org.eclipse.emf.ecore.resource.*; 
> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; 
> import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; 
> import org.eclipse.emf.ecore.EAttribute; 
> import org.eclipse.emf.ecore.EClass; 
> import org.eclipse.emf.ecore.EPackage; 
> import org.eclipse.emf.ecore.EReference; 
> 
> /** 
> * 
> * @author mereditk 
> */ 
> public class Main { 
>       /** Creates a new instance of Main */ 
>    public Main() { 
>    } 
>       /** 
>     * @param args the command line arguments 
>     */ 
>    public static void main(String[] args) { 
>       // Create a resource set. 
>    ResourceSet resourceSet = new ResourceSetImpl(); 
> 
>    // Register the default resource factory -- only needed for  
> stand-alone! 
>     
>  resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( 
>    Resource.Factory.Registry.DEFAULT_EXTENSION, new  
> XMIResourceFactoryImpl()); 
> 
>    // Register the package -- only needed for stand-alone! 
>    //LibraryPackage libraryPackage = LibraryPackage.eINSTANCE; 
> 
>    // Get the URI of the model file. 
>    //URI fileURI = URI.createFileURI(new File("c:/documents and  
> settings/mereditk/desktop/jfacc.xmi").getAbsolutePath()); 
>    //URI fileURI = URI.createFileURI(new  
> File("e:/tif/KevinMeredith/Samples/xmi/UPDM  
> Example.xmi").getAbsolutePath()); 
>    URI fileURI = URI.createFileURI(new File("C:/Documents and  
> Settings/mereditk/Desktop/abc2.xmi").getAbsolutePath()); 
>    // Demand load the resource for this file. 
>     Resource resource = resourceSet.getResource(fileURI, true);     
>                  // Print the contents of the resource to System.out. 
>        try 
>        { 
>          resource.save(System.out, Collections.EMPTY_MAP); 
>        } 
>        catch (IOException e) {} 
>    } 
>    } 
>
 |  
 |  
  |   |  
| Re: Import XMI [message #88494 is a reply to message #88479] | 
Fri, 06 July 2007 11:30    | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Originally posted by: merks.ca.ibm.com 
 
Kevin, 
 
It seemed pretty clear you were trying to read an instance of a UML2  
model given the package not found error involving the UML namespace. In  
general, to read an XMI file you need an Ecore model for the type of  
data in the file.    I suspect you should be registering  
XMI2UMLResource.Factory.INSTANCE... 
 
 
Kevin M wrote: 
> Mr. Merks, 
> 
> I appreciate your swift replies, however I do not understand how the  
> act of importing an XMI file to Eclipse/Rational Software Architect  
> does not fall under Eclipse Modeling Framework. 
> 
> Obviously your knowledge of Eclipse exceeds mine. Do you understand  
> that I'm attempting to import an XMI file to RSA using Java code? One  
> recurring error that I've encountered is, "Package with uri  
> 'http://schema.omg.org/spec/UML/2.1.1' not found." I respectfully  
> state so because I am attempting a very simple task, so I hope that  
> you're not misinterpreting my simple objective and convoluting it. 
> 
> I know that the XMI file can be imported to RSA, since I just did so  
> manually in RSA after I created a UML project, then used the Import  
> command for an XMI file. 
> 
> Please help me to rephrase my question in the UML forum so that I can  
> be fully helped. 
> 
> I continue to appreciate your help! 
> 
> Thanks, 
> Kevin 
>
 |  
 |  
  |   |  
| Re: Import XMI [message #88536 is a reply to message #88521] | 
Fri, 06 July 2007 14:05    | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Originally posted by: merks.ca.ibm.com 
 
Kevin, 
 
I'm not expert at how to use UML2, but I assume you'd use  
XMI2UMLResource.Factory.INSTANCE  in place of "new  
XMIResourceFactoryImpl()".  There might be other setup things you need  
to do, so best to look for documentation or wait until Kenn or James  
provides more details. 
 
 
Kevin M wrote: 
> Mr. Merks, how would XMI2UMLResource.Factory.INSTANCE be registered  
> with respect to this code? 
> 
> Should the XMIResource class be used? Please give a code snippet. 
> /* 
> * Main.java 
> * 
> * Created on July 5, 2007, 3:37 PM 
> * 
> * To change this template, choose Tools | Template Manager 
> * and open the template in the editor. 
> */ 
> 
> package loadxmi; 
> import java.io.File; 
> import java.io.IOException; 
> //import java.net.URI; 
> import org.eclipse.emf.common.util.URI; 
> import java.util.Collections; 
> //import org.eclipse.emf.*; 
> import org.eclipse.emf.ecore.resource.*; 
> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; 
> import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; 
> import org.eclipse.emf.ecore.EAttribute; 
> import org.eclipse.emf.ecore.EClass; 
> import org.eclipse.emf.ecore.EPackage; 
> import org.eclipse.emf.ecore.EReference; 
> 
> /** 
> * 
> * @author mereditk 
> */ 
> public class Main { 
>       /** Creates a new instance of Main */ 
>    public Main() { 
>    } 
>       /** 
>     * @param args the command line arguments 
>     */ 
>    public static void main(String[] args) { 
>       // Create a resource set. 
>    ResourceSet resourceSet = new ResourceSetImpl(); 
> 
>    // Register the default resource factory -- only needed for  
> stand-alone! 
>     
>  resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( 
>    Resource.Factory.Registry.DEFAULT_EXTENSION, new  
> XMIResourceFactoryImpl()); 
> 
>    // Register the package -- only needed for stand-alone! 
>    //LibraryPackage libraryPackage = LibraryPackage.eINSTANCE; 
> 
>    // Get the URI of the model file. 
>    //URI fileURI = URI.createFileURI(new File("c:/documents and  
> settings/mereditk/desktop/jfacc.xmi").getAbsolutePath()); 
>    //URI fileURI = URI.createFileURI(new  
> File("e:/tif/KevinMeredith/Samples/xmi/UPDM  
> Example.xmi").getAbsolutePath()); 
>    URI fileURI = URI.createFileURI(new File("C:/Documents and  
> Settings/mereditk/Desktop/abc2.xmi").getAbsolutePath()); 
>    // Demand load the resource for this file. 
>     Resource resource = resourceSet.getResource(fileURI, true);     
>                  // Print the contents of the resource to System.out. 
>        try 
>        { 
>          resource.save(System.out, Collections.EMPTY_MAP); 
>        } 
>        catch (IOException e) {} 
>    } 
>    } 
> 
> Thanks! 
> Kevin 
>
 |  
 |  
  |  
| Re: Import XMI [message #88687 is a reply to message #88536] | 
Mon, 09 July 2007 11:54   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Hi Kevin, 
 
I'm not sure if you had a look at the migration guide as Ed suggested? 
There is some sample code there to load models ( look toward the end of the 
document ). 
It shows how to set up registration of extensions and packages. 
 
You should be able to add an entry to registerExtensions() to do something 
like ... 
extensionFactoryMap.put(XMI2UMLResource.FILE_EXTENSION, 
XMI2UMLResource.Factory.INSTANCE). 
 
Have you tried that?   Let me know if that works.   If you are still having 
issues, please post a sample xmi model and I'll give it a try. 
 
- James. 
 
 
"Ed Merks" <merks@ca.ibm.com> wrote in message 
news:f6m098$ivr$1@build.eclipse.org... 
> Kevin, 
> 
> I'm not expert at how to use UML2, but I assume you'd use 
> XMI2UMLResource.Factory.INSTANCE  in place of "new 
> XMIResourceFactoryImpl()".  There might be other setup things you need 
> to do, so best to look for documentation or wait until Kenn or James 
> provides more details. 
> 
> 
> Kevin M wrote: 
> > Mr. Merks, how would XMI2UMLResource.Factory.INSTANCE be registered 
> > with respect to this code? 
> > 
> > Should the XMIResource class be used? Please give a code snippet. 
> > /* 
> > * Main.java 
> > * 
> > * Created on July 5, 2007, 3:37 PM 
> > * 
> > * To change this template, choose Tools | Template Manager 
> > * and open the template in the editor. 
> > */ 
> > 
> > package loadxmi; 
> > import java.io.File; 
> > import java.io.IOException; 
> > //import java.net.URI; 
> > import org.eclipse.emf.common.util.URI; 
> > import java.util.Collections; 
> > //import org.eclipse.emf.*; 
> > import org.eclipse.emf.ecore.resource.*; 
> > import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; 
> > import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; 
> > import org.eclipse.emf.ecore.EAttribute; 
> > import org.eclipse.emf.ecore.EClass; 
> > import org.eclipse.emf.ecore.EPackage; 
> > import org.eclipse.emf.ecore.EReference; 
> > 
> > /** 
> > * 
> > * @author mereditk 
> > */ 
> > public class Main { 
> >       /** Creates a new instance of Main */ 
> >    public Main() { 
> >    } 
> >       /** 
> >     * @param args the command line arguments 
> >     */ 
> >    public static void main(String[] args) { 
> >       // Create a resource set. 
> >    ResourceSet resourceSet = new ResourceSetImpl(); 
> > 
> >    // Register the default resource factory -- only needed for 
> > stand-alone! 
> > 
> >  resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( 
> >    Resource.Factory.Registry.DEFAULT_EXTENSION, new 
> > XMIResourceFactoryImpl()); 
> > 
> >    // Register the package -- only needed for stand-alone! 
> >    //LibraryPackage libraryPackage = LibraryPackage.eINSTANCE; 
> > 
> >    // Get the URI of the model file. 
> >    //URI fileURI = URI.createFileURI(new File("c:/documents and 
> > settings/mereditk/desktop/jfacc.xmi").getAbsolutePath()); 
> >    //URI fileURI = URI.createFileURI(new 
> > File("e:/tif/KevinMeredith/Samples/xmi/UPDM 
> > Example.xmi").getAbsolutePath()); 
> >    URI fileURI = URI.createFileURI(new File("C:/Documents and 
> > Settings/mereditk/Desktop/abc2.xmi").getAbsolutePath()); 
> >    // Demand load the resource for this file. 
> >     Resource resource = resourceSet.getResource(fileURI, true); 
> >                  // Print the contents of the resource to System.out. 
> >        try 
> >        { 
> >          resource.save(System.out, Collections.EMPTY_MAP); 
> >        } 
> >        catch (IOException e) {} 
> >    } 
> >    } 
> > 
> > Thanks! 
> > Kevin 
> >
 |  
 |  
  |  
| Re: Import XMI [message #608662 is a reply to message #88448] | 
Fri, 06 July 2007 11:07   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Kevin, 
 
Please use the UML2 newsgroup for questions about UML.  I've added it to  
the "to" list of the reply, so there's no need to repost the question.   
I'm pretty sure they have migration documentation that describes how to  
do this, so be sure to check out what's available:   
http://wiki.eclipse.org/index.php/MDT-UML2 
 
 
 
Kevin M wrote: 
> I would like to import XMI to Eclipse, specifically RSA, however this  
> error appears when attempting to load it via Java code. 
> 
> Package with uri 'http://schema.omg.org/spec/UML/2.1.1' not found 
> 
> I believe that the project being created via Java is a Java project,  
> not the desired UML project. 
> 
> Please help me to specify that my Java code will specify that a UML  
> model is to be created. 
> 
> Here's my code: 
> 
> /* 
> * Main.java 
> * 
> * Created on July 5, 2007, 3:37 PM 
> * 
> * To change this template, choose Tools | Template Manager 
> * and open the template in the editor. 
> */ 
> 
> package loadxmi; 
> import java.io.File; 
> import java.io.IOException; 
> //import java.net.URI; 
> import org.eclipse.emf.common.util.URI; 
> import java.util.Collections; 
> //import org.eclipse.emf.*; 
> import org.eclipse.emf.ecore.resource.*; 
> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; 
> import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; 
> import org.eclipse.emf.ecore.EAttribute; 
> import org.eclipse.emf.ecore.EClass; 
> import org.eclipse.emf.ecore.EPackage; 
> import org.eclipse.emf.ecore.EReference; 
> 
> /** 
> * 
> * @author mereditk 
> */ 
> public class Main { 
>       /** Creates a new instance of Main */ 
>    public Main() { 
>    } 
>       /** 
>     * @param args the command line arguments 
>     */ 
>    public static void main(String[] args) { 
>       // Create a resource set. 
>    ResourceSet resourceSet = new ResourceSetImpl(); 
> 
>    // Register the default resource factory -- only needed for  
> stand-alone! 
>     
>  resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( 
>    Resource.Factory.Registry.DEFAULT_EXTENSION, new  
> XMIResourceFactoryImpl()); 
> 
>    // Register the package -- only needed for stand-alone! 
>    //LibraryPackage libraryPackage = LibraryPackage.eINSTANCE; 
> 
>    // Get the URI of the model file. 
>    //URI fileURI = URI.createFileURI(new File("c:/documents and  
> settings/mereditk/desktop/jfacc.xmi").getAbsolutePath()); 
>    //URI fileURI = URI.createFileURI(new  
> File("e:/tif/KevinMeredith/Samples/xmi/UPDM  
> Example.xmi").getAbsolutePath()); 
>    URI fileURI = URI.createFileURI(new File("C:/Documents and  
> Settings/mereditk/Desktop/abc2.xmi").getAbsolutePath()); 
>    // Demand load the resource for this file. 
>     Resource resource = resourceSet.getResource(fileURI, true);     
>                  // Print the contents of the resource to System.out. 
>        try 
>        { 
>          resource.save(System.out, Collections.EMPTY_MAP); 
>        } 
>        catch (IOException e) {} 
>    } 
>    } 
>
 |  
 |  
  |  
| Re: Import XMI [message #608663 is a reply to message #88464] | 
Fri, 06 July 2007 11:13   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Originally posted by: kevin.m.meredith.lmco.com 
 
Mr. Merks, 
 
I appreciate your swift replies, however I do not understand how the act  
of importing an XMI file to Eclipse/Rational Software Architect does not  
fall under Eclipse Modeling Framework. 
 
Obviously your knowledge of Eclipse exceeds mine. Do you understand that  
I'm attempting to import an XMI file to RSA using Java code? One recurring  
error that I've encountered is, "Package with uri  
'http://schema.omg.org/spec/UML/2.1.1' not found." I respectfully state so  
because I am attempting a very simple task, so I hope that you're not  
misinterpreting my simple objective and convoluting it. 
 
I know that the XMI file can be imported to RSA, since I just did so  
manually in RSA after I created a UML project, then used the Import  
command for an XMI file. 
 
Please help me to rephrase my question in the UML forum so that I can be  
fully helped. 
 
I continue to appreciate your help! 
 
Thanks, 
Kevin
 |  
 |  
  |  
| Re: Import XMI [message #608664 is a reply to message #88479] | 
Fri, 06 July 2007 11:30   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Kevin, 
 
It seemed pretty clear you were trying to read an instance of a UML2  
model given the package not found error involving the UML namespace. In  
general, to read an XMI file you need an Ecore model for the type of  
data in the file.    I suspect you should be registering  
XMI2UMLResource.Factory.INSTANCE... 
 
 
Kevin M wrote: 
> Mr. Merks, 
> 
> I appreciate your swift replies, however I do not understand how the  
> act of importing an XMI file to Eclipse/Rational Software Architect  
> does not fall under Eclipse Modeling Framework. 
> 
> Obviously your knowledge of Eclipse exceeds mine. Do you understand  
> that I'm attempting to import an XMI file to RSA using Java code? One  
> recurring error that I've encountered is, "Package with uri  
> 'http://schema.omg.org/spec/UML/2.1.1' not found." I respectfully  
> state so because I am attempting a very simple task, so I hope that  
> you're not misinterpreting my simple objective and convoluting it. 
> 
> I know that the XMI file can be imported to RSA, since I just did so  
> manually in RSA after I created a UML project, then used the Import  
> command for an XMI file. 
> 
> Please help me to rephrase my question in the UML forum so that I can  
> be fully helped. 
> 
> I continue to appreciate your help! 
> 
> Thanks, 
> Kevin 
>
 |  
 |  
  |  
| Re: Import XMI [message #608666 is a reply to message #88494] | 
Fri, 06 July 2007 13:52   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Originally posted by: kevin.m.meredith.lmco.com 
 
Mr. Merks, how would XMI2UMLResource.Factory.INSTANCE be registered with  
respect to this code? 
 
Should the XMIResource class be used? Please give a code snippet.  
 
/* 
 * Main.java 
 * 
 * Created on July 5, 2007, 3:37 PM 
 * 
 * To change this template, choose Tools | Template Manager 
 * and open the template in the editor. 
 */ 
 
package loadxmi; 
import java.io.File; 
import java.io.IOException; 
//import java.net.URI; 
import org.eclipse.emf.common.util.URI; 
import java.util.Collections; 
//import org.eclipse.emf.*; 
import org.eclipse.emf.ecore.resource.*; 
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; 
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; 
import org.eclipse.emf.ecore.EAttribute; 
import org.eclipse.emf.ecore.EClass; 
import org.eclipse.emf.ecore.EPackage; 
import org.eclipse.emf.ecore.EReference; 
 
/** 
 * 
 * @author mereditk 
 */ 
public class Main { 
     
    /** Creates a new instance of Main */ 
    public Main() { 
    } 
     
    /** 
     * @param args the command line arguments 
     */ 
    public static void main(String[] args) { 
     
    // Create a resource set. 
    ResourceSet resourceSet = new ResourceSetImpl(); 
 
    // Register the default resource factory -- only needed for  
stand-alone! 
     
 resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( 
    Resource.Factory.Registry.DEFAULT_EXTENSION, new  
XMIResourceFactoryImpl()); 
 
    // Register the package -- only needed for stand-alone! 
    //LibraryPackage libraryPackage = LibraryPackage.eINSTANCE; 
 
    // Get the URI of the model file. 
    //URI fileURI = URI.createFileURI(new File("c:/documents and  
settings/mereditk/desktop/jfacc.xmi").getAbsolutePath()); 
    //URI fileURI = URI.createFileURI(new  
File("e:/tif/KevinMeredith/Samples/xmi/UPDM  
Example.xmi").getAbsolutePath()); 
    URI fileURI = URI.createFileURI(new File("C:/Documents and  
Settings/mereditk/Desktop/abc2.xmi").getAbsolutePath()); 
    // Demand load the resource for this file. 
     Resource resource = resourceSet.getResource(fileURI, true);     
            
	   // Print the contents of the resource to System.out. 
	   try 
	   { 
	     resource.save(System.out, Collections.EMPTY_MAP); 
	   } 
	   catch (IOException e) {} 
    } 
     
} 
 
Thanks! 
Kevin
 |  
 |  
  |  
| Re: Import XMI [message #608667 is a reply to message #88521] | 
Fri, 06 July 2007 14:05   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Kevin, 
 
I'm not expert at how to use UML2, but I assume you'd use  
XMI2UMLResource.Factory.INSTANCE  in place of "new  
XMIResourceFactoryImpl()".  There might be other setup things you need  
to do, so best to look for documentation or wait until Kenn or James  
provides more details. 
 
 
Kevin M wrote: 
> Mr. Merks, how would XMI2UMLResource.Factory.INSTANCE be registered  
> with respect to this code? 
> 
> Should the XMIResource class be used? Please give a code snippet. 
> /* 
> * Main.java 
> * 
> * Created on July 5, 2007, 3:37 PM 
> * 
> * To change this template, choose Tools | Template Manager 
> * and open the template in the editor. 
> */ 
> 
> package loadxmi; 
> import java.io.File; 
> import java.io.IOException; 
> //import java.net.URI; 
> import org.eclipse.emf.common.util.URI; 
> import java.util.Collections; 
> //import org.eclipse.emf.*; 
> import org.eclipse.emf.ecore.resource.*; 
> import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; 
> import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; 
> import org.eclipse.emf.ecore.EAttribute; 
> import org.eclipse.emf.ecore.EClass; 
> import org.eclipse.emf.ecore.EPackage; 
> import org.eclipse.emf.ecore.EReference; 
> 
> /** 
> * 
> * @author mereditk 
> */ 
> public class Main { 
>       /** Creates a new instance of Main */ 
>    public Main() { 
>    } 
>       /** 
>     * @param args the command line arguments 
>     */ 
>    public static void main(String[] args) { 
>       // Create a resource set. 
>    ResourceSet resourceSet = new ResourceSetImpl(); 
> 
>    // Register the default resource factory -- only needed for  
> stand-alone! 
>     
>  resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( 
>    Resource.Factory.Registry.DEFAULT_EXTENSION, new  
> XMIResourceFactoryImpl()); 
> 
>    // Register the package -- only needed for stand-alone! 
>    //LibraryPackage libraryPackage = LibraryPackage.eINSTANCE; 
> 
>    // Get the URI of the model file. 
>    //URI fileURI = URI.createFileURI(new File("c:/documents and  
> settings/mereditk/desktop/jfacc.xmi").getAbsolutePath()); 
>    //URI fileURI = URI.createFileURI(new  
> File("e:/tif/KevinMeredith/Samples/xmi/UPDM  
> Example.xmi").getAbsolutePath()); 
>    URI fileURI = URI.createFileURI(new File("C:/Documents and  
> Settings/mereditk/Desktop/abc2.xmi").getAbsolutePath()); 
>    // Demand load the resource for this file. 
>     Resource resource = resourceSet.getResource(fileURI, true);     
>                  // Print the contents of the resource to System.out. 
>        try 
>        { 
>          resource.save(System.out, Collections.EMPTY_MAP); 
>        } 
>        catch (IOException e) {} 
>    } 
>    } 
> 
> Thanks! 
> Kevin 
>
 |  
 |  
  |  
| Re: Import XMI [message #608677 is a reply to message #88536] | 
Mon, 09 July 2007 11:54   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Hi Kevin, 
 
I'm not sure if you had a look at the migration guide as Ed suggested? 
There is some sample code there to load models ( look toward the end of the 
document ). 
It shows how to set up registration of extensions and packages. 
 
You should be able to add an entry to registerExtensions() to do something 
like ... 
extensionFactoryMap.put(XMI2UMLResource.FILE_EXTENSION, 
XMI2UMLResource.Factory.INSTANCE). 
 
Have you tried that?   Let me know if that works.   If you are still having 
issues, please post a sample xmi model and I'll give it a try. 
 
- James. 
 
 
"Ed Merks" <merks@ca.ibm.com> wrote in message 
news:f6m098$ivr$1@build.eclipse.org... 
> Kevin, 
> 
> I'm not expert at how to use UML2, but I assume you'd use 
> XMI2UMLResource.Factory.INSTANCE  in place of "new 
> XMIResourceFactoryImpl()".  There might be other setup things you need 
> to do, so best to look for documentation or wait until Kenn or James 
> provides more details. 
> 
> 
> Kevin M wrote: 
> > Mr. Merks, how would XMI2UMLResource.Factory.INSTANCE be registered 
> > with respect to this code? 
> > 
> > Should the XMIResource class be used? Please give a code snippet. 
> > /* 
> > * Main.java 
> > * 
> > * Created on July 5, 2007, 3:37 PM 
> > * 
> > * To change this template, choose Tools | Template Manager 
> > * and open the template in the editor. 
> > */ 
> > 
> > package loadxmi; 
> > import java.io.File; 
> > import java.io.IOException; 
> > //import java.net.URI; 
> > import org.eclipse.emf.common.util.URI; 
> > import java.util.Collections; 
> > //import org.eclipse.emf.*; 
> > import org.eclipse.emf.ecore.resource.*; 
> > import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; 
> > import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; 
> > import org.eclipse.emf.ecore.EAttribute; 
> > import org.eclipse.emf.ecore.EClass; 
> > import org.eclipse.emf.ecore.EPackage; 
> > import org.eclipse.emf.ecore.EReference; 
> > 
> > /** 
> > * 
> > * @author mereditk 
> > */ 
> > public class Main { 
> >       /** Creates a new instance of Main */ 
> >    public Main() { 
> >    } 
> >       /** 
> >     * @param args the command line arguments 
> >     */ 
> >    public static void main(String[] args) { 
> >       // Create a resource set. 
> >    ResourceSet resourceSet = new ResourceSetImpl(); 
> > 
> >    // Register the default resource factory -- only needed for 
> > stand-alone! 
> > 
> >  resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( 
> >    Resource.Factory.Registry.DEFAULT_EXTENSION, new 
> > XMIResourceFactoryImpl()); 
> > 
> >    // Register the package -- only needed for stand-alone! 
> >    //LibraryPackage libraryPackage = LibraryPackage.eINSTANCE; 
> > 
> >    // Get the URI of the model file. 
> >    //URI fileURI = URI.createFileURI(new File("c:/documents and 
> > settings/mereditk/desktop/jfacc.xmi").getAbsolutePath()); 
> >    //URI fileURI = URI.createFileURI(new 
> > File("e:/tif/KevinMeredith/Samples/xmi/UPDM 
> > Example.xmi").getAbsolutePath()); 
> >    URI fileURI = URI.createFileURI(new File("C:/Documents and 
> > Settings/mereditk/Desktop/abc2.xmi").getAbsolutePath()); 
> >    // Demand load the resource for this file. 
> >     Resource resource = resourceSet.getResource(fileURI, true); 
> >                  // Print the contents of the resource to System.out. 
> >        try 
> >        { 
> >          resource.save(System.out, Collections.EMPTY_MAP); 
> >        } 
> >        catch (IOException e) {} 
> >    } 
> >    } 
> > 
> > Thanks! 
> > Kevin 
> >
 |  
 |  
  |   
Goto Forum:
 
 Current Time: Tue Nov 04 09:43:50 EST 2025 
 Powered by  FUDForum. Page generated in 0.07970 seconds  
 |