defining model scope for XMI loader [message #1782751] |
Wed, 28 February 2018 18:26  |
Eclipse User |
|
|
|
Hello Experts,
I am looking for a way to define model scope to a folder and load all the xmi files which are part of it in a resourceset.
Also during loading I encountered that proxy objects were not resolved as in XMI references were defined relative to a folder (which will be the model scope)
Example:
<student name="st2">
<address
href="Address.xmi#/"/>
</student>
Based on the above problem I realized that there should be a custom implementation for resolving proxies based on the model scope.
In case anyone of you have encountered similar use case and solved it by defining the custom proxy resolution mechanism and specifying folder scope. Please share the info regarding this.
Thanks a lot !!
|
|
|
Re: defining model scope for XMI loader [message #1782757 is a reply to message #1782751] |
Thu, 01 March 2018 00:58   |
Eclipse User |
|
|
|
There is no such thing as a Model Scope. Relative references are resolved against the URI used to load the resource containing those references. So if you're having problems, most likely you didn't load the resource with an absolute URI. I.e., if this resource is in the workspace say in /project/folder/Foo.xmi, you should use platform:/resource/project/folder/Foo.xmi to load it and then the relative URI will resolve to platform:/resource/project/folder/Address.xmi, i.e., in the same folder as the referencing resource. If you're loading from the file system use URI.createFileURI(new File(...).getAbsolutePath()) to create the URI you use to load the resource. In general, you should always use an absolute URI to load a resource, i.e., platform:/..., file:/..., http://...
|
|
|
Re: defining model scope for XMI loader [message #1782775 is a reply to message #1782757] |
Thu, 01 March 2018 04:57  |
Eclipse User |
|
|
|
Thanks a lot for your quick response Ed !!
As specified by you, I used URI.createFileURI(new File(...).getAbsolutePath()) and the proxies were resolved.
Resource resource1 = resourceSet.getResource( URI.createFileURI(getAbsolutePath("./model/Address.xmi" )),true);
Resource resource2 = resourceSet.getResource(URI.createFileURI(getAbsolutePath("./model/School1_with_cross_document_references.xmi")),true );
EcoreUtil.resolveAll(resourceSet);
|
|
|
Powered by
FUDForum. Page generated in 0.48145 seconds