using attribute
Full Description
swirl
Syntax
  using attribute attribute-name element-qualifier*
     ((item | @) numeric-expression)?


Purpose

This prefix allows attributes to be referenced without repeating the element qualifiers or the item indexer. It is also useful when using the "%v" format item on an attribute which does not belong to the current element.

Either the element qualifier or the item indexer must be specified.

The scope of the using prefix is the action it precedes. It does not carry down into subelements through a %c operator. The using prefix is frequently employed with compound actions.

Each time an item on the specified shelf is referenced in the action without an indexer, the item specified by using is used.

The item specified by the using prefix is looked up every time the shelf is referenced without an indexer. That means that when the using prefix specifies the item using:

  • lastmost, the selected items are moved to the end of the shelf.
  • @ (item), the selected item changes when new items are inserted before the specified one.
  • ^ (key), the selected item changes if the key is removed from the selected item and applied to a different item.

Specifying lastmost in a usingprefix, or in a passed read-only or modifiable function argument, effectively re-establishes the default behavior for the current item on the shelf. That is, the last item on the shelf when it is referenced is the default item. It can be used to cancel the effect of any outer establishment of a default item.

A using attribute prefix will cause input to the parser to be buffered until the action to which it applies completes.

This following example illustrates how attribute aliases can be used to simplify attribute identification when more than one opened element has an attribute with the same name.

In this example, the attribute alias parent-type allows the parent's type attribute to be easily identified, especially in "%v" formats, even if the currently opened element has an attribute named "type".

  using attribute type of parent as parent-type
     do when attribute type != attribute parent-type
        output "Type attributes differ:%n" _
               "  current: %v(type)%n" _
               "  parent's: %v(parent-type)%n"
     done

Copyright © OmniMark Technologies Corporation, 1988-1998.