3.4

@@BeginRepeat/@@EndRepeat

Use the @@BeginRepeat/@@EndRepeat pair when you have a dataset containing multiple nodes of the same name, and want to list the data for each node or group of nodes.

Syntax:

@@BeginRepeat(<datasource>, <GroupByCount>)

Parameters:

<datasource>

The nodes to process. Must include the entire node structure to repeat.

<GroupByCount>

How many nodes to include in a single group. <GroupByCount> is an integer and if omitted, is assumed to be 1.

For example,

@@BeginRepeat(#Classes.Class, 3)

Content

@@EndRepeat

repeats the content once if there are one to three Class nodes under Classes, twice if there are four to six Class nodes under Classes, three times if there are seven to nine Class nodes under Classes, etc.

 

You can place any content, including tokens, text, and statements (including additional @@BeginRepeat / @@EndRepeat pairs) between @@BeginRepeat and @@EndRepeat.

The @@BeginRepeat statement creates four special nodes for internal use while the repeat runs:

RepeatIndex

The node matching the data source the repeat is currently processing. For example, if datasource is Classes.Class, RepeatIndex is 1 for the first Class node, 2 for the second Class node, etc.

RepeatTotal

The total number of nodes matching the data source. For example, if datasource is Classes.Class and there are three Class nodes, RepeatTotal will be three.

RepeatLoopTotal

The number of nodes in the group being processed. For example, if GroupByCount is 3, and there are five nodes, RepeatLoopTotal for nodes 1-3 will be three, and RepeatLoopTotal for nodes 4-5 will be two (since there are only two nodes in the second group). If GroupByCount is left off, RepeatLoopTotal equals RepeatTotal, since each node is its own group.

LoopCounter

The number of groups processed, inclusive.

For example, if GroupByCount is 3, and there are five nodes matching the datasource, the LoopCounter will be 1 for the first three nodes, since they are in group 1, and 2 for the next two nodes, since they are in group 2.

 

You can reference the special XML nodes for processing using #Child.<SpecialNode> token. For example, if datasource is Classes.Class, you would use #Class.RepeatIndex, #Class.RepeatTotal, etc.

You can reference specific tokens within the repeat by appending [x] after the child portion of the datasource, where x is the number of the node in the matching set of nodes. For example, if datasource is Classes.Class, #Classes.Class[2].ClassName returns return Class Name for the second Class node in the repeat.