Register XMI without ECORE source [message #854459] |
Mon, 23 April 2012 21:12  |
Eclipse User |
|
|
|
Hi, everyone.
I've been resolving a lot of issues here, and now I'm half way:
- after discovering a Java project by MoDisco Java Discoverer, how could I load the resultant XMI model in some XMIResource and navigate? I did so with an Ecore file.
What if I only have the XMI model?
ResourceSet resourceSet = new ResourceSetImpl(); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put
(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl()); resourceSet.getPackageRegistry().put(MyMModelPackage.eNS_URI,MyMModelPackage.eINSTANCE);
File file = new File("C:\\Users\\USER\\workspace\\mmodels\\MyMModel.ecore");
//System.out.println(file);
URI uri = URI.createFileURI(file.getAbsolutePath());
//System.out.println(uri);
Resource resource = resourceSet.getResource(uri, true);
The above code works fine, but without the Ecore file, I can't figure it out.
By the way, I got the code from MyMModel.ecore-->MyMModel.genmodel->generate test code->*tests folders; thanks to this forum.
Thank you.
|
|
|
Re: Register XMI without ECORE source [message #854692 is a reply to message #854459] |
Tue, 24 April 2012 02:50   |
Eclipse User |
|
|
|
On 24/04/2012 3:12 AM, Juan Castel wrote:
> Hi, everyone.
>
> I've been resolving a lot of issues here, and now I'm half way:
>
> - after discovering a Java project by MoDisco Java Discoverer, how
> could I load the resultant XMI model in some XMIResource and navigate?
> I did so with an Ecore file.
>
> What if I only have the XMI model?
>
>
> ResourceSet resourceSet = new ResourceSetImpl();
> resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put
> (Resource.Factory.Registry.DEFAULT_EXTENSION, new
> XMIResourceFactoryImpl());
> resourceSet.getPackageRegistry().put(MyMModelPackage.eNS_URI,MyMModelPackage.eINSTANCE);
> File file = new
> File("C:\\Users\\USER\\workspace\\mmodels\\MyMModel.ecore");
You registrations are for reading instances of the generated model. Why
do you also need to read the original model into a resource? I'd expect
you to be reading instances at this point.
> //System.out.println(file);
> URI uri = URI.createFileURI(file.getAbsolutePath());
> //System.out.println(uri);
> Resource resource = resourceSet.getResource(uri, true);
>
> The above code works fine, but without the Ecore file, I can't figure
> it out.
>
> By the way, I got the code from
> MyMModel.ecore-->MyMModel.genmodel->generate test code->*tests
> folders; thanks to this forum.
>
> Thank you.
|
|
|
|
Re: Register XMI without ECORE source [message #1856476 is a reply to message #855721] |
Mon, 12 December 2022 13:59  |
Eclipse User |
|
|
|
Hello,"
I have the same issue that you use to have. I have my XMI file and I need to load it and navigate but I have the same error "Package with uri '*' not found."
On every post I see people saying that I should register the package but I don't have the ecore model I just have the xmi file in a standalone java app.
I was wondering if you solved this problem ? Because it seems that nobody knows how to load an XMI model file in a standalone java app.
Thanks.
|
|
|
Powered by
FUDForum. Page generated in 0.04206 seconds