Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Using fully qualified Ids for non containment cross-documents references
Using fully qualified Ids for non containment cross-documents references [message #755950] Thu, 10 November 2011 09:57 Go to next message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
The default behavior for persisting non containment cross-documents references is something similar as (taken from the example):
<orders href="supplier3.xml#//@orders.0"/>


Suppose now that we want to reference a specific item in that order, we would end up with something like this (if orders would contain items):
<item href="supplier3.xml#//@orders.0/@items.4"/>


Using index is in my case not really good since the referenced document can change independently which makes this approach not really robust (if an item or an order would be removed, my second document becomes totally inconsistent).

So, to fix this problem I could make add an EAttribute to the Item EClass with the ID property set to true, and then this ID would be used instead of an index (don't remember if the syntax is 100% correct):
<item href="supplier3.xml#//MySpecificItem"/>


However, in my case the Items are not unique within a resource, they are unique within an order. So instead of having only the Id of my item, I would like to have a fully qualified Id (which means that orders need also to have an ID property):
<item href="supplier3.xml#//MyOrder.MySpecificItem"/>


I guess this is not feasible by default with EMF but is there a way to end up with something like that ? The reason is to have files more robust as they are now.


Re: Using fully qualified Ids for non containment cross-documents references [message #756003 is a reply to message #755950] Thu, 10 November 2011 12:59 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Cedric,

Comments below.


On 10/11/2011 10:57 AM, Cedric Moonen wrote:
> The default behavior for persisting non containment cross-documents
> references is something similar as (taken from the example):
> <orders href="supplier3.xml#//@orders.0"/>
Yes, a fragment path with indices for multi-valued references.
>
> Suppose now that we want to reference a specific item in that order,
> we would end up with something like this (if orders would contain items):
> <item href="supplier3.xml#//@orders.0/@items.4"/>
>
> Using index is in my case not really good since the referenced
> document can change independently which makes this approach not really
> robust (if an item or an order would be removed, my second document
> becomes totally inconsistent).
Indeed.
>
> So, to fix this problem I could make add an EAttribute to the Item
> EClass with the ID property set to true, and then this ID would be
> used instead of an index (don't remember if the syntax is 100% correct):
> <item href="supplier3.xml#//MySpecificItem"/>
Just <resource-URI>#<id> will result.
>
> However, in my case the Items are not unique within a resource, they
> are unique within an order.
You should specify it as the eKey for the containment references. Then
you'll get @feature[key='value']...
> So instead of having only the Id of my item, I would like to have a
> fully qualified Id (which means that orders need also to have an ID
> property):
> <item href="supplier3.xml#//MyOrder.MySpecificItem"/>
>
> I guess this is not feasible by default with EMF but is there a way to
> end up with something like that ? The reason is to have files more
> robust as they are now.
It's also possible to specialize the segments in an arbitrary way via
eURIFragmentSegment/eObjectForURIFragmentSegment in the implementation
class. See EModelElementImpl for an example.
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Using fully qualified Ids for non containment cross-documents references [message #756018 is a reply to message #756003] Thu, 10 November 2011 13:48 Go to previous message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
Ed, thanks for the reply. Specifying the name as the eKeys solves indeed my problem. I wasn't aware of that option in EMF.
Previous Topic:Printing EMF EObject properties
Next Topic:EMF Validation - which direction
Goto Forum:
  


Current Time: Thu Apr 18 02:35:09 GMT 2024

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

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

Back to the top