Predicates

Each location step may include predicates. A predicate is an expression enclosed in square brackets ([ ]) that filters an object set.

For each object in the set to be filtered, the predicate expression is evaluated with that object as the context object, and with the number of objects in the object set as the context size. All predicates in a location step must be true for an object to be selected.

You can use only searchable properties in a predicate, unless you are testing the property for nil or non-nil values.

A predicate expression can include logical or comparison operators.

For example, the following search path selects all folders that have the hasPermission property set to either read or traverse:

//folder[permission('read') or permission('traverse')]

If the predicate consists of only a property name, objects for which that property is not nil will be selected. For example, the following search path selects all packages that have a value specified for the routingHint property:

/content/package[@routingHints]

The following search path selects all packages that have a nil routingHint property:

/content/package[not(@routingHints)]

Note: You cannot filter nil or non-nil values for a read-only property or a property acquired from a containing object.