[XQuery] fs:convert-operand / General comparison

Hi,

I have a question to the formal semantics of the general comparison. In http://www.w3.org/TR/2004/WD-xquery-semantics-20040220/#sec_general_comparisons <http://www.w3.org/TR/2004/WD-xquery-semantics-20040220/#sec_general_comparisons>  it is described as follows:

[Expr1 GeneralOp Expr2]Expr 
== 
some $v1 in fn:data([Expr1]Expr) satisfies 
some $v2 in fn:data([Expr2]Expr) satisfies 
let $u1 := fs:convert-operand($v1, $v2) return 
let $u2 := fs:convert-operand($v2, $v1) return 
[GeneralOp]GeneralOp ($u1, $u2) 

assuming Expr1 and Expr2 being sequences, there is a nested loop like this:

for all elements in Expr1
	for all elements in Expr 2
		let $u1 := fs:convert-operand($v1, $v2) return 
		let $u2 := fs:convert-operand($v2, $v1) return
		GeneralOp ($u1, $u2)

As described, $v1 will be converted to the type of $v2 or string depending on the type of $v2.
And then $v2 will be converted to the type of $v2??? Does this make any sense at all? Or should it rather be $v2 is converted to the type of $u1? In case of $v2 has type not equal xdt:untypedAtomic $u1 has the same type as $v2 and in the other case $u1 has type string and converting $v1 with $expected = type($u2) = xdt:string would yield $u2 having type string as well.

Am I right in assuming the correct equation to be:

[Expr1 GeneralOp Expr2]Expr 
== 
some $v1 in fn:data([Expr1]Expr) satisfies 
some $v2 in fn:data([Expr2]Expr) satisfies 
let $u1 := fs:convert-operand($v1, $v2) return 
let $u2 := fs:convert-operand($v2, $u1) return 
[GeneralOp]GeneralOp ($u1, $u2)

or am I just plain wrong?

Dealing with the same issue:
Considering function fs:convert-operand as described in http://www.w3.org/TR/2004/WD-xquery-semantics-20040220/#sec_convert_operand <http://www.w3.org/TR/2004/WD-xquery-semantics-20040220/> .
When having statEnv <http://www.w3.org/TR/2004/WD-xquery-semantics-20040220/> .xpath1.0_compatibility <http://www.w3.org/TR/2004/WD-xquery-semantics-20040220/>  = false, type($actual) = String and type($expected) = Integer no conversion is done, right? 
Considering a general comparison of a string and an integer value. According to the formal semantics of the general comparison, convert-operand would be called for both values but no conversion would take place actually. So I end up with a comparison of a string and an integer that is not defined (no overloaded comparison function exists taken these two types). That would force me to throw a XP0004 or XP0006 error due top the incompatible types, right?
Thanks & Cheers
Daniel

Received on Thursday, 15 April 2004 04:39:15 UTC