|
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 |
Ed Merks 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/
|
|
|
|
Powered by
FUDForum. Page generated in 0.01723 seconds