| Syntax 
   repeat over reversed? current elements element-qualifier*
     as alias-name
   local-declaration*
   action*
  again
 Purpose
 
 A form of the repeat overaction used to "iterate over" opened elements and access information about them. The default behavior of arepeat over current elementsloop is to start with the element that was opened first and iterates "forward" to the most recently opened element, processing each open element in turn. Within a repeat over current elementsaction, the  alias-name provides a way to access the current element selected in the iteration. Anelementdefinition alone always identifies the currently opened element, and not the current item of the iteration. The element selected by the current iteration is always identified by thecurrent elementelement alias name in the head of therepeat overaction. This also works for several elements at once, because a singlerepeat overcan be applied to bothcurrent elementsandreversed current elementssimultaneously.repeat over current elementsmust define an "alias" for the opened element selected in each iteration. The formcurrent-elementfollowed by the alias name is used to identify any reference to the selected element. The repeat over reversed current elementsaction iterates over the most recently opened element and iterates "backwards" over the remainder of the currently opened elements, from the most recently opened element to the "oldest" open element (that is the one that was opened first). If there are no open elements, or the qualifier following repeat over current elements ofidentifies an open element that does not exist, therepeat overaction is not executed: it effectively identifies an empty set of opened elements. #itemis always one (1) on the first iteration, and the number of opened items on the last iteration, even when thereversedoption is used.#itemnever decrements.
 The current elements"shelf" differs from other shelves in several ways. In particular, because more than one instance of an element type can be open at one time,  more than one item ofcurrent elementscan have the same key value, andname ofis used rather thankey ofto access the name of opened elements. A repeat overaction can iterate over the set of opened elements, or a subset of them, by qualifyingcurrent elementswithof. Therepeat overaction identifies the element: either the element identified by theofqualifier followingrepeat over current elements, or, if there is no such qualifier, the currently opened element. This element is identified when therepeat overcommences. Arepeat overaction iterates over the set of opened elements consisting of the identified element and all of its ancestors. A repeat overaction that iterates over thecurrent elementsin the input processor buffers text written to the#markup-parserstream  until the end of the loop. All text written to the markup parser within arepeat over current elementsaction is "buffered": none of the text is actually passed to OmniMark's markup parser until after the end of therepeat overaction. A "%q" format item, references to attributes, and element tests are not affected by a repeat over current elementsaction. These apply to the same element within the loop as they would outside the loop. In other words, the use of "%q" in therepeat over current elementsaction does not give the name of the element selected by the current iteration, but rather that of the most recently opened element. An element alias-name can be used only as an "element-name" following the keyword current element. current elementalias-name can be used in several contexts within therepeat over current elementsloop. It can be used to:
 identify a specific opened element.
test the identity of the currently selected element.
get the name of the currently selected element.
get the number of opened elements, down to and including the currently selected element.
 It is possible to use a name as both an element alias-name and a "real" element name. If such a name is used in any context other than immediately following the keyword current element, it refers to the element with that name and not to the alias-name. Element alias names are subject to the setting of the namecase generaldeclaration in the same way as all other element names, even though they are not, in a strict sense, SGML element names. This code sample will close all of the elements which are currently open. Note, however, that because input to the parser is "buffered" while the loop is running, the elements won't actually be closed until the "repeat over" loop is complete.
   repeat over reversed current elements as this-element
  output "</"
  output name of current element this-element
  output ">"
  again
 |