Repeating elements and list tags

You can store the values of repeating elements in a tag, either as a single value or as a list. Tags that contain lists of values are referred to as list tags. The values stored list tags can be reported in the test output.

Enabling tags to store a list of values

By default, a tag can hold only a single value. To enable it to store a list of values from repeating elements, do the following steps:
  1. Right-click an element that is marked as repeating.
  2. In the context menu, select Contents > Edit. The Store page is displayed.
  3. Select the Append to list of values check box.

    By default, the check box is not selected, which means each new value assigned to the tag replaces the previous one. If the option is selected and the tag has a default value, the initial assignment replaces the default value. Subsequent assignments from the same message cause additional values to be added to the tag as members of a list.

Populating and creating messages from list tags

To populate list tags, use either the Iterate Test Data action or the Lookup Test Data action. To get one row at a time, plus the other rows that are grouped with it to provide values for repeating elements, use the Iterate Test Data action. Set the Group data by column field in the Iterate Test Data action to the column to be used to group the rows together. This column must have the same value for all rows in one group, and a different value for different groups. For example, the id column in the sample data shown in Using repeating and optional elements repeats even when the additional child where value is null option is used. The Iterate Test Data action populates the list tags with one group (including the values of its repeating elements) at a time.

If you want more control over what you are looking up at one time or do not want to iterate over multiple groups, then use the Lookup Test Data action. You can optionally specify lookup values to filter the data and only retrieve values from rows where the specified columns contain the specified values. The Lookup Test Data action populates the list tags with all the results that match the lookup values.

You can mark repeating elements by using the context menu. You configure them the same way for messages that use an XSD as for plain XML or JSON. The only difference however is that the XSD contains information on which elements can repeat. When you select null when you should have selected duplicated values and vice versa results in failures.

Contents of a list tag are shown in the following form in reports:
{value1, value2, ... valuen}

The value that is returned from a tag depends on the context. When constructing messages that have repeating elements, list tags control the number of local repeated elements in the message. At any given point, only a single value from the list is substituted. In some test actions, such as Log or SQL Query, you can extract a specific value from a list tag by using the %%tag[index]%% notation. The values within the list are stored by using a zero index. For example, to extract the first value in the list, use %%tag[0]%%; to extract the third value, use %%tag[2]%%. If the selected tag does not contain a list, an error results. You can use another tag as the index, but do not enclose it with double percent signs; %%tag[%%indexTag%%]%% creates an error condition.