EReference on a default ID [message #431116] |
Mon, 29 June 2009 16:26 |
Eclipse User |
|
|
|
Originally posted by: guillaume.surrel.scalagent.com
Hi all,
I'm new to emf and I'm currently stuck on something.
Here is my problem :
I've made an EClass 'B' which has an EReference 'link' on an EClass 'A'.
'A' has an EAttribute 'id' with the ID attribute set to true.
The problem is that I have something like this in the resulting XML :
<A id="default">
<B link="//@A.0">
instead of
<A id="default">
<B link="default">
when the id on A is not set and has the default value. Everything is as
expected when I explicitly set the id value of class A using the
properties view.
Thank you.
|
|
|
|
Re: EReference on a default ID [message #431144 is a reply to message #431119] |
Tue, 30 June 2009 09:23 |
Eclipse User |
|
|
|
Originally posted by: guillaume.surrel.scalagent.com
Thanks Ed for the quick reply.
Ed Merks a écrit :
> Guillaume,
>
> The ID must be set to used.
I'm not sure what you mean by this. Is this about eIsSet method
returning true ? Because modifying the generated code to do it seems to
do exactly what I'm expecting.
> Are you suggesting you made "default" the
> default value for the id attribute?
Exactly.
> That's not a good idea, because if
> there is more than one 'A' they will have the same ID value, which is
> invalid, and so you'll still have to set it.
Of course, but the purpose is to save a little time when keeping default
id value.
>
> Guillaume Surrel wrote:
>> Hi all,
>>
>> I'm new to emf and I'm currently stuck on something.
>> Here is my problem :
>> I've made an EClass 'B' which has an EReference 'link' on an EClass 'A'.
>> 'A' has an EAttribute 'id' with the ID attribute set to true.
>>
>> The problem is that I have something like this in the resulting XML :
>> <A id="default">
>> <B link="//@A.0">
>> instead of
>> <A id="default">
>> <B link="default">
>> when the id on A is not set and has the default value. Everything is
>> as expected when I explicitly set the id value of class A using the
>> properties view.
>>
>>
>> Thank you.
|
|
|
|
Re: EReference on a default ID [message #431156 is a reply to message #431146] |
Tue, 30 June 2009 11:19 |
Eclipse User |
|
|
|
Originally posted by: guillaume.surrel.scalagent.com
Ed Merks a écrit :
> Yes because it's implemented like this in EcoreUtil
>
> public static String getID(EObject eObject)
> {
> EClass eClass = eObject.eClass();
> EAttribute eIDAttribute = eClass.getEIDAttribute();
> return eIDAttribute == null || !eObject.eIsSet(eIDAttribute) ?
> null : convertToString(
> eIDAttribute.getEAttributeType(),
> eObject.eGet(eIDAttribute));
> }
Ok, thanks for pointing this out.
>>> That's not a good idea, because if there is more than one 'A' they
>>> will have the same ID value, which is invalid, and so you'll still
>>> have to set it.
>> Of course, but the purpose is to save a little time when keeping
>> default id value.
> It's common for there to be only one A in the resource?
Yes, there will be more likely a very small number of A.
|
|
|
Powered by
FUDForum. Page generated in 0.03685 seconds