Conditional

Description The XPath expression, path, is evaluated. If true, then template is evaluated, otherwise if an else clause is present, then template2 is evaluated.
Simple Form
#if "path"# template #fi#
#if "path"# template #else# template2 #fi#
XML Form
<if path="path"> template </if>
<if path="path"> template
	<else> template2 </else></if>
Translation to Java
if (context.evalBoolean("path")) {
	template-translated-to-Java
}
if (context.evalBoolean("path")) {
	template-translated-to-Java
} else {
	template2-translated-to-Java
}
Example Template test.template

#if "//word='up'"#up is in the list#fi#

#if "count(//word)<5"#
	less than 5 words
#else#
	5 or more words
#fi#


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 test

up is in the list
	5 or more words