.. _index-of:
========
index-of
========
The position(s) of an atomic value within a sequence
Description
~~~~~~~~~~~
The fn:index-of function returns the position(s) of an atomic value within a
sequence. The $seqParam argument is the sequence to be searched, while
$srchParam is the value to search for. This function returns a sequence of
integers representing the position(s) of the value within the sequence, in
order, starting with 1 (not 0).
The $seqParam sequence must contain all atomic values, or nodes that have atomic
typed values. The items in the sequence are compared to the search value by
their typed value, not node identity. Untyped values are treated like strings.
.. list-table::
:widths: 40 60
:header-rows: 1
* - **Parameters**
- **Description**
* - seqParam:string()
- the sequence of values
* - srchParam:string()
- the value to find the index of
* - collation:string()
- the collation to use for comparing strings
Examples
~~~~~~~~
.. list-table::
:widths: 50 50
:header-rows: 1
* - **XPath**
- **Results**
* - index-of( ('a', 'b', 'c'), 'a')
- 1
* - index-of( ('a', 'b', 'c'), 'd')
- ()
* - index-of( (4, 5, 6, 4), 4)
- (1, 4)
* - index-of( (4, 5, 6, 4), 04.0)
- (1, 4)
* - index-of( ('a', 5, 6), 'a')
- 1
* - index-of( (), 'a')
- ()
* - index-of( (1, 1), 1 )
- (1, 2)
See Also
~~~~~~~~
.. toctree::
:titlesonly:
:glob:
* :ref:`functx_index-of-node`.
* :ref:`functx_index-of-deep-equal-node`.
* :ref:`position`.