RE: Feedback on XQuery F&O

Additional comments from Michael Kay
> 
> 3 (Error function) and Issue #181 (semantics of fn:error)
> 
> Consider aligning this function with XSLT's message system 
> (which can optionally terminate or not).
> 
>   ----
> [AM] The error function may be implemented in different ways 
> by languages that use Xpath.  XSLT may want to use the 
> message system but this is their decision.

I think that they may have been suggesting an option where fn:error()
produces an error message but doesn't terminate. This aligns with another
proposal to add an fn:trace() function. I can see something like this being
needed in XQuery - I don't think it's needed in XPath.

> 
> 8.3.1-8.3.21 (op:*-equal) Useless definitions
> 
> "Returns true if and only if $operand1 is exactly equal to 
> $operand2." Well, duh.  But what is the meaning of the phrase 
> "is exactly equal to" ?? [AM] Should we say valuesd are 
> exactly equal.  It's hard to say something useful without a 
> multi-page disquisition on equality.  Feel free to suggest 
> alternate wording.

We definitely need to say, for each data type, exactly what we mean by
equality. This comment has been made a number of times. In most cases I
don't think it needs a multi-page disquisition. In some cases we can refer
to the XML Schema definition, but not in all cases.

> 13.1.7 (fn:deep-equal)

> The equivalent XQuery given for deep-equal() is incorrect.  When both
nodes lack > a name, the second condition fails.

Not quite

The test
  (node-name($a) != node-name($b))

returns true if there is a pair of items, one from node-name($a) and one
from node-name($b), that are not equal to each other. If neither node has a
name, then there is no such pair, so we take the "else" branch.

The test is wrong, however, if one node has a name and the other does not.

I think the test should be written:

if (!sequence-deep-equal(node-name($a), node-name($b)))
then false()
else

after correcting the handling of () by sequence-deep-equal, noted below.

> 
> 14.3.1 (fn:sequence-deep-equal)
> 
> The sequence-deep-equal() function is strangely asymmetric with the
> sequence-node-equal() function.  The latter returns the empty 
> sequence if either argument is empty, but the former does not.
> 
> [AM] I'll raise this with the taskforce.
> 

It's clearly a nonsense that sequence-deep-equal returns () when one of the
sequences is empty. It should return false if one is empty, true if they are
both empty. 

In fact sequence-deep-equal($a, $b) should be defined as:

count($a) = count($b)
  and
every $i in (1 to count($a)) satisfies (
  if ($a[i] instance of atomic 
      and $b[i] instance of atomic )
      then ($a[i] eq $b[i]) 
  else if ($a[i] instance of node
      and $b[i] instance of node)
      then deep-equal($a[$i], $b[$i])) 
  else false()
}

While sequence-node-equal($a, $b) should be defined as:

count($a) = count($b)
  and
every $i in (1 to count($a)) satisfies
  $a[$i] is $b[$i]

Michael Kay

Received on Tuesday, 4 February 2003 11:04:36 UTC