Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Does ID property have to be unique in the whole Resource?
Does ID property have to be unique in the whole Resource? [message #423102] Tue, 23 September 2008 12:27 Go to next message
koloale is currently offline koloaleFriend
Messages: 41
Registered: July 2009
Member
I have two classes in my Ecore model, A and B, both have id property,
third C class has reference to A (non-containment). When I assign the
same ids A and B objects, and save them in one XML resource along with
C, the operation executed successfully.
Result xml contains something like:

<?xml version="1.0" encoding="UTF-8"?>
<root>
<a id=1/>
<b id=1/>
<c a="#1"/>
</root>

This xml is what I expect. But when loading this xml I get error: "Value
is not legal", cased by ClassCastException.

Is any ability to correct this issue? Is it correct that loading with id
s only works when all ids are unique(in my example a and b have to be
different)? Why couldn't XMLResource deduce correct type of referenced
object based on eReference of containing object?

Thanks in advance,
Alexey
Re: Does ID property have to be unique in the whole Resource? [message #423103 is a reply to message #423102] Tue, 23 September 2008 13:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Yes. That is the XML semantics, as well as EMOF.

Cheers,

Christian


koloale wrote:
> I have two classes in my Ecore model, A and B, both have id property,
> third C class has reference to A (non-containment). When I assign the
> same ids A and B objects, and save them in one XML resource along with
> C, the operation executed successfully.
> Result xml contains something like:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <root>
> <a id=1/>
> <b id=1/>
> <c a="#1"/>
> </root>
>
> This xml is what I expect. But when loading this xml I get error: "Value
> is not legal", cased by ClassCastException.
>
> Is any ability to correct this issue? Is it correct that loading with id
> s only works when all ids are unique(in my example a and b have to be
> different)? Why couldn't XMLResource deduce correct type of referenced
> object based on eReference of containing object?
>
> Thanks in advance,
> Alexey
Re: Does ID property have to be unique in the whole Resource? [message #423106 is a reply to message #423103] Tue, 23 September 2008 13:30 Go to previous messageGo to next message
koloale is currently offline koloaleFriend
Messages: 41
Registered: July 2009
Member
Of course it XML semantics if id property of xsd:idref type. But when I
generate Ecore model from Java classes, my id property has no connection
with idref schema type. So is it feasible to deduce type from eReference
and search object with given id among only objects wthis correspomding
of reference type? Besides, all information for that is available.

Christian W. Damus пишет:
> Yes. That is the XML semantics, as well as EMOF.
>
> Cheers,
>
> Christian
>
>
> koloale wrote:
>> I have two classes in my Ecore model, A and B, both have id property,
>> third C class has reference to A (non-containment). When I assign the
>> same ids A and B objects, and save them in one XML resource along with
>> C, the operation executed successfully.
>> Result xml contains something like:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <root>
>> <a id=1/>
>> <b id=1/>
>> <c a="#1"/>
>> </root>
>>
>> This xml is what I expect. But when loading this xml I get error:
>> "Value is not legal", cased by ClassCastException.
>>
>> Is any ability to correct this issue? Is it correct that loading with
>> id s only works when all ids are unique(in my example a and b have to
>> be different)? Why couldn't XMLResource deduce correct type of
>> referenced object based on eReference of containing object?
>>
>> Thanks in advance,
>> Alexey
Re: Does ID property have to be unique in the whole Resource? [message #423115 is a reply to message #423106] Tue, 23 September 2008 14:18 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30803
Registered: July 2009
Senior Member
Alexey,

That's potentially feasible, but not directly supported by EMF.
Consider that you might have a base class X with two derived classes Y
and Z each of which has a different ID feature. Then you might have a
feature x of type X that refers to Y and Z by ID. In this case, you'd
not know if it was a Y or a Z so even Y and Z better have unique IDs.
So I wouldn't suggest trying to go down your path.


koloale wrote:
> Of course it XML semantics if id property of xsd:idref type. But when
> I generate Ecore model from Java classes, my id property has no
> connection with idref schema type. So is it feasible to deduce type
> from eReference and search object with given id among only objects
> wthis correspomding of reference type? Besides, all information for
> that is available.
>
> Christian W. Damus пишет:
>> Yes. That is the XML semantics, as well as EMOF.
>>
>> Cheers,
>>
>> Christian
>>
>>
>> koloale wrote:
>>> I have two classes in my Ecore model, A and B, both have id
>>> property, third C class has reference to A (non-containment). When
>>> I assign the same ids A and B objects, and save them in one XML
>>> resource along with C, the operation executed successfully.
>>> Result xml contains something like:
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <root>
>>> <a id=1/>
>>> <b id=1/>
>>> <c a="#1"/>
>>> </root>
>>>
>>> This xml is what I expect. But when loading this xml I get error:
>>> "Value is not legal", cased by ClassCastException.
>>>
>>> Is any ability to correct this issue? Is it correct that loading
>>> with id s only works when all ids are unique(in my example a and b
>>> have to be different)? Why couldn't XMLResource deduce correct type
>>> of referenced object based on eReference of containing object?
>>>
>>> Thanks in advance,
>>> Alexey
Previous Topic:[Query] Status of the EMF Query Component
Next Topic:getting additional resources via customized reflective editor
Goto Forum:
  


Current Time: Sat Jan 18 09:43:34 GMT 2020

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

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

Back to the top