Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

This answer is pertaining to the second question posted using the second paragraph. you can stop an expression value from getting printed using a chain operator (->). For ex:

<<counterInc()->"">>

See the example for 'throwError (Object o)' in the official online help documentation here: http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.xpand.doc%2Fhelp%2Fch04s02.html

You may also find the 'Counter extensions' section helpful for counter operations in Xpand

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top