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