Hi, I'm Ask INFA!
What would you like to know?
ASK INFAPreview
Please to access Ask INFA.

Table of Contents

Search

  1. Preface
  2. Understanding Data Types and Field Properties
  3. Designing Processes
  4. Using and Displaying Data
  5. Designing Guides
  6. Designing Process Objects
  7. Designing Service Connectors
  8. Using App Connections
  9. System Services, Listeners and Connectors
  10. Designing Human Tasks

Design

Design

compare

compare

The compare function in XQuery is used to compare two strings using a specified collation. This function can help determine the order of strings, for example, sorting based on a defined collation.

Syntax

fn:compare(comparand1, comparand2, collation)
The following table describes the argument for this command:
Argument
Required/Optional
Description
comparand1
Required
The first string to be compared. This can be a valid string or
empty-sequence()
.
comparand2
Required
The second string to be compared. This can also be a valid string or
empty-sequence()
.
collation
Optional
A string that specifies the collation URI to be used for the comparison. If omitted, the default collation is used. The collation affects how string comparison is done, taking locale-specific rules into account.

Return Value

  • Returns a negative integer if
    $comparand1
    is less than
    $comparand2
    .
  • Returns zero if the strings are equal.
  • Returns a positive integer if
    $comparand1
    is greater than
    $comparand2
    .
  • Returns
    empty-sequence()
    if either input is
    empty-sequence()
    .

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:compare('a', 'b')
-1
fn:compare('a', 'a')
0
fn:compare('b', 'a')
1
fn:compare('ab', 'abc')
-1
fn:compare('a', 'B')
1
This shows that when using the simple code point collation, a lowercase
a
comes after an uppercase
B
.
fn:compare(upper-case('a'), upper-case('B'))
-1
fn:compare('a', ())
()
fn:compare('a', 'b', 'FOO')
Error FOCH0002
fn:compare((), ())
()

0 COMMENTS

We’d like to hear from you!