Iteration over Node Sets

Description For each node in path, evaluate the template. The loop variable, var, is optional, and if used becomes both an XPath variable and the Java loop variable.
Simple Form
#for var "path"#
template
#end#
XML Form
<for var="var" path="path">
template
</for>
Translation to Java
NodeList x = context.evalNodeSet("path");
for (int j; j<x.getLength(); ++j) {
    Node var = (Node) x.item(j);
    context.push(var, j+1, x.getLength());
    template-translated-to-java
    context.pop();
}
Example Template Dict.template

public class Dict {

	String[] words = {
	#for "//word"#
		"#"."#",
	#end#
	};
}

Example Spec words.xml

<?xml version="1.0"?>
<words>
  <word>hill</word>
  <word>fetch</word>
  <word>pail</word>
  <word>water</word>
  <word>up</word>
  <word>down</word>
  <word>crown</word>
</words>
Generated Output Dict.java

public class Dict {

	String[] words = {
		"hill",
		"fetch",
		"pail",
		"water",
		"up",
		"down",
		"crown",
	};
}