You can also use path expressions to traverse values that are lists. Consider an object that has an attribute children whose value is a java.util.List. Each object in the list is itself a GenericObject with a name attribute and an age attribute. Write the path to the name of the first child as:
children[#0].name
Path expressions use square brackets to indicate the indexing of a list. The token between brackets is the index expression. In the simplest case, this is a positive integer that is used to index the list by element position.
Typically, the position of an object in a list is arbitrary. Index expressions can also specify simple search criteria to identify one object in the list. Objects in a list typically have a name attribute, which serves to uniquely identify this object among its peers. Path expressions support an implicit reference to an object’s name attribute within the index expression.
For example
children[hannah].age
The preceding path expression obtains the list of objects stored under the children attribute. This list is searched until an object with a name attribute equal to hannah is found. If a matching object is found, Waveset returns the value of the age attribute.
<ref>accountInfo.accounts[type=vms].name</ref>
accountInfo.accounts[type=vms].name returns a list of names for VMS resources. It returns a list of only one element if only one exists.
children[hannah].age is equivalent to children[name==hannah].age. If you search using type=LDAP for example, you would get a list of names of LDAP resources. However, if you use the == operator, the result is a single object. For example, children[parent=hannah].occupation returns a list of occupations for all of hannah’s children, but children[parent==hannah].occupation returns a single occupation (not in a list) for whichever child was found first.
Example
<index i=’0’> < ref>accountInfo.accounts[type=vms].name</ref> </index>
is equivalent to
<ref>accountInfo.accounts[type==vms].name</ref>
If more than one account with type vms exists, then either example will return the first account found with no particular guaranteed ordering.