Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EMF] Relative paths in .ecore files
[EMF] Relative paths in .ecore files [message #664127] Thu, 07 April 2011 14:51 Go to next message
Christian Huelsmeier is currently offline Christian HuelsmeierFriend
Messages: 12
Registered: September 2010
Junior Member
Hello,

if I use a .ecore file via Load Resource in another .ecore file and use/reference classes from the loaded resource, the paths are relative to the location of the referring file.

For example:
I have two ecore projects (project1, project2) and in each project there is one model (model1.ecore, model2.ecore). model1.ecore is a loaded resource in model2.ecore and classes from model1.ecore are referred by classes located in model2.ecore, i.e. Person (in model2.ecore) is a subclass of Entity (model1.ecore).
Modeling Person as subclass of Entity would result in this xml:

<eClassifiers xsi:type="ecore:EClass" name="Person" eSuperTypes="../../ecore.project1/model/model1.ecore#//core/Entity">
...


This will fail if I decide to move project1 to another directory so that project2 isn't in the same directory and so the relative path is broken.
Is there a possibility to generete the reference in this a format (with platform:/resource)?
<eClassifiers xsi:type="ecore:EClass" name="Person" eSuperTypes="platform:/resource/project1/model/model1.ecore#//core/Entity">
...


I uploaded an example here: http://tinyurl.com/3hd7o6s

Cheers

Christian

[Updated on: Thu, 07 April 2011 14:51]

Report message to a moderator

Re: [EMF] Relative paths in .ecore files [message #664151 is a reply to message #664127] Thu, 07 April 2011 15:41 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Christian,

Comments below.

Christian Huelsmeier wrote:
> Hello,
>
> if I use a .ecore file via Load Resource in another .ecore file and
> use/reference classes from the loaded resource, the paths are relative
> to the location of the referring file.
Indeed.
>
> For example:
> I have two ecore projects (project1, project2) and in each project
> there is one model (model1.ecore, model2.ecore). model1.ecore is a
> loaded resource in model2.ecore and classes from model1.ecore are
> referred by classes located in model2.ecore, i.e. Person (in
> model2.ecore) is a subclass of Entity (model1.ecore).
> Modeling Person as subclass of Entity would result in this xml:
>
> <eClassifiers xsi:type="ecore:EClass" name="Person"
> eSuperTypes="../../ecore.project1/model/model1.ecore#//core/Entity ">
> ..
>
> This will fail if I decide to move project1 to another directory so
> that project2 isn't in the same directory and so the relative path is
> broken.
Of course you can open it in the editor and do "Save as." And of
course if you move the referenced file the referencing files will be
broken, regardless of whether the reference is relative or absolute.
> Is there a possibility to generete the reference in this a format
> (with platform:/resource)?
>
> <eClassifiers xsi:type="ecore:EClass" name="Person"
> eSuperTypes=" platform:/resource/project1/model/model1.ecore#//core/Entity ">
>
It is possible, but it's not supported via options in the UI. One of
the primary reasons is that these relative references work even when the
resources are packaged up in the binary bundle. I.e., when the
referencing resource is loaded via platform:/plugin/.... the referenced
resource will also be loaded with a URI of that form, and all works
well. More generally, by using purely relative references we avoid
encoding any absolute knowledge about the physical location so we can
access everything via http:, file:, platform:/resource,
platform:/plugin, cvs:, or whatever, as long as we preserve the
relative/logical structure of the workspace.
> ..
>
>
> I uploaded an example here: http://tinyurl.com/3hd7o6s
>
> Cheers
>
> Christian


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [EMF] Relative paths in .ecore files [message #664202 is a reply to message #664151] Thu, 07 April 2011 19:53 Go to previous messageGo to next message
Christian Huelsmeier is currently offline Christian HuelsmeierFriend
Messages: 12
Registered: September 2010
Junior Member
Ed,

thanks for your answer.

Ed Merks wrote on Thu, 07 April 2011 11:41

It is possible, but it's not supported via options in the UI. One of
the primary reasons is that these relative references work even when the
resources are packaged up in the binary bundle. I.e., when the
referencing resource is loaded via platform:/plugin/.... the referenced
resource will also be loaded with a URI of that form, and all works
well. More generally, by using purely relative references we avoid
encoding any absolute knowledge about the physical location so we can
access everything via http:, file:, platform:/resource,
platform:/plugin, cvs:, or whatever, as long as we preserve the
relative/logical structure of the workspace.



Can you tell me how to do this? Is there a tutorial that tells me what to do to get the references in the way I want them to look like?
Maybe there are other (and/or better) solutions.
The requirement I have is that there are two (or more) projects containing .ecore files which are somehow linked together. These projects are in the same workspace, but not necessarily located in the same directory.

Christian
Re: [EMF] Relative paths in .ecore files [message #665070 is a reply to message #664202] Wed, 13 April 2011 08:03 Go to previous messageGo to next message
Christian Huelsmeier is currently offline Christian HuelsmeierFriend
Messages: 12
Registered: September 2010
Junior Member
Does anyone else have any suggestions?

Thanks in advance

Christian

Christian Huelsmeier wrote on Thu, 07 April 2011 15:53
Ed,

thanks for your answer.

Ed Merks wrote on Thu, 07 April 2011 11:41

It is possible, but it's not supported via options in the UI. One of
the primary reasons is that these relative references work even when the
resources are packaged up in the binary bundle. I.e., when the
referencing resource is loaded via platform:/plugin/.... the referenced
resource will also be loaded with a URI of that form, and all works
well. More generally, by using purely relative references we avoid
encoding any absolute knowledge about the physical location so we can
access everything via http:, file:, platform:/resource,
platform:/plugin, cvs:, or whatever, as long as we preserve the
relative/logical structure of the workspace.



Can you tell me how to do this? Is there a tutorial that tells me what to do to get the references in the way I want them to look like?
Maybe there are other (and/or better) solutions.
The requirement I have is that there are two (or more) projects containing .ecore files which are somehow linked together. These projects are in the same workspace, but not necessarily located in the same directory.

Christian

Re: [EMF] Relative paths in .ecore files [message #665195 is a reply to message #665070] Wed, 13 April 2011 15:26 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020105040804030003020604
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Christian,

This post isn't appearing in the same thread, so that doesn't help
anyone suggest much of anything...

You'd need to write your own utility to load the Ecore model and then
save it using this option with a specialized handler that produces the
URIs in the form you want.

/**
* A {@link URIHandler} value that will be used to control how
URIs are {@link URI#resolve(URI) resolved} during load
* and {@link URI#deresolve(URI) deresolved} during save.
* @see URI
* @see URIHandler
* @see XMLHelper#resolve(URI, URI)
* @see XMLHelper#deresolve(URI)
* @see URIHandlerImpl
*/
String OPTION_URI_HANDLER = "URI_HANDLER";

I expect that you'd be better off solving real problems instead of
focusing on this issue, which I think isn't really a problem in the
first place.


Christian Huelsmeier wrote:
> Does anyone else have any suggestions?
>
> Thanks in advance
>
> Christian
>
> Christian Huelsmeier wrote on Thu, 07 April 2011 15:53
>> Ed,
>>
>> thanks for your answer.
>>
>> Ed Merks wrote on Thu, 07 April 2011 11:41
>> > It is possible, but it's not supported via options in the UI. One
>> of > the primary reasons is that these relative references work even
>> when the > resources are packaged up in the binary bundle. I.e.,
>> when the > referencing resource is loaded via platform:/plugin/....
>> the referenced > resource will also be loaded with a URI of that
>> form, and all works > well. More generally, by using purely relative
>> references we avoid > encoding any absolute knowledge about the
>> physical location so we can > access everything via http:, file:,
>> platform:/resource, > platform:/plugin, cvs:, or whatever, as long as
>> we preserve the > relative/logical structure of the workspace.
>>
>>
>> Can you tell me how to do this? Is there a tutorial that tells me
>> what to do to get the references in the way I want them to look like?
>> Maybe there are other (and/or better) solutions.
>> The requirement I have is that there are two (or more) projects
>> containing .ecore files which are somehow linked together. These
>> projects are in the same workspace, but not necessarily located in
>> the same directory.
>>
>> Christian
>
>

--------------020105040804030003020604
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Christian,<br>
<br>
This post isn't appearing in the same thread, so that doesn't help
anyone suggest much of anything...<br>
<br>
You'd need to write your own utility to load the Ecore model and then
save it using this option with a specialized handler that produces the
URIs in the form you want.<br>
<blockquote><small>  /**<br>
   * A {@link URIHandler} value that will be used to control how URIs
are {@link URI#resolve(URI) resolved} during load <br>
   * and {@link URI#deresolve(URI) deresolved} during save.<br>
   * @see URI<br>
   * @see URIHandler<br>
   * @see XMLHelper#resolve(URI, URI)<br>
   * @see XMLHelper#deresolve(URI)<br>
   * @see URIHandlerImpl<br>
   */<br>
  String OPTION_URI_HANDLER = "URI_HANDLER";</small><br>
</blockquote>
I expect that you'd be better off solving real problems instead of
focusing on this issue, which I think isn't really a problem in the
first place.<br>
<br>
<br>
Christian Huelsmeier wrote:
<blockquote cite="mid:io3ku1$qgl$1@news.eclipse.org" type="cite">Does
anyone else have any suggestions?
<br>
<br>
Thanks in advance
<br>
<br>
Christian
<br>
<br>
Christian Huelsmeier wrote on Thu, 07 April 2011 15:53
<br>
<blockquote type="cite">Ed,
<br>
<br>
thanks for your answer.
<br>
<br>
Ed Merks wrote on Thu, 07 April 2011 11:41
<br>
&gt; It is possible, but it's not supported via options in the UI.  
One of &gt; the primary reasons is that these relative references work
even when the &gt; resources are packaged up in the binary bundle. 
I.e., when the &gt; referencing resource is loaded via
platform:/plugin/.... the referenced &gt; resource will also be loaded
with a URI of that form, and all works &gt; well.  More generally, by
using purely relative references we avoid &gt; encoding any absolute
knowledge about the physical location so we can &gt; access everything
via http:, file:, platform:/resource, &gt; platform:/plugin, cvs:, or
whatever, as long as we preserve the &gt; relative/logical structure of
the workspace.
<br>
<br>
<br>
Can you tell me how to do this? Is there a tutorial that tells me what
to do to get the references in the way I want them to look like?
<br>
Maybe there are other (and/or better) solutions.
<br>
The requirement I have is that there are two (or more) projects
containing .ecore files which are somehow linked together. These
projects are in the same workspace, but not necessarily located in the
same directory.
<br>
<br>
Christian
<br>
</blockquote>
<br>
<br>
</blockquote>
</body>
</html>

--------------020105040804030003020604--


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[Teneo] setting Hibernate Interceptor
Next Topic:[EMF Compare] Correctly compare non-identifiable references
Goto Forum:
  


Current Time: Fri Mar 29 15:54:27 GMT 2024

Powered by FUDForum. Page generated in 0.02919 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top