|
Re: Design question: using ecore model during reflective processing [message #398407 is a reply to message #398406] |
Tue, 07 February 2006 20:05 |
Ed Merks 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. 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.<br>
<blockquote>
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>
<xsd:simpleTy pe name="corporationRID">
<br>
<xsd:restriction base="xsd:string">
<br>
<xsd:pattern value="C\w+"/>
<br>
</xsd:restriction>
<br>
</xsd:simpleT ype>
<br>
<br>
which is transformed into ECore as:
<br>
<br>
<eClassifiers xsi:type="ecore:EDataType" name="CorporationRID"
instanceClassName="java.lang.String">
<br>
<eAnnotations
source=<a class="moz-txt-link-rfc2396E" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">"http:///org/eclipse/emf/ecore/util/ExtendedMetaData"</a>>
<br>
<details key="name" value="corporationRID"/>
<br>
<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>/>
<br>
<details key="pattern" value="C\w+"/>
<br>
</eAnnotations>
<br>
</eClassifiers>
<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 <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.
<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/
|
|
|
Powered by
FUDForum. Page generated in 0.02026 seconds