XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition (544 page)

BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
7.17Mb size Format: txt, pdf, ePub

compare($x, $y, if ($param-uri) then $param-uri else default-collation())

When you call a function that expects a collation, you can always omit the argument to request the default collation, but you cannot supply a value such as an empty sequence or a zero-length string: if the argument is present, then it must be a valid collation.

See Also

compare()
on page 727

deep-equal()
on page 745

distinct-values()
on page 749

index-of()
on page 807

max()
on page 830

min()
on page 830

Value Comparisons
on page 581 in Chapter 8

distinct-values

The
distinct-values()
function eliminates duplicate values from a sequence.

For example,
distinct-values((3, 5, 3, 6))
might return
(5, 6, 3)
.

Signature

Argument
Type
Meaning
sequence
xs:anyAtomicType*
The input sequence
collation
(optional)
xs:string
The collation to be used when comparing values that are strings
Result
xs:anyAtomicType*
The input sequence, with duplicate values removed

Effect

If a sequence containing nodes is supplied as the argument, the nodes are first atomized as part of the standard function calling rules.

An untyped atomic value in the sequence is treated as a string.

If two or more values in the sequence are equal to each other (according to the rules of the
eq
operator, using the specified collation when comparing strings), then only one of them is included in the result sequence. It is not defined which of them will be retained (for example, if the input sequence contains the
xs:integer
3 and the
xs:decimal
3.0, then it is unpredictable which of these two values will be present in the result). In addition, the order of the values in the result sequence is undefined.

If the sequence contains two values that are not comparable using the
eq
operator (for example, an integer and a string), then these values are treated as distinct; no error is reported.

For the purpose of this function, NaN is considered equal to itself, and distinct from any other value.

Examples

Assume that the default collation is case-blind, that is, that it treats the strings
A
and
a
as equal. The table below gives one possible result for each expression; a particular XPath processor might return some permutation of this result, or might include different items from a set that are equal to each other (such as
A
and
a
).

Other books

Dancing with a Rogue by Potter, Patricia;
Crustaceans by Andrew Cowan
Unruly Urges by Evans, Lily
False Security by Angie Martin
Ratha's Courage by Clare Bell
Chosen by Denise Grover Swank
Antiphony by Chris Katsaropoulos
Pied Piper by Nevil Shute
Time and Again by Clifford D. Simak