The compare() Function

Release 2.0 - ...

Syntax

  CopyCode image Copy Code
number compare(string, string)

Description

This function returns -1, 0, or 1, depending on whether the value of the first argument is respectively less than, equal to, or greater than the value of second argument based on lexicographic comparison using Unicode code point values.

Example

XML CopyCode image Copy Code
<xforms:group>
   <xforms:output value="compare('apple','orange')">
      <xforms:label>compare('apple','orange') : </xforms:label>
   </xforms:output>
</xforms:group>
<xforms:group>
   <xforms:output value="compare('apple','apple')">
      <xforms:label>compare('apple','apple') : </xforms:label>
   </xforms:output>
</xforms:group>
<xforms:group>
   <xforms:output value="compare('orange','apple')">
      <xforms:label>compare('orange','apple') : </xforms:label>
   </xforms:output>
</xforms:group>

The above example returns -1, 0 and 1 respectively.

Specification

Link to the XForms specification: the compare() function.