|
Re: Traversing all resources from XMI-file [message #1058620 is a reply to message #1058598] |
Tue, 14 May 2013 14:45 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
Peter,
Comments below.
On 14/05/2013 4:17 PM, Peter Johnsen wrote:
> Hi,
>
> I wonder whether someone could please help on a small issue.
>
> I have an Ecore model consisting of three classes: A, B and C. A
> references B (non-containment, whereas B references C (containment).
> When I load an XMI-model of the Ecore model I'm not able to access the
> objects of B and C.
How so?
> When I create the XMI-model starting with A, the a B object is
> correctly referenced in the editor(by loading resource and selecting
> the B object). I use .getAllContents() on the resource acquired by
> using resourceSet.getResource( "a.xmi" ).
Don't use a relative URI to load a resource; relative paths within the
resource will not resolve correctly. Use an absolute URI such as
platform:/resource/project/file.extension or file:/c:/path/file.xtension.
> I can access the A object, but not the other objects.
> EcoreUtil.resolveAll() did not give me a complete list, but I may not
> access the resources in the proper way. Also, if I make a model with B
> as the root class, I can "access" C objects in the code.
Also, Resource.getAllContents will only visit the contained objects of
that one resource, not objects contained in other resources. You can
use ResourceSet.getAllContents to visit all resources and all the
objects contained by those resources.
>
> Any tips?
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
|
|
|
|
|
|
Re: Traversing all resources from XMI-file [message #1068163 is a reply to message #1068161] |
Fri, 12 July 2013 13:31 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
It sounds like the serialization doesn't conform to the model, but since
I don't know the model and I can't see the serialization, there's not
much else I can say. Note that even when loading throws an exception,
the resource will still be populated to the extent that was possible, so
another call to resourceSet.getResource(<uri>, false) will yield the
resource and you can traverse starting with resource.getContents().
On 12/07/2013 3:26 PM, bim boh wrote:
> @Ed,
>
> Yes I do have ecore model.
>
> Also after you suggested I grabbed the book on EMF and tried to use
> the load functionality.
>
> At the moment I am stuck with this.
>
> Caused by: org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature
> 'reports' not found. (file:/C:/Eclipse/report.ecm, 3, 49).
>
> Thanks
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03126 seconds