Acessing elements from a list [message #46022] |
Wed, 21 May 2008 10:04  |
Eclipse User |
|
|
|
Originally posted by: wickers.jonathan.gmail.com
Hello,
I created a meta model extending ecore to add attributes to eClass. One
of my attribute is a list extending eStructuralFeature.
I created my plugin using EMF, and it worked well, and then, created my
model.
My problem is how to get my datas in the list ? How can I iterate on
this list ?
I tried this, but without any succes :
<c:iterate select "$currentClass/MappedAttribute" var=currentElem">
<c:get select "$currentElem/@hashcodeList" />
</c:iterate>
Thanks for help
Regards,
Jonathan
|
|
|
|
|
Re: Acessing elements from a list [message #46625 is a reply to message #46343] |
Thu, 29 May 2008 13:24  |
Eclipse User |
|
|
|
Jonathan:
I'm glad I misunderstood. This is definitely easier...
Let's assume $myEClass points to your MyEClass instance your described here:
> <eClassifiers xsi:type="MyEClass" name="Capability"
> dbTableName="capability" equalsAttributesList="//Capability/id
> //Capability/name">
So, $myEClass/@name would return 'Capability' and $myEClass/@dbTableName
would return 'capability'
But, equalsAttributeList is a manifestation of an EReference, so
$myEClass/@equalsAttributesList WOULD NOT return anything.
Instead, the list is referenced as if 'equalsAttributesList' were XML child
elements $myEClass/equalsAttributesList, with each element being an entry in
the list. Typically, you'd write JET code like this:
<c:iterate select="$myEClass/equalsAttributesList" var="ea">
<%-- do something with $ea --%>
</c:iterate>
This is a case were looking at the XMI saved by EMF can be misleading. JET
is not reading the XMI! It is looking at in-memory EObjects and their
corresponding EClass's. If a feature of the EObject is delcared as an
EAttribute, you access it with @. If it is an EReference, you access it like
a 'child'.
Hope this helps.
And, your English is excellent :-)
Paul
|
|
|
Powered by
FUDForum. Page generated in 0.03177 seconds