It seems confusing to me that deep-equal & atomic-equal return different results than eq for binary types:
let $hex := xs:hexBinary(''), $base64 := xs:base64Binary('')
return (
(: false :) deep-equal($hex, $base64),
(: false :) atomic-equal($hex, $base64),
(: true :) $hex eq $base64
)
The rules say:
fn:deep-equal
If both $i1 and $i2 are instances of xs:hexBinary or xs:base64Binary, $i1 eq $i2 returns true.
This can be interpreted in two ways, but it seems to mean that $i1 and $i2 need to have the same type?
fn:atomic-equal
One of the following conditions is true:
$value1 and $value2 are both instances of xs:hexBinary.
$value1 and $value2 are both instances of xs:base64Binary.
op:binary-equal
op:binary-equal(
$value1 as (xs:hexBinary | xs:base64Binary),
$value2 as (xs:hexBinary | xs:base64Binary)
) as xs:boolean
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.
As atomic-equal(xs:double(3), xs:float(3)) returns true, I would also expect true for binary items with the same contents.
Related (for numbers): #986
It seems confusing to me that
deep-equal&atomic-equalreturn different results thaneqfor binary types:The rules say:
fn:deep-equalThis can be interpreted in two ways, but it seems to mean that
$i1and$i2need to have the same type?fn:atomic-equalop:binary-equalAs
atomic-equal(xs:double(3), xs:float(3))returnstrue, I would also expecttruefor binary items with the same contents.Related (for numbers): #986