Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Don't Get It - anyURI and ecore:reference
Don't Get It - anyURI and ecore:reference [message #1002145] Fri, 18 January 2013 02:54 Go to next message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
I am using a publicly available IEEE schema for project. I have extended this schema by simply importing one of my own schemas into it.

The resulting genmodel, when I create a new EMF Project, has two main packages and ecore models generated. One ecore for each of the major schemas.

In my schema, I am trying to make a reference to something in the larger enclosing schema (the IEEE one). So I'm trying to use the in my own schema:

<xs:complexType name="controlType">
<xs:sequence>
<xs:element name="registerFieldRef" type="xs:anyURI" ecore:reference="fieldType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>

fieldType is a ComplexType defined in another schema file (the larger public schema that "surrounds" my schema. Like this: <xs:complexType name="fieldType">

I have typed at least 50 different things in the ecore:reference="" quotes and I can't get anything generated out of EMF that doesn't create a reference to a generic EObject. I want a reference to FieldType (the Class that EMF correctly creates for the complexType "fieldType).

I have searched and found people trying to figure out how to get a reference to a generic EObject and not a specific type, but I'm trying to do the opposite - I want a specific type reference.


I don't get it. Does ecore:reference need to refer to a Java class or something within the schema? The package containing the EMF class I want to reference has not been created yet by the Model generator, so I don't understand how I could make a reference to that.
Re: Don't Get It - anyURI and ecore:reference [message #1002246 is a reply to message #1002145] Fri, 18 January 2013 08:39 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Brandon,

Comments below.

On 18/01/2013 3:54 AM, Brandon Lewis wrote:
> I am using a publicly available IEEE schema for project. I have
> extended this schema by simply importing one of my own schemas into it.
>
> The resulting genmodel, when I create a new EMF Project, has two main
> packages and ecore models generated. One ecore for each of the major
> schemas.
One for each namespace...
>
> In my schema, I am trying to make a reference to something in the
> larger enclosing schema (the IEEE one). So I'm trying to use the in
> my own schema:
>
> <xs:complexType name="controlType">
> <xs:sequence>
> <xs:element name="registerFieldRef" type="xs:anyURI"
> ecore:reference="fieldType" minOccurs="0" maxOccurs="unbounded"/>
> </xs:sequence>
> </xs:complexType>
>
> fieldType is a ComplexType defined in another schema file (the larger
> public schema that "surrounds" my schema. Like this: <xs:complexType
> name="fieldType">
>
> I have typed at least 50 different things in the ecore:reference=""
> quotes and I can't get anything generated out of EMF that doesn't
> create a reference to a generic EObject. I want a reference to
> FieldType (the Class that EMF correctly creates for the complexType
> "fieldType).
You have to use exactly what you's put in the type="...". If what
you're trying doesn't work there (i.e., the schema validates it as
unresolved), it won't work in the ecore:reference either.
>
> I have searched and found people trying to figure out how to get a
> reference to a generic EObject and not a specific type, but I'm trying
> to do the opposite - I want a specific type reference.
>
>
> I don't get it. Does ecore:reference need to refer to a Java class or
> something within the schema?
It needs to use a schema reference that would resolve if it were used as
an actual type in the schema. So you need an import and it needs to be
a QName that would resolve properly, so be sure you have an xmlns
declaration for that imported schema's namespace and be sure to use it
as part of you QName reference.
> The package containing the EMF class I want to reference has not been
> created yet by the Model generator, so I don't understand how I could
> make a reference to that.
It needs to be a schema reference...


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Don't Get It - anyURI and ecore:reference [message #1005550 is a reply to message #1002246] Sat, 26 January 2013 13:41 Go to previous message
Brandon Lewis is currently offline Brandon LewisFriend
Messages: 268
Registered: May 2012
Senior Member
Thanks Ed! That answer perfectly cleared it up for me.

I was able to debug my problem by putting a type=".." reference in my schema and using my schema validator to tell me what I was doing wrong. Once I figured that out, I moved that over to the ecore:reference="..." part and it worked.

All good now. I appreciate your help.

> I have typed at least 50 different things in the ecore:reference=""
> quotes and I can't get anything generated out of EMF that doesn't
> create a reference to a generic EObject. I want a reference to
> FieldType (the Class that EMF correctly creates for the complexType
> "fieldType).
You have to use exactly what you's put in the type="...". If what
you're trying doesn't work there (i.e., the schema validates it as
unresolved), it won't work in the ecore:reference either.
>
> I have searched and found people trying to figure out how to get a
> reference to a generic EObject and not a specific type, but I'm trying
> to do the opposite - I want a specific type reference.
>
>
> I don't get it. Does ecore:reference need to refer to a Java class or
> something within the schema?
It needs to use a schema reference that would resolve if it were used as
an actual type in the schema.
Previous Topic:[CDO] Updating CDO references in XMI Resource
Next Topic:[CDO] 4.1 transaction rollback after a commit
Goto Forum:
  


Current Time: Thu Apr 18 03:19:41 GMT 2024

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

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

Back to the top