company logo

Reference element

A reference element just consists of a property (or variable) name: Reference elements can be used at any position in a path.

persons.children.children

Usually, reference elements will not change selection and do refer to the currently selected instance in the path. Especially in OSI expressions, this is used to selects an instance in a collection and referring to it in the next statement(s).

The application is responsible to select property instances in reference elements, because otherwise, the path returns nothing.

As long as the path uses reference elements, those will refer to the preselected instances. When the path, however, contains an iteration or selector element, subsequent reference elements do not have the same selection and are known in the context of the path, only. Thus,

persons.children.children

and

persons.children().children

refer to the same selection in person, but children () usually has a different selection from children and so do all subsequent reference elements.

  person.Get(0);        // selects the first person in the collection

  Message(person.name); // prints the name of the selected person

  if ( person.children.Next ) // selects the next child for the selected pwerson

    Message(person.children.name);     // prints the name of the selected child