Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Design question: using ecore model during reflective processing
Design question: using ecore model during reflective processing [message #398406] Tue, 07 February 2006 19:15 Go to next message
Chris Tomlinson is currently offline Chris TomlinsonFriend
Messages: 25
Registered: July 2009
Junior Member
Hello,

I have a design question regarding accessing information in an ecore
model at runtime. I am working with ECore models generated from XML
Schema. As an example, I have:

<xsd:simpleType name="corporationRID">
<xsd:restriction base="xsd:string">
<xsd:pattern value="C\w+"/>
</xsd:restriction>
</xsd:simpleType>

which is transformed into ECore as:

<eClassifiers xsi:type="ecore:EDataType" name="CorporationRID"
instanceClassName="java.lang.String">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="corporationRID"/>
<details key="baseType"
value="http://www.eclipse.org/emf/2003/XMLType#string"/>
<details key="pattern" value="C\w+"/>
</eAnnotations>
</eClassifiers>

Now the problem that I have is that I want to write some generic code
that I can use with a generic editor based on the Generic Form Editor.
This code needs to instantiate an ElementSelectionListDialog that is
populated with information based on knowing that an EAttribute is filled
in the original XML Schema by an instance of the xsd:simpleType,
corporationRID (or any of many other such types).

As evidenced from the <eClassifiers/> above, the generated Java code
will use java.lang.String for the type of variables and methods that
implement attributes that have the original type CorporationRID.

So I think that the question that I'm trying to answer is:

What is the appropriate way in EMF to navigate from an EAttribute, for
example, backwards into the information in the ECore model where I can
recover information from the original XML Schema?

It seems that a manouver similar to this is needed since the generated
Java model access plugin doesn't carry enough information as far as I
can tell to allow the proposed generic code to know the semantic type of
an attribute value at runtime.

I know that org.eclipse.emf.ecore provides model access to an ECore
model and that org.eclipse.emf.codegen.ecore provides access to a
genmodel; however, it's not clear to me how best to use these tools to
do what I want.

I hope that I've described the need clearly enough that if there is a
more direct way of getting the job done then someone will be able to
point me in a profitable direction. Failing that then I'd like to know
if there are examples that I could look at that would illustrate the
dort of idioms that should be used.

Thanks very much for any help
Re: Design question: using ecore model during reflective processing [message #398407 is a reply to message #398406] Tue, 07 February 2006 20:05 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------010400050709050402060502
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Chris,

For this purpose, ExtendedMetaData is your best friend. It provides
answers to questions about the information in the original schema.
E.g., the following yields the base type of the attribute's type.

ExtendedMetaData.INSTANCE.getBaseType(eAttribute.getEAttribu teType())


Chris Tomlinson wrote:

> Hello,
>
> I have a design question regarding accessing information in an ecore
> model at runtime. I am working with ECore models generated from XML
> Schema. As an example, I have:
>
> <xsd:simpleType name="corporationRID">
> <xsd:restriction base="xsd:string">
> <xsd:pattern value="C\w+"/>
> </xsd:restriction>
> </xsd:simpleType>
>
> which is transformed into ECore as:
>
> <eClassifiers xsi:type="ecore:EDataType" name="CorporationRID"
> instanceClassName="java.lang.String">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="corporationRID"/>
> <details key="baseType"
> value="http://www.eclipse.org/emf/2003/XMLType#string"/>
> <details key="pattern" value="C\w+"/>
> </eAnnotations>
> </eClassifiers>
>
> Now the problem that I have is that I want to write some generic code
> that I can use with a generic editor based on the Generic Form Editor.
> This code needs to instantiate an ElementSelectionListDialog that is
> populated with information based on knowing that an EAttribute is
> filled in the original XML Schema by an instance of the
> xsd:simpleType, corporationRID (or any of many other such types).
>
> As evidenced from the <eClassifiers/> above, the generated Java code
> will use java.lang.String for the type of variables and methods that
> implement attributes that have the original type CorporationRID.
>
> So I think that the question that I'm trying to answer is:
>
> What is the appropriate way in EMF to navigate from an EAttribute, for
> example, backwards into the information in the ECore model where I can
> recover information from the original XML Schema?
>
> It seems that a manouver similar to this is needed since the generated
> Java model access plugin doesn't carry enough information as far as I
> can tell to allow the proposed generic code to know the semantic type
> of an attribute value at runtime.
>
> I know that org.eclipse.emf.ecore provides model access to an ECore
> model and that org.eclipse.emf.codegen.ecore provides access to a
> genmodel; however, it's not clear to me how best to use these tools to
> do what I want.
>
> I hope that I've described the need clearly enough that if there is a
> more direct way of getting the job done then someone will be able to
> point me in a profitable direction. Failing that then I'd like to know
> if there are examples that I could look at that would illustrate the
> dort of idioms that should be used.
>
> Thanks very much for any help
>
>


--------------010400050709050402060502
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Chris,<br>
<br>
For this purpose, ExtendedMetaData is your best friend.&nbsp; It provides
answers to questions about the information in the original schema.&nbsp;&nbsp;
E.g., the following yields the base type of the attribute's type.<br>
<blockquote>&nbsp;
ExtendedMetaData.INSTANCE.getBaseType(eAttribute.getEAttribu teType()) <br>
</blockquote>
<br>
Chris Tomlinson wrote:
<blockquote cite="middsark2$j7f$1@utils.eclipse.org" type="cite">Hello,
<br>
<br>
I have a design question regarding accessing information in an ecore
model at runtime. I am working with ECore models generated from XML
Schema. As an example, I have:
<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;xsd:simpleTy pe name="corporationRID"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;xsd:restriction base="xsd:string"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xsd:pattern value="C\w+"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &lt;/xsd:restriction&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/xsd:simpleT ype&gt;
<br>
<br>
which is transformed into ECore as:
<br>
<br>
&nbsp; &lt;eClassifiers xsi:type="ecore:EDataType" name="CorporationRID"
instanceClassName="java.lang.String"&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;details key="name" value="corporationRID"/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;details key="baseType"
value=<a class="moz-txt-link-rfc2396E" href="http://www.eclipse.org/emf/2003/XMLType#string">"http://www.eclipse.org/emf/2003/XMLType#string"</a>/&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;details key="pattern" value="C\w+"/&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;/eAnnotations&gt;
<br>
&nbsp; &lt;/eClassifiers&gt;
<br>
<br>
Now the problem that I have is that I want to write some generic code
that I can use with a generic editor based on the Generic Form Editor.
This code needs to instantiate an ElementSelectionListDialog that is
populated with information based on knowing that an EAttribute is
filled in the original XML Schema by an instance of the xsd:simpleType,
corporationRID (or any of many other such types).
<br>
<br>
As evidenced from the &lt;eClassifiers/&gt; above, the generated Java
code will use java.lang.String for the type of variables and methods
that implement attributes that have the original type CorporationRID.
<br>
<br>
So I think that the question that I'm trying to answer is:
<br>
<br>
What is the appropriate way in EMF to navigate from an EAttribute, for
example, backwards into the information in the ECore model where I can
recover information from the original XML Schema?
<br>
<br>
It seems that a manouver similar to this is needed since the generated
Java model access plugin doesn't carry enough information as far as I
can tell to allow the proposed generic code to know the semantic type
of an attribute value at runtime.
<br>
<br>
I know that org.eclipse.emf.ecore provides model access to an ECore
model and that org.eclipse.emf.codegen.ecore provides access to a
genmodel; however, it's not clear to me how best to use these tools to
do what I want.
<br>
<br>
I hope that I've described the need clearly enough that if there is a
more direct way of getting the job done then someone will be able to
point me in a profitable direction. Failing that then I'd like to know
if there are examples that I could look at that would illustrate the
dort of idioms that should be used.
<br>
<br>
Thanks very much for any help
<br>
<br>
<br>
</blockquote>
<br>
</body>
</html>

--------------010400050709050402060502--


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Invalid NMTOKEN value: ' ' in XSD ecore model
Next Topic:embedded string persisting with &quot;
Goto Forum:
  


Current Time: Fri Apr 19 12:57:40 GMT 2024

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

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

Back to the top