views:

535

answers:

1

Can i get some good tutorials on XPand.. i need to get info on commands like LET. It would better if some one could post some samples on it.

The problem i am facing is like.. i run a "for" loop and after checking some condition i need to increment a counter . but i am unable to do so. when i increment the counter, it gets printed to the output file.

Thanks in advance.

+1  A: 

There is a worked example which templates Ant scripts. The same article is republished on DZone.

More specifically, this paper presents this example on the LET operator:

<<LET packageName + "." + className AS fqn>>
  the fully qualified name is: <<fqn>>;
<<ENDLET>>

Finally, from this post on openArchitecureWare forum:

The LET statement is really simple: it creates a local constant with the specified value and a scope in which this constant is visible. This also means that the LET statement is unusable for looping behavior.

In fact, if you try to loop, you're basically solving problems in the wrong place. XPand templates are only meant for generating textual artifacts while most logic underlying the generation should be implemented in Xtensions. Xtend does not have a loop construct either but it's possible to find an alternative if you're willing to follow the functional programming-paradigm. Also, take note of the 'indexOf' method of oaw.List.

jamesh