XQuery questions

Friday, 1 July 2016 · 3 messages
M
meumapple1 Jul 2016 18:10 #
Does anyone knows why () != (1) evaluates to false? And why substring("aas", 1, 2) instance of function(*) evaluates to false? Thanks! Joseph
CG
Christian Grün1 Jul 2016 18:17 #
Quoted text · meumapple · 1 line
> () != (1) evaluates to false?
!= is an "existential comparison": every item on the left is compared with every item on the right. True is returned if there is at least one successful hit. As both the left and right sequence is empty, there will be nothing to compare, and the result is false. Here are some other examples that demonstrate the behavior: 1 = () 1 != () (1,2) = (2,3) <a><b>X</b><b>Y</b></a>/b = 'X'
Quoted text · meumapple · 1 line
> substring("aas", 1, 2) instance of function(*) evaluates to false?
Because substring("aas", 1, 2) returns a string. This one will give you true: (: function with 3 arguments) substring#3 instance of function(*)
M
meumapple1 Jul 2016 19:04 #
Great
Quoted text · Christian Grün · 3 lines
> Il giorno 01 lug 2016, alle ore 18:17, Christian Grün <christian.gruen at gmail.com> ha scritto: > > () != (1) evaluates to false?
!= is an "existential comparison": every item on the left is compared with every item on the right. True is returned if there is at least one successful hit. As both the left and right sequence is empty, there will be nothing to compare, and the result is false. Here are some other examples that demonstrate the behavior: 1 = () 1 != () (1,2) = (2,3) <a><b>X</b><b>Y</b></a>/b = 'X'
Quoted text · Christian Grün · 1 line
> substring("aas", 1, 2) instance of function(*) evaluates to false?
Because substring("aas", 1, 2) returns a string. This one will give you true: (: function with 3 arguments) substring#3 instance of function(*)

⚡Generated with XQuery