|
Re: ecore:opposite [message #411566 is a reply to message #411560] |
Mon, 30 July 2007 11:00 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Tarek,
An opposite feature must directly be a feature on the reference's type.
So if a class X has a feature y of type Y and that feature is to have an
opposite, it must be a feature x of type X in Y. So you have to define
them as you had them in the original version. But you could mark the
reference feature as ecore:transient and ecore:derived so it isn't saved
and so that it's derived from the string valued IDREF feature of the new
child type you introduced.
Tarek wrote:
> Hi:
>
> I am using Eclipse 3.2.2, EMF 2.2, and GMF 1.0.3.
>
> I have this out file like:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xmachine initial-state="Idle" model-name="Bank_Cashier">
> <state name="Idle">
> <inTransitions>T3</inTransitions>
> <outTransitions>T1</outTransitions>
> <outTransitions>T4</outTransitions>
> </state>
> <state name="serving">
> <inTransitions>T1</inTransitions>
> <outTransitions>T2</outTransitions>
> </state>
> <state name="answering">
> <inTransitions>T2</inTransitions>
> <inTransitions>T4</inTransitions>
> <outTransitions>T3</outTransitions>
> </state>
> <transition fromState="Idle" functionName="fun1" toState="serving"
> TransitionID="T1"/>
> <transition fromState="serving" functionName="fun2"
> toState="answering" TransitionID="T2"/>
> <transition fromState="answering" functionName="fun3" toState="Idle"
> TransitionID="T3"/>
> <transition fromState="Idle" functionName="fun4" toState="answering"
> TransitionID="T4"/>
> </xmachine>
>
>
> I used this xml schema to define the above part:
> for the State
>
> <xsd:complexType name="state">
> <xsd:sequence>
> <xsd:element name="inTransitions" type="xsd:IDREF"
> maxOccurs="unbounded" ecore:reference="transition"
> ecore:opposite="toState"/>
> <xsd:element name="outTransitions" type="xsd:IDREF"
> maxOccurs="unbounded" ecore:reference="transition"
> ecore:opposite="fromState"/>
> </xsd:sequence>
> <xsd:attribute name="name" type="xsd:ID"/>
> </xsd:complexType>
>
> and for the transition:
>
> <xsd:complexType name="transition">
> <xsd:attribute name="TransitionID" type="xsd:ID" use="required"/>
> <xsd:attribute name="fromState" type="xsd:IDREF"
> ecore:reference="state" ecore:opposite="outTransitions"/>
> <xsd:attribute name="functionName" type="allowed-string"/>
> <xsd:attribute name="toState" type="xsd:IDREF"
> ecore:reference="state" ecore:opposite="inTransitions"/>
> </xsd:complexType>
>
> I want to use the latest JET2 to generate Jave code and test cases
> from the output file, however, the version compatible with Eclispe
> 3.2.2 and EMF 2.2 has a bug that can not deal with elements contents
> and attrbutes togather in same file. these bugs have been fixed in the
> latest JET2 build. however, this build requires Eclipse 3.3 and EMF 2.3.
>
> Therefore, to get arround this bug, I want to modify the model output
> file by adding the attribute (transitionID) to
> inTransitions/outTransitions as following:
>
> <state name="Idle">
> <inTransitions transitionID="T3"/>
> <outTransitions transitionID="T1"/>
> <ouTransitions transitionID="T4"/>
> </state>
>
> and so on for each state.
>
> I do not want to define the inTransitions/ouTransitions as an
> attribute for the State, because this will produce the following:
>
> <state name="Idle" inTransitions="T3" outTransitions="T1 T4">
>
> the value of outTransitions="T1 T4" will be returned by JET2 as single
> string T1 T4. which I do not want.
>
> I tried to do the followig:
>
> <xsd:complexType name="state">
> <xsd:sequence>
> <xsd:element name="inTransition" type="inTransition"
> maxOccurs="unbounded"/>
> <xsd:element name="outTransition" type="outTransition"
> maxOccurs="unbounded"/>
> </xsd:sequence>
> <xsd:attribute name="name" type="xsd:ID"/>
> </xsd:complexType>
> <xsd:complexType name="inTransition">
> <xsd:attribute name="transitionID" type="xsd:IDREF"
> ecore:reference="transition" ecore:opposite="toState"/>
> </xsd:complexType>
> <xsd:complexType name="outTransition">
> <xsd:attribute name="transitionID" type="xsd:IDREF"
> ecore:reference="transition" ecore:opposite="fromState"/>
> </xsd:complexType>
>
> <xsd:complexType name="transition">
> <xsd:attribute name="transitionID" type="xsd:ID" use="required"/>
> <xsd:attribute name="fromState" type="xsd:IDREF"
> ecore:reference="outTransition" ecore:opposite="transitionID"/>
> <xsd:attribute name="functionName" type="allowed-string"/>
> <xsd:attribute name="toState" type="xsd:IDREF"
> ecore:reference="inTransition" ecore:opposite="transitionID"/>
> </xsd:complexType>
>
> But that did not work.
>
> Is it possible to do what I am looking for.
>
> Thank you very much in advance
>
> Tarek
>
>
>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Powered by
FUDForum. Page generated in 0.02936 seconds