Acessing elements from a list [message #46022] |
Wed, 21 May 2008 14: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 #46343 is a reply to message #46145] |
Thu, 22 May 2008 14:58 |
Eclipse User |
|
|
|
Originally posted by: wickers.jonathan.gmail.com
Paul Elder a écrit :
> Jonathan:
>
> I think I'll need more information. Here's what I think I understand:
>
> 1) You have an EClass MyEClass which extends EClass
> 2) You have an EClass MyEStructuralFeature which extends EStructuralFeature
> 3) In MyEClass there is an EReference feature [0..*] of type
> MyEStructuralFeature. (I'll call this feature 'foo').
>
> Am I right so far?
I'm sorry, I'm not very good in English, I'll try to explain myself
better. Actually, my problem is that MyEclass has a EReference feature
[0..*] (and not a MyEStructuralFeature), and this is this list of
EReference feature which I need to get values.
>
> But then I start to get (really) confused (which goes with the territory
> when building meta-meta models).
>
> Assuming $c is a MyEClass instance, then JET will have no idea what to do
> with the '$c/foo' or '$c/@foo' . The XPath engine has an assumption that
> EStructuralFeatures are either EReferences or EAttributes. It is completely
> undefined what would happen with a third kind of EStructuralFeature.
Ok, thanks for the tip :)
>
> One last question? What code goes EMF generate for your new kind of feature?
>
> Paul
I'm not sure to understand what you want to say. EMF generate an Ecore
model which I use to create plug-in. I export this plug-in to ecplise to
be able to create models based on my meta model.
This is an extract from my model :
<eClassifiers xsi:type="MyEClass" name="Capability"
dbTableName="capability" equalsAttributesList="//Capability/id
//Capability/name">
The equalsAttributesList is the result of the EReference feature in
MyEClass.
I hope I've been clear this time.
Thanks for your help Paul.
Regards,
Jonathan
(I think I should listened my teacher with more attention during english
classes ;))
|
|
|
Re: Acessing elements from a list [message #46625 is a reply to message #46343] |
Thu, 29 May 2008 17:24 |
Paul Elder Messages: 849 Registered: July 2009 |
Senior Member |
|
|
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.06213 seconds