home contribute faq download

FunctX XSLT Functions

fn:index-of

The position(s) of an atomic value within a sequence

Google
Webxsltfunctions.com

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.

This description is © Copyright 2007, Priscilla Walmsley. It is excerpted from the book XQuery by Priscilla Walmsley, O'Reilly, 2007. For a complete explanation of this function, please refer to Appendix A of the book.

Arguments and Return Type

NameTypeDescription
$seqParam xs:anyAtomicType* the sequence of values
$srchParam xs:anyAtomicType the value to find the index of
$collation xs:string the collation to use for comparing strings
return value xs:integer*

Examples

XSLT ExampleResults
<index-of( ('a', 'b', 'c'), 'a'>
<1>
<index-of( ('a', 'b', 'c'), 'd'>
<()>)
<index-of(>ndex-of( (4, 5, 6, 4), 4)
<(1,>1, 4)
<index-of(>ndex-of( (4, 5, 6, 4), 04.0)
<(1,>1, 4)
<index-of( ('a', 5, 6), 'a'>
<1>
<index-of( (), 'a'>
<()>)

See Also

functx:index-of-nodeThe position of a node in a sequence, based on node identity
functx:index-of-deep-equal-nodeThe position of a node in a sequence, based on contents and attributes
fn:positionThe current context position

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26W3C, XQuery 1.0 and XPath 2.0 Functions and Operators, http://www.w3.org/TR/xpath-functions/
Datypic XSLT Services

Recommended Reading:

XQuery