| Why EObject NOT Concrete Type? [message #791695] |
Mon, 06 February 2012 01:26  |
Eclipse User |
|
|
|
HI, I created an EMF model base on a schema without namespace. There are
two complex types one name 'foo' and the other is 'bar', Element
contains an attribute 'id' whose tpe is 'xsd:ID'. Element contains an
attribute 'foo' whose type is 'xsd:IDREF' and an ecore annotation
'ecore:reference='foo'.
In generated Ecore model, Bar's attribute 'foo' contains the following
annotations.
source ...
reference...
kind='attribute'
name='foo'
namespace='##targetNamespace'
It seems OK until now, but in generated class files. Field foo of class
Bar doesn't match my assumption.
interface Bar extend EObject{
public void setFoo(EObject xxx);
public EObject getFoo();
}
Why? Did I miss some important settings?
Thanks for you help!
|
|
|
|
| Re: Why EObject NOT Concrete Type? [message #791722 is a reply to message #791711] |
Mon, 06 February 2012 02:15  |
Eclipse User |
|
|
|
Thank for your so quick reply. I found What's wrong, it's my fault.
Foo and Bar are schema elements. Complex type definition was enclosed by
element so the outer complex type can't reference it. It's about visible
scope.
for example.
<xs:element name="foo">
//Here, Element foo has an anonymous complex type, but it's not visible
to bar
<xs:complexType>
<xs:attribute type="xs:ID"/>
</xs:complexType>
</xs>
<xs:element name="bar">
<xs:complexType>
<xs:attribute name="foo" type="xs:IDREF" ecore:reference="???"/>
</xs:complexType>
So I move foo's type outer, and let's be a global complex type, then
bar's type can see it.
<xs:complexType name="fooType">
....
</xs>
<xs:element="foo" type="fooType"/>
<xs:element name="bar">
<xs:complexType>
<xs:attribute name="foo" type="xs:IDREF" ecore:reference="fooType"/>
</xs:complexType>
Whatever, I really appreciate Ed's help. I'm full of confidence to study
EMF well when you are on the group.
On 02/06/2012 02:54 PM, Ed Merks wrote:
> David,
>
> Comments below.
>
> On 06/02/2012 7:26 AM, David Chan wrote:
>> HI, I created an EMF model base on a schema without namespace. There
>> are two complex types one name 'foo' and the other is 'bar', Element
>> contains an attribute 'id' whose tpe is 'xsd:ID'. Element contains an
>> attribute 'foo' whose type is 'xsd:IDREF' and an ecore annotation
>> 'ecore:reference='foo'.
> Should this be something more like "prefix:foo"? Keep in mind that the
> value of the annotation must be a QName that resolves the same way as
> when you use it to specify the type of the element in the schema itself.
>>
>> In generated Ecore model, Bar's attribute 'foo' contains the following
>> annotations.
>>
>> source ...
>> reference...
>> kind='attribute'
>> name='foo'
>> namespace='##targetNamespace'
>>
>> It seems OK until now, but in generated class files. Field foo of
>> class Bar doesn't match my assumption.
>>
>> interface Bar extend EObject{
>> public void setFoo(EObject xxx);
>> public EObject getFoo();
>> }
> So EMF didn't resolve the QName...
>>
>> Why? Did I miss some important settings?
> Probably you didn't use an appropriately qualified QName for the complex
> type.
>>
>> Thanks for you help!
|
|
|
Powered by
FUDForum. Page generated in 0.04189 seconds