Skip to content

Binary comparisons #2139

Description

@ChristianGruen

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething that doesn't work in the current specificationPR PendingA PR has been raised to resolve this issueXQFOAn issue related to Functions and Operators

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions