Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community Forumsc:iterate and inheritance in a model
https://www.eclipse.org/forums/index.php/mv/msg/9170/28183/#msg_28183
I'm wondering if it's possible to loop through two different classes in a
EMF model if one inherits the other. Let's say I have the two following
classes in my diagram:
Apple(name, color) <---- SpecialApple (specialAttribute)
SpecialApple inherits the name and color from the Apple class.
Now if I want to iterate through all the apples to print their names for
example in a JET2 transformation I can do two loops. One goes through all my
Apples, the other through the SpecialApples.
We can see here that the two loops are nearly the same so I was wondering
weather it's possible to merge them into only one loop just for a matter of
clarity of the code
Thanks, Tex.]]>Tex Twil2007-07-24T10:07:20-00:00Re: c:iterate and inheritance in a model
https://www.eclipse.org/forums/index.php/mv/msg/9170/28373/#msg_28373
From you examples, it appears that SpecialApple and Apple are in different
collections/features of $currTree. If they are then you could try the
following:
But, if Apple and SpecialApple instances are added to the same feature, say
allApples, you merely have to write:
<c:iterate select="$currTree/allApples" var="currApple">
<%-- To distinguish SpecialApple for Apple --%>
<c:if test="$currApple[self::SpecialApple]">
.... stuff only for SpecialApple. similarly, self::Apple identifies only
Apple instances (not SpecialApple)
</c:if>
</c:iterate>
Paul
"Tex Twil" <chaljan@hotmail.com> wrote in message
news:f84j0v$it6$1@build.eclipse.org...
> Hi,
> I'm wondering if it's possible to loop through two different classes in a
> EMF model if one inherits the other. Let's say I have the two following
> classes in my diagram:
> Apple(name, color) <---- SpecialApple (specialAttribute)
>
> SpecialApple inherits the name and color from the Apple class.
>
> Now if I want to iterate through all the apples to print their names for
> example in a JET2 transformation I can do two loops. One goes through all
> my Apples, the other through the SpecialApples.
>
> <c:iterate select="$currTree/apples" var="currApple">
> ....
> </c:iterate>
> <c:iterate select="$currTree/specialApples" var="currApple">
> ....
> </c:iterate>
>
> We can see here that the two loops are nearly the same so I was wondering
> weather it's possible to merge them into only one loop just for a matter
> of clarity of the code
>
> Thanks, Tex.]]>Paul Elder2007-07-25T12:55:08-00:00Re: c:iterate and inheritance in a model
https://www.eclipse.org/forums/index.php/mv/msg/9170/28996/#msg_28996
the first possibility works, thank you.
regards,
Tex
"Paul Elder" <pelder@ca.ibm.com> a écrit dans le message de
news:f87h8l$ucv$1@build.eclipse.org...
> Tex:
>
> From you examples, it appears that SpecialApple and Apple are in different
> collections/features of $currTree. If they are then you could try the
> following:
>
> <c:iterate select="$currTree/apples | $currTree/specialApples"
> var="currApple">
> </c:iterate>
>
> But, if Apple and SpecialApple instances are added to the same feature,
> say allApples, you merely have to write:
>
> <c:iterate select="$currTree/allApples" var="currApple">
> <%-- To distinguish SpecialApple for Apple --%>
> <c:if test="$currApple[self::SpecialApple]">
> ... stuff only for SpecialApple. similarly, self::Apple identifies only
> Apple instances (not SpecialApple)
> </c:if>
> </c:iterate>
>
> Paul
>
> "Tex Twil" <chaljan@hotmail.com> wrote in message
> news:f84j0v$it6$1@build.eclipse.org...
>> Hi,
>> I'm wondering if it's possible to loop through two different classes in a
>> EMF model if one inherits the other. Let's say I have the two following
>> classes in my diagram:
>> Apple(name, color) <---- SpecialApple (specialAttribute)
>>
>> SpecialApple inherits the name and color from the Apple class.
>>
>> Now if I want to iterate through all the apples to print their names for
>> example in a JET2 transformation I can do two loops. One goes through all
>> my Apples, the other through the SpecialApples.
>>
>> <c:iterate select="$currTree/apples" var="currApple">
>> ....
>> </c:iterate>
>> <c:iterate select="$currTree/specialApples" var="currApple">
>> ....
>> </c:iterate>
>>
>> We can see here that the two loops are nearly the same so I was wondering
>> weather it's possible to merge them into only one loop just for a matter
>> of clarity of the code
>>
>> Thanks, Tex.
>
>]]>Tex Twil2007-07-26T07:55:56-00:00