Skip to main content

If Tag Reference


This article defines and If Tags and Else Tags.


Tag: iftag: <wr:if ... > 


The If Tag requires a Boolean statement to work. It uses the evaluation of True or False to print or not print the content between the If Tag and EndIf Tag. If Tags can be nested. 



This statement is used like a test  - like whether a node contains a value or not, whether the value is higher than $1000.00, or whether the value starts with the letter 'A'. Additionally, you can use the If Tag to change the formatting of the content included between the tag.


  • If the statement evaluates to True, Windward will print whatever content (Tags or text) is present between the If Tag and its corresponding EndIf Tag. 
  • If the statement evaluates to False, Windward will not print the content between the If and EndIf Tags
    • When you want to switch between 2 options, use an Else tag. This way, if the statement evaluates as False, the content between the Else Tag and EndIf Tag will be printed instead. There is no need to include any select statement in the Else Tag. (If you need this approach with more than 2 options, take a look at the Switch and Case Tags



A report designer might use an If Tag to display information about past-due invoices in red, while information about invoices that are not past due is displayed in black. (e.g. IF DueDate >= 90 Days ‘Red’; IF DueDate < 90 Days ‘Black’.)


Else Tags are used to instruct AutoTag what to do when the condition defined in an If Tag is not met. Else Tags can only be used in conjunction with an If Tags, however, the use of Else Tags is optional. In other words, you can have an If Tag without an Else Tag, but you cannot have an Else Tag without an If Tag.

If Tag Notes and Tips 

  • Learn how to use Windward Symbols in your If Tag.
  • When you want a specific Tag to display something when some conditions are met, you will need to use an Out Tag with an IF Function as part of the select, or use Conditional Formatting.

    If you want to evaluate two conditions, then you need to Add a New Rule rather than incorporating it into the first condition box.
  • When creating the condition syntax, you need to precede with a = and use brackets eg. =(${cvs.STATUS}='-1') You can’t select the STATUS tag, which means you’ve got to be very careful when typing it in.
  • Before changing a conditional format, may be easiest to remove it completely and create it from scratch rather than trying to edit an existing conditional format.



  • select - required. 
    • If the "select" is evaluated as a Select (SQL, XPath, etc.) and not an Evaluate, then the node will first be tested for existence. If it does not exist it will return false. This is the default setting, but can be forced by prepending the select with a ! character.
    • If it does exist and if the node returns a boolean value, it will return that value. Reading the value is forced by prepending a ' character.
    • If you're evaluating a condition, set your condition to evaluate by prepending a = character to the statement (i.e. "=1<2" would evaluate the condition 1 < 2).  Otherwise it will return true for a non-empty node, and will use the notEmpty value if it is an empty node.


  • Delete Row – The ‘deleteRow’ attribute was introduced in v14.
    • Boolean: true(default), false
    • If the <if> tag evaluates to false, everything to the corresponding </if> is skipped and the processing continues from what follows the </if>. If it happens that the </if> is residing inside a table's row, deleteRow is true, and the row is empty (all cells comprising the row are empty), that row will be removed from the table. This allows to eliminate the empty rows in the output.


  • notEmpty - optional (only used if this is a select passed to the data source). The node must exist and must not be empty. In the If Tag you can set the notEmpty property to true or false. This property is only used for a SQL select that returns null or an XPath select that returns a zero length string. For the case of returning a node that exists but is empty:
    • notEmpty = true - the If Tag will return false because the node must not be empty to return true.
    • notEmpty = false - the If Tag will return true because the node exists and you are not requiring it be non-empty.


Note: There is no test= anymore. It’s always select= and Windward determines if it’s a select or an evaluate (test) based on syntax or the !/= at the start to override.


Valid variables

  • boolean (the text true or false - no quotes)
  • long
  • double
  • string - strings must be in quotes. You may include \" inside a string, but no other escape sequences.
  • null - a special marker indicating that a data value does not exist. It can be used with comparison operators == and !=.


forEach Row Test

A forEach loop can iterate over several rows of data at once (see the forEach tag for details on this). Inside the loop row [0] always exists but the additional rows may not exist in the last iteration of the loop.

For example, if the forEach is iterating over 7 rows of data and has step=’3’ then the first two times through the loop all 3 rows exist but the last time only the first row exists.


Note: rows access is 0-based. So the first row is [0] and the second row is [1]. The number inside the [] is the offset from the start and the first row is the start of the rows.


To test if a row exists, use the following construct. Note that this is a test=, not a select=.

<wr:forEach ="./name" var=”items” step=”3”>

<wr:if test=”${@items[1]}”>

Second row exists



The @items[1] is the context for row [1] in the forEach loop. By definition this If will always be true for each time through the loop except the last time. Also, all other tags will return nothing if they are for a row that does not exist, so in many cases you do not need to use this If.

All row access, aside from this use in If, uses items[1] while this uses @items[1]. The @ sign tells the system to check existence (a true/false value) instead of access the row’s data.

XML Usage​

<wr:if select="./name">

... other text ...


... other text ...


The <wr:else/> is optional, and in that case everything is skipped if the node does not exist.


Click here to download the XML sample.

SQL Usage​

<wr:if select=″select * from ORDER_ITEM where ORDER_ID = ${orderNum}″>

The results are checked to determine if any rows were returned. The statement is true if one or more rows were returned. If no rows were returned, the statement is false.




<wr:if select=″select REBATE_INFO from ORDER_ITEM where ORDER_ID = ${orderNum}″ isEmpty=″false″>

If you use the isEmpty attribute, the field in the first column of the first row is evaluated, regardless of how many rows are returned. The statement is true if this field contains any value other than a NULL or empty string. The statement is false if the field contains a NULL or an empty string.


Click here to download the SQL sample.



Suppressing Blank Lines

Suppressing Blank Lines When a Field Exists But is Empty:


To suppress blank lines, be sure your Tags are each on a separate line, with no blanks or tabs before or after the tags. For example, you might have several address lines and wish to suppress any blank fields, so that a blank line doesn’t appear in the address. You'll need to make adjustments to the notEmpty property in the Tag Editor.  Compare these examples:


Example of no tabs or spaces, one tag per paragraph – blank lines successfully suppressed:

<wr:if select=’/order/customer/address/@city’ notEmpty=’true’>

<out select=’/order/customer/address/@city’>



Example of two tags per paragraph – blank lines occur:

<wr:if select=’/order/customer/address/@city’ notEmpty=’true’><out select=’/order/customer/address/@city’></wr:if>


Example of tabs or spaces around tags – blank lines occur:

{TAB} <wr:if select=’/order/customer/address/@city’ notEmpty=’true’><=:/order/customer/address/@city>

{TAB} </wr:if>


When using select vs. test attributeFor <wr:if select="./name"> ... </wr:if>, Windward Reports performs an If on the dataset. It looks for the existence of the node identified by the select and is true if the node exists and false if it doesn't exist. If the attribute notEmpty="true" is set, the node must exist and must have data in it. A single space counts as data.


For <wr:if test="${stat.index}>1"> ... </wr:if>, Windward Reports performs a boolean evaluation on the test attribute. In this case it is not hitting the data source. However, the use of ${name.item} type fields in the boolean expression allows the evaluation to be performed against var fields from forEach and query tags and varStatus fields from forEach tags.

Example: Select Attribute

<wr:if select="./name" notEmpty=”true”>

... other text ...


... other text ...


Example: Test Attribute

<wr:if test="${stat.first}">

... other text ...


... other text ...


which will include the template between the if and the else if the referenced node exists, and will include the text between the else and the if end tag if it does not.