Skip to main content



      Home
Home » Modeling » M2T (model-to-text transformation) » JET2-GMF/EMF Access Container class
JET2-GMF/EMF Access Container class [message #23884] Wed, 27 June 2007 07:02 Go to next message
Eclipse UserFriend
Hello,
Im using JET to generate some file from my GMF model instance and
everything works fine.

Now I have a question if it's possible to access a "Container" class
form the one being containted. Here's is a litte example of a simple model

ClassA <>------- ClassB ------- ClassC

This means that the ClassB is contained by the class A. The class C has
a reference to the classB. The entry point to my JET transformation is
the classC from where I can easily access the classB but I dont know how
to acceess the class A from the classB.

This is represented in the xml file of my model instance like:

<classA name="myclassA" >
<classB name="myclassB"/>
</classA>

<classC name="myclassC" refClassB="//@classesA.0/@classesB.0">
</classC>

So my question again is how can I access an attribute of a classA if I'm
itterating through the classesC.

I hope Im clear enough :)

Thanks,
Tex.
Re: JET2-GMF/EMF Access Container class [message #23925 is a reply to message #23884] Wed, 27 June 2007 07:39 Go to previous messageGo to next message
Eclipse UserFriend
Putting a reference from the classB to its container classA would be a
solution but I think it's not the best one.



Tex Twil wrote:
> Hello,
> Im using JET to generate some file from my GMF model instance and
> everything works fine.
>
> Now I have a question if it's possible to access a "Container" class
> form the one being containted. Here's is a litte example of a simple model
>
> ClassA <>------- ClassB ------- ClassC
>
> This means that the ClassB is contained by the class A. The class C has
> a reference to the classB. The entry point to my JET transformation is
> the classC from where I can easily access the classB but I dont know how
> to acceess the class A from the classB.
>
> This is represented in the xml file of my model instance like:
>
> <classA name="myclassA" >
> <classB name="myclassB"/>
> </classA>
>
> <classC name="myclassC" refClassB="//@classesA.0/@classesB.0">
> </classC>
>
> So my question again is how can I access an attribute of a classA if I'm
> itterating through the classesC.
>
> I hope Im clear enough :)
>
> Thanks,
> Tex.
Re: JET2-GMF/EMF Access Container class [message #23961 is a reply to message #23925] Wed, 27 June 2007 09:25 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vincent.lg.voila.fr

Hi Tex, maybe you can try something like that :

<c:iterate var="curClassC" select="//classC">

<c:setVariable var="curClassA"
select="//classA[classB=$curClassC/@refClassB]">
<%-- do something with $curClassA --%>

</c:iterate>

Here we iterate through all classC nodes.
the select clause in setVariable tag searches for a classA node that
contains a classB node which matches the refClassB attribute of the
current classC node. I hope what I said is clear for you. I think you can
do the trick only using XPath expression, without adding any unnecessary
references.

Hope it helps,
Vincent.
Re: JET2-GMF/EMF Access Container class [message #23999 is a reply to message #23884] Wed, 27 June 2007 09:59 Go to previous messageGo to next message
Eclipse UserFriend
Tex:

The JET XPath engine supports the parent axis:

$myB/parent::node() or $myB/parent::*

or the more cryptic, abbreviated form:

$myB/..

Paul

"Tex Twil" <chaljan@hotmail.com> wrote in message
news:f5tg4g$ukc$1@build.eclipse.org...
> Hello,
> Im using JET to generate some file from my GMF model instance and
> everything works fine.
>
> Now I have a question if it's possible to access a "Container" class form
> the one being containted. Here's is a litte example of a simple model
>
> ClassA <>------- ClassB ------- ClassC
>
> This means that the ClassB is contained by the class A. The class C has a
> reference to the classB. The entry point to my JET transformation is the
> classC from where I can easily access the classB but I dont know how to
> acceess the class A from the classB.
>
> This is represented in the xml file of my model instance like:
>
> <classA name="myclassA" >
> <classB name="myclassB"/>
> </classA>
>
> <classC name="myclassC" refClassB="//@classesA.0/@classesB.0">
> </classC>
>
> So my question again is how can I access an attribute of a classA if I'm
> itterating through the classesC.
>
> I hope Im clear enough :)
>
> Thanks,
> Tex.
Re: JET2-GMF/EMF Access Container class [message #24034 is a reply to message #23999] Wed, 27 June 2007 10:03 Go to previous message
Eclipse UserFriend
Great ! Thank you.

Regards,
Tex.

Paul Elder wrote:
> Tex:
>
> The JET XPath engine supports the parent axis:
>
> $myB/parent::node() or $myB/parent::*
>
> or the more cryptic, abbreviated form:
>
> $myB/..
>
> Paul
>
> "Tex Twil" <chaljan@hotmail.com> wrote in message
> news:f5tg4g$ukc$1@build.eclipse.org...
>> Hello,
>> Im using JET to generate some file from my GMF model instance and
>> everything works fine.
>>
>> Now I have a question if it's possible to access a "Container" class form
>> the one being containted. Here's is a litte example of a simple model
>>
>> ClassA <>------- ClassB ------- ClassC
>>
>> This means that the ClassB is contained by the class A. The class C has a
>> reference to the classB. The entry point to my JET transformation is the
>> classC from where I can easily access the classB but I dont know how to
>> acceess the class A from the classB.
>>
>> This is represented in the xml file of my model instance like:
>>
>> <classA name="myclassA" >
>> <classB name="myclassB"/>
>> </classA>
>>
>> <classC name="myclassC" refClassB="//@classesA.0/@classesB.0">
>> </classC>
>>
>> So my question again is how can I access an attribute of a classA if I'm
>> itterating through the classesC.
>>
>> I hope Im clear enough :)
>>
>> Thanks,
>> Tex.
>
>
Previous Topic:c:iterate with delimiter and formatting
Next Topic:check if a variable is defined
Goto Forum:
  


Current Time: Sat May 10 12:18:31 EDT 2025

Powered by FUDForum. Page generated in 0.03074 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top