MarkLogic 9 Product Documentation
fn:index-of

fn:index-of(
   $seqParam as xs:anyAtomicType*,
   $srchParam as xs:anyAtomicType,
   [$collationLiteral as xs:string]
) as xs:integer*

Summary

Returns a sequence of positive integers giving the positions within the sequence $seqParam of items that are equal to $srchParam.

The collation used by the invocation of this function is determined according to the rules in 7.3.1 Collations. The collation is used when string comparison is required.

The items in the sequence $seqParam are compared with $srchParam under the rules for the eq operator. Values that cannot be compared, i.e. the eq operator is not defined for their types, are considered to be distinct. If an item compares equal, then the position of that item in the sequence $srchParam is included in the result.

If the value of $seqParam is the empty sequence, or if no item in $seqParam matches $srchParam, then the empty sequence is returned.

The first item in a sequence is at position 1, not position 0.

The result sequence is in ascending numeric order.

Parameters
seqParam A sequence of values.
srchParam A value to find on the list.
collationLiteral A collation identifier.

Example

fn:index-of((10, 20, 30, 40), 35) returns ().

fn:index-of((10, 20, 30, 30, 20, 10), 20)
  returns (2, 5).

fn:index-of(("a", "sport", "and", "a", "pastime"), "a")
  returns (1, 4).

If @a is an attribute of type xs:NMTOKENS whose
typed value is " red green blue ", then:

fn:index-of(@a, "blue") returns 3.

This is because the function calling mechanism
atomizes the attribute node to produce a sequence of
three xs:NMTOKENs.
Powered by MarkLogic Server | Terms of Use | Privacy Policy