11 Operators on base64Binary and hexBinary

11.1 Comparisons of base64Binary and hexBinary values

The following comparison operators on xs:base64Binary and xs:hexBinary values are defined. Comparisons take two operands of the same type; that is, both operands must be xs:base64Binary or both operands may be xs:hexBinary. Each returns a boolean value.

A value of type xs:hexBinary can be compared with a value of type xs:base64Binary by casting one value to the other type. See 19.1.6 Casting to xs:base64Binary and xs:hexBinary.

Function Meaning
op:hexBinary-equal Returns true if two xs:hexBinary values contain the same octet sequence.
op:hexBinary-less-than Returns true if the first argument is less than the second.
op:base64Binary-equal Returns true if two xs:base64Binary values contain the same octet sequence.
op:base64Binary-less-than Returns true if the first argument is less than the second.

11.1.1 op:hexBinary-equal

Summary

Returns true if two xs:hexBinary values contain the same octet sequence.

Operator Mapping

Defines the semantics of the "eq" and "ne" operators when applied to two xs:hexBinary values.

Signature
op:hexBinary-equal(
$value1 as xs:hexBinary,
$value2 as xs:hexBinary
) as xs:boolean
Rules

The function returns true if $value1 and $value2 are of the same length, measured in binary octets, and contain the same octets in the same order. Otherwise, it returns false.

11.1.2 op:hexBinary-less-than

Summary

Returns true if the first argument is less than the second.

Operator Mapping

Defines the semantics of the "lt" operator when applied to two xs:hexBinary values. Also used in the definition of the "ge" operator.

Signature
op:hexBinary-less-than(
$arg1 as xs:hexBinary,
$arg2 as xs:hexBinary
) as xs:boolean
Rules

The function returns true if any of the following conditions is true:

  1. $arg1 is zero-length (contains no octets) and $arg2 is not zero-length.

  2. Neither argument is zero-length, and the first octet of $arg1 is less than the first octet of $arg2, treating the value of the octet as an unsigned integer in the range 0 to 255.

  3. Neither argument is zero-length, the first octet of $arg1 is equal to the first octet of $arg2, and the xs:hexBinary value formed by taking all octets of arg1 after the first is less than the xs:hexBinary value formed by taking all octets of arg2 after the first.

Otherwise, the function returns false.

11.1.3 op:base64Binary-equal

Summary

Returns true if two xs:base64Binary values contain the same octet sequence.

Operator Mapping

Defines the semantics of the "eq" and "ne" operators when applied to two xs:base64Binary values.

Signature
op:base64Binary-equal(
$value1 as xs:base64Binary,
$value2 as xs:base64Binary
) as xs:boolean
Rules

The function returns true if $value1 and $value2 are of the same length, measured in binary octets, and contain the same octets in the same order. Otherwise, it returns false.

11.1.4 op:base64Binary-less-than

Summary

Returns true if the first argument is less than the second.

Operator Mapping

Defines the semantics of the "lt" operator when applied to two xs:base64Binary values. Also used in the definition of the "ge" operator.

Signature
op:base64Binary-less-than(
$arg1 as xs:base64Binary,
$arg2 as xs:base64Binary
) as xs:boolean
Rules

The function returns true if any of the following conditions is true:

  1. $arg1 is zero-length (contains no octets) and $arg2 is not zero-length.

  2. Neither argument is zero-length, and the first octet of $arg1 is less than the first octet of $arg2, treating the value of the octet as an unsigned integer in the range 0 to 255.

  3. Neither argument is zero-length, the first octet of $arg1 is equal to the first octet of $arg2, and the xs:base64Binary value formed by taking all octets of arg1 after the first is less than the xs:base64Binary value formed by taking all octets of arg2 after the first.

Otherwise, the function returns false.