The compare function takes two strings as arguments and compares them for equality and alphabetically, using the collation supplied as argument. If string1 is alphabetically less than string2 (for example the two string are "A" and "B"), then the function returns -1. If the two strings are equal (for example, "A" and "A"), the function returns 0. If string1 is greater than string2 (for example, "B" and "A"), then the function returns 1.
XQuery, XSLT 2.0, XSLT 3.0.
The first input string.
The second input string.
Specifies the collation to use for string comparison. This input may originate from the output of the default-collation function or it may be a collation such as http://www.w3.org/2005/xpath-functions/collation/html-ascii-case-insensitive.
The following mapping compares the strings "A" and "a" using the case insensitive collation http://www.w3.org/2005/xpath-functions/collation/html-ascii-case-insensitive, which is supplied by a constant.
XSLT 2.0 Mapping
The result of the mapping above is 0, meaning that both strings are treated as equal. However, if you replace the collation with the one provided by the default-collation function, the collation changes to the default Unicode code point collation, and the mapping result becomes -1 ("A" is alphabetically less than "a").