Else Tag

The else tag adds increased power to the if tag. By default, the if tag has a third part that is understood but not explicitly stated:

  • If the condition isn't met, do nothing.

You can change this, however. If the if tag condition is not met, you can tell the document template to do something else. To achieve this, you need to use the else tag. For example, the report could insert the text "Outside North America" for cities outside the continent.

An else tag is optional. An else tag can only be used once inside an if tag and is only valid inside an if tag. Be sure it is complete (that is, it contains the final />).

In other words, you can have an if tag without an else tag, but you can't have an else tag without an if tag.


Here's a table with an else tag:


First Name

Last Name


<forEach tag> <out tag>

<out tag>

<if tag> <out tag> <elsetag> Outside North America <endIf tag>

<endforEach tag>



There are four tags in the city column:

  • The if tag sets the condition
  • The out tag tells the report what to do if the condition is met
  • The else tag tells the report that if the condition set by the if tag isn't met, to do something else: in this case, insert the text "Outside North America"
  • The EndIf tag tells the template to stop setting a condition

Just as with the If tag, the Else tag has two parts:

  • Evaluating if a condition (set by the If tag) isn't met.
  • Determining what to do if the condition isn't met.

And here's the final report:


First Name

Last Name




Outside North America



New York



Outside North America



Outside North America