elements of


Return type:
Returns a shelf of events corresponding to the element stack of element-expression.
elements of element-expression


Operator elements of returns a shelf of all markup-element-event regions that are open around the argument event. The first item of the resulting shelf is the root element of the document, and the lastmost contains the argument event. The shelf cannot be modified, and its items are not keyed.

You can use elements of in all the same ways you use other read-only, unkeyed shelves. You can get the number of the elements, iterate over them with a repeat over loop, copy the shelf, index it with an item number, or pass it to a function as a read-only argument:

  define string source function
     full-path (read-only markup-element-event elements)
     repeat over elements as e
        output "/" || name of e
  element "row" when full-path (elements of ancestor "table") = "/document/appendix/table"

If you apply elements of to an event produced by create-element-event, it will return a single-item shelf with the same event. It is more useful to apply elements of to an event created by a markup parser. Such an event can be captured using #current-markup-event or an element expression like ancestor in the above example. Events are immutable: the elements of a parsed event will always be the same, both during the parse and after the parse is complete.

current elements

The older version of this operator, current elements, is syntactically more constrained and its use is not recommended. Most uses of current elements of can be simply replaced by elements of, and uses of current elements not followed by of, by elements of element.

The only exception is repeat over current elements. If you replace current elements by elements in this case, you will also need to remove all the current element heralds preceding the shelf alias inside the loop body.