Returns the values that appear in a sequence, with duplicates eliminated.
The function returns the sequence that results from removing from
but one of a set of values that are considered equal to one another.
Two items $J and $K in the input sequence
(after atomization, as required by the function signature)
are considered equal if
fn:deep-equal($J, $K, $coll) is true,
$coll is the collation selected according to the rules in . This collation is used when string comparison is
The order in which the sequence of values is returned is implementation-dependent.
Which value of a set of values that compare equal is returned is implementation-dependent.
If the input sequence contains values of different numeric types that differ from each
other by small amounts, then the eq operator is not transitive, because of rounding
effects occurring during type promotion. In the situation where the input contains three
C such that
A eq B,
B eq C, but
A ne C, then the number of items in the result
of the function (as well as the choice of which items are returned) is implementation-dependent, subject only to the constraints that (a) no two
items in the result sequence compare equal to each other, and (b) every input item that
does not appear in the result sequence compares equal to some item that does appear in
the result sequence.
For example, this arises when computing:
distinct-values( (xs:float('1.0'), xs:decimal('1.0000000000100000000001', xs:double( '1.00000000001'))
because the values of type
xs:double both compare
equal to the value of type
xs:decimal but not equal to each other.
fn:distinct-values((1, 2.0, 3, 2)) returns
(1, 3, 2.0).
xs:untypedAtomic("plum"), xs:untypedAtomic("plum"))) returns
$arg is the empty sequence, the function returns the empty sequence.
Values of type
xs:untypedAtomic are compared as if they were of type
Values that cannot be compared, because the
eq operator is not defined for
their types, are considered to be distinct.
xs:double values, positive zero is equal to
negative zero and, although
NaN does not equal itself, if
NaN values a single
NaN is returned.
xs:time values do not
have a timezone, they are considered to have the implicit timezone provided by the
dynamic context for the purpose of comparison. Note that
xs:time values can compare equal even if their
timezones are different.