Skip to main content



      Home
Home » Archived » M2M (model-to-model transformation) » [QVTO] Help for explaining a mapping behavior.
[QVTO] Help for explaining a mapping behavior. [message #482235] Tue, 25 August 2009 15:08 Go to next message
Eclipse UserFriend
Hi all,

I'm trying to understand what's happening when executing a mapping.
The piece of code I'm executing is the following one:

mapping siteMap::Node::toDivMainNavigation(): xhtml::DivType{
init{
log('3..divMainNav..1',self.name);
log('4..divMainNav..2',inModel.nodesMainNav->size());
}
id:='mainNavigation';
ul:= object xhtml::UlType{
id:='main_navigation';

li:= inModel.nodesMainNav->map toLiNavigationLink();

};
end{
log('5..ul size..3',result.ul->size());
log('6..li size..3',result.ul->first().li->size());
}
}

The aim of the mapping is to obtain something similar to this:
<div id="mainNavigation">
<ul id="main_navigation">
<li>Item 1</li>
<li>Item 2</li>
</ul>
</div>

The mapping is executed a number of times, depending on the Nodes of the
input model. The problem is that it seems that the mapping named
toLiNavigationLink(), which is invoked by toDivMainNavigation() only is
called once, the first time that toDivMainNavigation is invoked.

An example of the output shown in the console as a consequence of the
log messages is the following one:

3..divMainNav..1, data: Leisure
4..divMainNav..2, data: 8
toLiNavigation, data: News
toLiNavigation, data: Contact
toLiNavigation, data: Teaching
toLiNavigation, data: Research
toLiNavigation, data: Publications
toLiNavigation, data: Leisure
toLiNavigation, data: News
toLiNavigation, data: Contact
5..ul size..3, data: 1
6..li size..3, data: 8
3..divMainNav..1, data: Consulting Hours
4..divMainNav..2, data: 8
5..ul size..3, data: 1
6..li size..3, data: 8
3..divMainNav..1, data: Courses
4..divMainNav..2, data: 8
5..ul size..3, data: 1
6..li size..3, data: 8


As it can be seen toLiNavigation is executed only during the first
execution of toDivMainNavigation.

My question is: Why the line of code li:= inModel.nodesMainNav->map
toLiNavigationLink(); is only executed once?

Thanks in advance and regards,
Toñi
Re: [QVTO] Help for explaining a mapping behavior. [message #482238 is a reply to message #482235] Tue, 25 August 2009 15:32 Go to previous messageGo to next message
Eclipse UserFriend
Hi Toñi ,

It's expected behavior.
For the same source given mapping is executed only only. On subsequent
calls it fetches already created result from implicit trace and return
it (see QVT Spec, Section 8.2.1.15 MappingOperation: Execution Semantics).

You might take a look at similar discussion:
http://dev.eclipse.org/mhonarc/newsLists/news.eclipse.modeli ng.m2m/msg04380.html

Regards,
Sergey

Toñi Reina Quintero wrote:
> Hi all,
>
> I'm trying to understand what's happening when executing a mapping. The
> piece of code I'm executing is the following one:
>
> mapping siteMap::Node::toDivMainNavigation(): xhtml::DivType{
> init{
> log('3..divMainNav..1',self.name);
> log('4..divMainNav..2',inModel.nodesMainNav->size());
> }
> id:='mainNavigation';
> ul:= object xhtml::UlType{
> id:='main_navigation';
>
> li:= inModel.nodesMainNav->map toLiNavigationLink();
>
> };
> end{
> log('5..ul size..3',result.ul->size());
> log('6..li size..3',result.ul->first().li->size());
> }
> }
>
> The aim of the mapping is to obtain something similar to this:
> <div id="mainNavigation">
> <ul id="main_navigation">
> <li>Item 1</li>
> <li>Item 2</li>
> </ul>
> </div>
>
> The mapping is executed a number of times, depending on the Nodes of the
> input model. The problem is that it seems that the mapping named
> toLiNavigationLink(), which is invoked by toDivMainNavigation() only is
> called once, the first time that toDivMainNavigation is invoked.
>
> An example of the output shown in the console as a consequence of the
> log messages is the following one:
>
> 3..divMainNav..1, data: Leisure
> 4..divMainNav..2, data: 8
> toLiNavigation, data: News
> toLiNavigation, data: Contact
> toLiNavigation, data: Teaching
> toLiNavigation, data: Research
> toLiNavigation, data: Publications
> toLiNavigation, data: Leisure
> toLiNavigation, data: News
> toLiNavigation, data: Contact
> 5..ul size..3, data: 1
> 6..li size..3, data: 8
> 3..divMainNav..1, data: Consulting Hours
> 4..divMainNav..2, data: 8
> 5..ul size..3, data: 1
> 6..li size..3, data: 8
> 3..divMainNav..1, data: Courses
> 4..divMainNav..2, data: 8
> 5..ul size..3, data: 1
> 6..li size..3, data: 8
>
>
> As it can be seen toLiNavigation is executed only during the first
> execution of toDivMainNavigation.
>
> My question is: Why the line of code li:= inModel.nodesMainNav->map
> toLiNavigationLink(); is only executed once?
>
> Thanks in advance and regards,
> Toñi
Re: [QVTO] Help for explaining a mapping behavior. [message #482260 is a reply to message #482238] Tue, 25 August 2009 17:31 Go to previous message
Eclipse UserFriend
Thanks, Sergey, now I understand what's happening, and thanks to the
discussion you have suggested I have fixed the problem with an explicit
constructor (that now works with my 2.0.0 release :-))

Sergey Boyko escribió:
> Hi Toñi ,
>
> It's expected behavior.
> For the same source given mapping is executed only only. On subsequent
> calls it fetches already created result from implicit trace and return
> it (see QVT Spec, Section 8.2.1.15 MappingOperation: Execution Semantics).
>
> You might take a look at similar discussion:
> http://dev.eclipse.org/mhonarc/newsLists/news.eclipse.modeli ng.m2m/msg04380.html
>
>
> Regards,
> Sergey
>
> Toñi Reina Quintero wrote:
>> Hi all,
>>
>> I'm trying to understand what's happening when executing a mapping.
>> The piece of code I'm executing is the following one:
>>
>> mapping siteMap::Node::toDivMainNavigation(): xhtml::DivType{
>> init{
>> log('3..divMainNav..1',self.name);
>> log('4..divMainNav..2',inModel.nodesMainNav->size());
>> }
>> id:='mainNavigation';
>> ul:= object xhtml::UlType{
>> id:='main_navigation';
>> li:= inModel.nodesMainNav->map toLiNavigationLink();
>> };
>> end{
>> log('5..ul size..3',result.ul->size());
>> log('6..li size..3',result.ul->first().li->size());
>> }
>> }
>>
>> The aim of the mapping is to obtain something similar to this:
>> <div id="mainNavigation">
>> <ul id="main_navigation">
>> <li>Item 1</li> <li>Item 2</li>
>> </ul>
>> </div>
>>
>> The mapping is executed a number of times, depending on the Nodes of
>> the input model. The problem is that it seems that the mapping named
>> toLiNavigationLink(), which is invoked by toDivMainNavigation() only
>> is called once, the first time that toDivMainNavigation is invoked.
>>
>> An example of the output shown in the console as a consequence of the
>> log messages is the following one:
>>
>> 3..divMainNav..1, data: Leisure
>> 4..divMainNav..2, data: 8
>> toLiNavigation, data: News
>> toLiNavigation, data: Contact
>> toLiNavigation, data: Teaching
>> toLiNavigation, data: Research
>> toLiNavigation, data: Publications
>> toLiNavigation, data: Leisure
>> toLiNavigation, data: News
>> toLiNavigation, data: Contact
>> 5..ul size..3, data: 1
>> 6..li size..3, data: 8
>> 3..divMainNav..1, data: Consulting Hours
>> 4..divMainNav..2, data: 8
>> 5..ul size..3, data: 1
>> 6..li size..3, data: 8
>> 3..divMainNav..1, data: Courses
>> 4..divMainNav..2, data: 8
>> 5..ul size..3, data: 1
>> 6..li size..3, data: 8
>>
>>
>> As it can be seen toLiNavigation is executed only during the first
>> execution of toDivMainNavigation.
>>
>> My question is: Why the line of code li:= inModel.nodesMainNav->map
>> toLiNavigationLink(); is only executed once?
>>
>> Thanks in advance and regards,
>> Toñi
Previous Topic:[QVTO] Transformation performance degradation
Next Topic:[QVTo] Compiled transformation?
Goto Forum:
  


Current Time: Sun Jul 13 19:08:31 EDT 2025

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

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

Back to the top