Does ID property have to be unique in the whole Resource? [message #423102] |
Tue, 23 September 2008 08:27  |
Eclipse User |
|
|
|
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 09:10   |
Eclipse User |
|
|
|
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 09:30   |
Eclipse User |
|
|
|
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 10:18  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.09866 seconds