Use the following functions to perform logical operations within expressions. Most logical functions return 1 and 0 to indicate true or false. The exceptions are cmp, ncmp, and, and or.
Takes any number of arguments and returns zero if any argument values are logically false. If one child evaluates to false, the function does not evaluate subsequent children. If all arguments are logically true, the function returns the value of the last argument. Zero (<i>0</i> or <s>0</s>) and <null> are considered logically false.
The following expression returns zero.
<and> <i>42</i> <s>cat</s> <i>null</i> </and>
The following expression returns cat.
<and> <i>42</i> <s>cat</s> </and>
Compares two string values. You can use this function to sort a list of strings
The function returns:
negative number– value of the first argument is lexically less than the second.
positive number– first argument is lexically greater than the second
0 (zero) – arguments are equal
Arguments are coerced to strings, if necessary.
The following expression returns -1.
<cmp> <i>20</i> <i>100</i> </cmp>
The following expression returns -16. This expression returns a number that indicates the difference between the letters r and b when presented in alphabetical order. Since there are 16 letters between the letters b and r, when bob is compared to ray, the value is -16. Alternatively, if r were compared to b, the value returned would be 16.
<cmp> <s>bob</s> <s>ray</s> </cmp>
The following expression returns 0 (zero).
<cmp> <s>daryl</s> <s>daryl</s> </cmp>
Performs an equality test. The function can take multiple arguments, although typically it has only two. The data type of the first argument defines how the equality test is performed. If the first argument is of type:
string– all subsequent arguments are coerced to strings, and string comparison is performed
integer– all subsequent arguments are coerced to integers, and numeric comparison is performed
object– all subsequent arguments must be of type object, and the value of Object.equals is true for each
This function returns:
0– statement is logically false
1– statement is logically true
<eq> <ref>role</ref> <s>engineering</s> </eq>
Takes two arguments.
This function returns:
0– the first argument is numerically less than or equal to the second
1– the first argument is numerically greater than the second
<gt> <ref>age</ref> <i>42</i> </gt>
Takes two arguments.
This function returns:
0– first argument is less than the second
1– the first argument is numerically greater than or equal to the second
The following expression returns 1.
<gte> <i>10</i> <i>5</i> </gte>
Used when referencing Boolean values that are represented with the strings true and false rather than the number 0 and 1. Takes one argument.
This function returns:
0– the argument is logically true. The following are considered true: the string true, a Boolean true, and a non-zero integer. (Anything else is considered false.)
1– the argument is logically false or returns the string false.
The following expression returns 1.
<isFalse> <s>false</s> </isFalse>
Takes one argument.
This function returns:
0– statement is non-null
1– statement is null.
The following expression returns 1.
<isnull> <null/> </isnull>
The following expression returns 0.
<isnull> <i>0</i> </isnull>
Used when referencing Boolean values that are represented with the strings true and false rather than the number 0 and 1. Takes one argument.
This function returns:
0– the argument is logically false. The following are considered true: the string true, a Boolean true, and a non-zero integer. (Anything else is considered false.)
1– the argument is logically true.
The following expression returns 0.
<isTrue> <s>false</s> </isTrue>
Takes two arguments.
This function returns:
0– first argument is numerically greater than or equal to the second
1– first argument is numerically less than the second
The following expression returns 0 (zero).
<lt> <i>10</i> <i>5</i> </lt>
The following expression returns 1.
<lt> <i>5</i> <i>10</i> </lt>
Takes two arguments.
This function returns:
0– first argument is numerically greater than the second
1– first argument is numerically less than or equal to the second
<lte> <ref>age</ref> <i>42</i> </lte>
Performs case-insensitive comparison of two string values.
This function returns:
negative number– indicates that the value of the first argument is lexically less than the second
positive number– indicates that the first argument is lexically greater than the second
0 (zero) – indicates that the arguments are equal
Arguments are coerced to strings, if necessary.
The following expression returns 0.
<ncmp> <s>Daryl</s> <s>daryl</s> </ncmp>
Performs an inequality test. Its behavior is simply the negation of the equality test performed by the eq function.
This function returns:
0– the two arguments are equal
1– the two arguments are not equal
<neq> <ref>role</ref> <s>management</s> </neq>
Reverses the logic of the nested expression.
This function returns:
1– the value of the argument is logically false
0– argument is logically true
The following example returns 1.
<not> <eq> <i>42</i> <i>24</i> </eq> </not>
Takes multiple arguments.
This function returns:
0– all arguments are logically false
Value of the first argument expression that results in a logically true value
The following expression returns 0, which is logically false.
<or> <i>0</i> <i>0</i> </or>
The following expression returns the string cat, which is also logically true.
<or> <i>0</i> <s>cat</s> </or>
Takes one argument
This function returns:
0– null argument
1– non-null argument
The value of the following expression is 1 if the firstname has been set or 0 (zero) if firstname is null.
<notnull> <ref>firstname</ref> </notnull>
The value of the following expression is 0 because the value is null.
<notnull><null/></notnull>