|
Re: c:iterate and inheritance in a model [message #28373 is a reply to message #28183] |
Wed, 25 July 2007 12:55 |
Paul Elder Messages: 849 Registered: July 2009 |
Senior Member |
|
|
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.
|
|
|
Re: c:iterate and inheritance in a model [message #28996 is a reply to message #28373] |
Thu, 26 July 2007 07:55 |
Tex Twil Messages: 179 Registered: July 2009 |
Senior Member |
|
|
Hello Paul,
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.
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.02978 seconds