| Syntax 
   repeat over shelf-type? shelf-name (& shelf-type shelf-name)?
     local-declaration*
     action*
  again
 Purpose
 
 A special form of the repeataction used to process successive items on a given shelf. The actions are repeated once for each item on the shelf. References to the shelf name are interpreted as though followed by item 1 during the first iteration, by  item 2 in the second iteration, and so forth. 
 repeat overcan process the items on several shelves in parallel. The first item on each shelf is processed before the loop moves to the second item, and so on, until all items on all shelves have been processed.
 The keyword andcan be used in place of "&". In a repeat overaction, it is often useful to know whether the loop is at the first or last iteration. Two predefined switches provide this information. The switch named#firstis active only on the first iteration. The#lastswitch is active only on the last iteration. They are both active on the only iteration over a set with one member. These two switches are read-only; they can be tested in a switch test, but they cannot be explicitly activated or deactivated. Whenrepeat overloops nest, each instance has its own#firstand#lastswitches. You can also ask for the index of the current iteration by accessing the predefined counter #item. It can be used in numeric expressions or in format items that format counters. When repeat over loops nest, each instance has its own indices. repeat overcan be used to process the following:
 successive tokens from a list-valued attribute 
successive attributes of a currently open element
the current element stack  
the referents shelf
 If a repeat overaction iterates over a set of attributes or over the tokens of an attribute, or if an attribute or attribute token is identified by ausingprefix, then all text written to the#markup-parserstream will be "buffered" in the same manner until the action completes. Can you add an item to a shelf inside a repeat over loop? Yes, but only at a position greater that the size of the shelf when the loop began. The number of iterations in the loop is determined before the first iteration, and adding more items to the shelf from within the loop will not change the number of iterations being performed.
 Can you remove items from a shelf within a repeat over loop? Yes, but only items that were added within the same loop. |