<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/fn.indexOf.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>fn.indexOf</api:function-name><api:suggest>fn.indexof</api:suggest><api:suggest>fn</api:suggest><api:suggest>indexof</api:suggest><api:function-link mode="xquery" fullname="fn:index-of">/apidoc/8.0/fn:index-of.xml</api:function-link><api:function mode="javascript" name="indexOf" type="builtin" lib="fn" category="SequenceBuiltins" bucket="W3C-Standard Functions" hidden="false" prefix="fn" namespace="http://www.w3.org/2005/xpath-functions" fullname="fn.indexOf"><api:summary>
<p xmlns="http://www.w3.org/1999/xhtml">
Returns a sequence of positive integers giving the positions within the
sequence $seqParam of items that are equal to $srchParam.
</p><p xmlns="http://www.w3.org/1999/xhtml">
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.
</p><p xmlns="http://www.w3.org/1999/xhtml">
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.
</p><p xmlns="http://www.w3.org/1999/xhtml">
If the value of $seqParam is the empty sequence, or if no item in $seqParam
matches $srchParam, then the empty sequence is returned.
</p><p xmlns="http://www.w3.org/1999/xhtml">
The first item in a sequence is at position 1, not position 0.
</p><p xmlns="http://www.w3.org/1999/xhtml">
The result sequence is in ascending numeric order.
</p>
</api:summary><api:params><api:param name="seqParam" type="xs:anyAtomicType*"><api:param-description>
A sequence of values.
  </api:param-description><api:param-name>seqParam</api:param-name><api:param-type>(String | Number | Boolean | null)[]</api:param-type></api:param><api:param name="srchParam" type="xs:anyAtomicType"><api:param-description>
A value to find on the list.
  </api:param-description><api:param-name>srchParam</api:param-name><api:param-type>xs.anyAtomicType</api:param-type></api:param><api:param name="collationLiteral" type="xs:string" optional="true"><api:param-description>
A collation identifier.
  </api:param-description><api:param-name>collationLiteral</api:param-name><api:param-type>String</api:param-type></api:param></api:params><api:return>ValueIterator</api:return><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
fn.indexOf([10, 20, 30, 40], 35); 
=&gt; returns ().

fn.indexOf([10, 20, 30, 30, 20, 10], 20)
=&gt;  returns (2, 5) as a ValueIterator.

fn.indexOf(["a", "sport", "and", "a", "pastime"], "a")
=&gt;  returns (1, 4) as a ValueIterator.

// a is a variable whose value is the attribute @a
// of type xs:NMTOKENS whose typed value is " red green blue " 
fn.indexOf(a, "blue") returns 3.

This is because the function calling mechanism
atomizes the attribute node to produce a sequence of
three xs:NMTOKENs.
</pre>
</api:example></api:function></api:function-page>