Unexpected unary lookup result
Friday, 11 May 2018 · 7 messages · last reply 14 May 2018
SZ
Sebastian Zimmer11 May 2018 01:50 #
Hi,
I have this script where I use the lookup operator to perform a unary lookup:
xquery version "3.1";
declare namespace array = "http://www.w3.org/2005/xpath-functions/array";
let $array := []
return (
empty($array!?*), (: returns false :)
empty(
for $i in 1 to array:size($array)
return $array($i)
) (: returns true :)
)I'm curious that the first expression returns false even though it should be equivalent to the second expression, if I read the XQuery spec [1] right:
If the context item is an array:
If theKeySpecifier
<https://www.w3.org/TR/2017/REC-xquery-31-20170321/#doc-xquery31-KeySpecifier>is a wildcard ("|*|"), theUnaryLookup
<https://www.w3.org/TR/2017/REC-xquery-31-20170321/#doc-xquery31-UnaryLookup>operator is equivalent to the following expression:
for $k in 1 to array:size(.)
return .($k)But maybe I'm missing something. I'd be glad if you could help.
Best regards,
Sebastian Zimmer
[1] https://www.w3.org/TR/2017/REC-xquery-31-20170321/#id-unary-lookup
--
Sebastian Zimmer
sebastian.zimmer at uni-koeln.de <mailto:sebastian.zimmer at uni-koeln.de> CCeH Logo <http://cceh.uni-koeln.de>
Cologne Center for eHumanities <http://cceh.uni-koeln.de>
DH Center at the University of Cologne
Twitter Logo <https://twitter.com/CCeHum>@CCeHum
<https://twitter.com/CCeHum>
GC
Giuseppe Celano11 May 2018 08:28 #
Hi Sebastian,
In my Basex 9.0.1 and 8.6.7 you get two "true".
Best,
Giuseppe
Universität Leipzig
Institute of Computer Science, NLP
Augustusplatz 10
04109 Leipzig
Deutschland
E-mail: celano at informatik.uni-leipzig.de
E-mail: giuseppegacelano at gmail.com
Web site 1: http://www.dh.uni-leipzig.de/wo/team/
Web site 2: https://sites.google.com/site/giuseppegacelano/
Quoted text · Sebastian Zimmer · 35 lines
> On May 11, 2018, at 1:50 AM, Sebastian Zimmer <sebastian.zimmer at uni-koeln.de> wrote: > > Hi, > > I have this script where I use the lookup operator to perform a unary lookup: > > xquery version "3.1"; > declare namespace array = "http://www.w3.org/2005/xpath-functions/array" <http://www.w3.org/2005/xpath-functions/array>; > > let $array := [] > > return ( > empty($array!?*), (: returns false :) > empty( > for $i in 1 to array:size($array) > return $array($i) > ) (: returns true :) > ) > I'm curious that the first expression returns false even though it should be equivalent to the second expression, if I read the XQuery spec [1] right: > > If the context item is an array: > If the KeySpecifier <https://www.w3.org/TR/2017/REC-xquery-31-20170321/#doc-xquery31-KeySpecifier> is a wildcard ("*"), the UnaryLookup <https://www.w3.org/TR/2017/REC-xquery-31-20170321/#doc-xquery31-UnaryLookup> operator is equivalent to the following expression: > for $k in 1 to array:size(.) > return .($k) > But maybe I'm missing something. I'd be glad if you could help. > Best regards, > Sebastian Zimmer > [1] https://www.w3.org/TR/2017/REC-xquery-31-20170321/#id-unary-lookup <https://www.w3.org/TR/2017/REC-xquery-31-20170321/#id-unary-lookup> > -- > Sebastian Zimmer > sebastian.zimmer at uni-koeln.de <mailto:sebastian.zimmer at uni-koeln.de> > <cceh-logo-cyan.png> <http://cceh.uni-koeln.de/> > Cologne Center for eHumanities <http://cceh.uni-koeln.de/> > DH Center at the University of Cologne > <twitter_logo.png> <https://twitter.com/CCeHum>@CCeHum <https://twitter.com/CCeHum>
SZ
Sebastian Zimmer11 May 2018 11:04 #
Hi Giuseppe,
thanks for checking. I double-checked again. The problem is even weirder now:
When using the console, I too get 2x true:
$ ./bin/basex "./webapp/array_test.xql"
true
true
When using the web server, I still get this:
$ curl localhost:8994/rest?run=array_test.xql
false
true
At first I thought there was some cache at work, preventing the update, but it doesn't seem to be the case. I can edit the XQL und both outputs change accordingly, but the first boolean is still different.
Best regards,
Sebastian
Quoted text · Giuseppe Celano · 72 lines
Am 11.05.2018 um 08:28 schrieb Giuseppe Celano: > Hi Sebastian, > > In my Basex 9.0.1 and 8.6.7 you get two "true". > > Best, > Giuseppe > > Universität Leipzig > Institute of Computer Science, NLP > Augustusplatz 10 > 04109 Leipzig > Deutschland > E-mail: celano at informatik.uni-leipzig.de > <mailto:celano at informatik.uni-leipzig.de> > E-mail: giuseppegacelano at gmail.com > Web site 1: http://www.dh.uni-leipzig.de/wo/team/ > Web site 2: https://sites.google.com/site/giuseppegacelano/ > >> On May 11, 2018, at 1:50 AM, Sebastian Zimmer >> <sebastian.zimmer at uni-koeln.de >> <mailto:sebastian.zimmer at uni-koeln.de>> wrote: >> >> Hi, >> >> I have this script where I use the lookup operator to perform a unary >> lookup: >> >> xquery version "3.1"; >> declare namespace array ="http://www.w3.org/2005/xpath-functions/array"; >> >> let $array := [] >> >> return ( >> empty($array!?*), (: returns false :) >> empty( >> for $i in 1 to array:size($array) >> return $array($i) >> ) (: returns true :) >> ) >> >> I'm curious that the first expression returns false even though it >> should be equivalent to the second expression, if I read the XQuery >> spec [1] right: >> >> If the context item is an array: >> If theKeySpecifier >> <https://www.w3.org/TR/2017/REC-xquery-31-20170321/#doc-xquery31-KeySpecifier>is >> a wildcard ("|*|"), theUnaryLookup >> <https://www.w3.org/TR/2017/REC-xquery-31-20170321/#doc-xquery31-UnaryLookup>operator >> is equivalent to the following expression: >> for $k in 1 to array:size(.) >> return .($k) >> >> But maybe I'm missing something. I'd be glad if you could help. >> >> Best regards, >> Sebastian Zimmer >> >> [1] https://www.w3.org/TR/2017/REC-xquery-31-20170321/#id-unary-lookup >> >> -- >> Sebastian Zimmer >> sebastian.zimmer at uni-koeln.de <mailto:sebastian.zimmer at uni-koeln.de> >> <cceh-logo-cyan.png> <http://cceh.uni-koeln.de/> >> >> Cologne Center for eHumanities <http://cceh.uni-koeln.de/> >> DH Center at the University of Cologne >> <twitter_logo.png> <https://twitter.com/CCeHum>@CCeHum >> <https://twitter.com/CCeHum> >> >
--
Sebastian Zimmer
sebastian.zimmer at uni-koeln.de <mailto:sebastian.zimmer at uni-koeln.de> CCeH Logo <http://cceh.uni-koeln.de>
Cologne Center for eHumanities <http://cceh.uni-koeln.de>
DH Center at the University of Cologne
Twitter Logo <https://twitter.com/CCeHum>@CCeHum
<https://twitter.com/CCeHum>
SZ
Sebastian Zimmer11 May 2018 11:12 #
Hi again,
the problem is gone now after a reboot. It seems that the web server was running on another version while the console was running with 9.0.1
Sorry for the inconvenience.
Best,
Sebastian
Quoted text · Sebastian Zimmer · 110 lines
Am 11.05.2018 um 11:04 schrieb Sebastian Zimmer: > > Hi Giuseppe, > > thanks for checking. I double-checked again. The problem is even > weirder now: > > When using the console, I too get 2x true: > > $ ./bin/basex "./webapp/array_test.xql" > true > true > > When using the web server, I still get this: > > $ curl localhost:8994/rest?run=array_test.xql > false > true > > At first I thought there was some cache at work, preventing the > update, but it doesn't seem to be the case. I can edit the XQL und > both outputs change accordingly, but the first boolean is still different. > > Best regards, > Sebastian > > > Am 11.05.2018 um 08:28 schrieb Giuseppe Celano: >> Hi Sebastian, >> >> In my Basex 9.0.1 and 8.6.7 you get two "true". >> >> Best, >> Giuseppe >> >> Universität Leipzig >> Institute of Computer Science, NLP >> Augustusplatz 10 >> 04109 Leipzig >> Deutschland >> E-mail: celano at informatik.uni-leipzig.de >> <mailto:celano at informatik.uni-leipzig.de> >> E-mail: giuseppegacelano at gmail.com >> Web site 1: http://www.dh.uni-leipzig.de/wo/team/ >> Web site 2: https://sites.google.com/site/giuseppegacelano/ >> >>> On May 11, 2018, at 1:50 AM, Sebastian Zimmer >>> <sebastian.zimmer at uni-koeln.de >>> <mailto:sebastian.zimmer at uni-koeln.de>> wrote: >>> >>> Hi, >>> >>> I have this script where I use the lookup operator to perform a >>> unary lookup: >>> >>> xquery version "3.1"; >>> declare namespace array ="http://www.w3.org/2005/xpath-functions/array"; >>> >>> let $array := [] >>> >>> return ( >>> empty($array!?*), (: returns false :) >>> empty( >>> for $i in 1 to array:size($array) >>> return $array($i) >>> ) (: returns true :) >>> ) >>> >>> I'm curious that the first expression returns false even though it >>> should be equivalent to the second expression, if I read the XQuery >>> spec [1] right: >>> >>> If the context item is an array: >>> If theKeySpecifier >>> <https://www.w3.org/TR/2017/REC-xquery-31-20170321/#doc-xquery31-KeySpecifier>is >>> a wildcard ("|*|"), theUnaryLookup >>> <https://www.w3.org/TR/2017/REC-xquery-31-20170321/#doc-xquery31-UnaryLookup>operator >>> is equivalent to the following expression: >>> for $k in 1 to array:size(.) >>> return .($k) >>> >>> But maybe I'm missing something. I'd be glad if you could help. >>> >>> Best regards, >>> Sebastian Zimmer >>> >>> [1] https://www.w3.org/TR/2017/REC-xquery-31-20170321/#id-unary-lookup >>> >>> -- >>> Sebastian Zimmer >>> sebastian.zimmer at uni-koeln.de <mailto:sebastian.zimmer at uni-koeln.de> >>> <cceh-logo-cyan.png> <http://cceh.uni-koeln.de/> >>> >>> Cologne Center for eHumanities <http://cceh.uni-koeln.de/> >>> DH Center at the University of Cologne >>> <twitter_logo.png> <https://twitter.com/CCeHum>@CCeHum >>> <https://twitter.com/CCeHum> >>> >> > > -- > Sebastian Zimmer > sebastian.zimmer at uni-koeln.de <mailto:sebastian.zimmer at uni-koeln.de> > CCeH Logo <http://cceh.uni-koeln.de> > > Cologne Center for eHumanities <http://cceh.uni-koeln.de> > DH Center at the University of Cologne > Twitter Logo <https://twitter.com/CCeHum>@CCeHum > <https://twitter.com/CCeHum> >
--
Sebastian Zimmer
sebastian.zimmer at uni-koeln.de <mailto:sebastian.zimmer at uni-koeln.de> CCeH Logo <http://cceh.uni-koeln.de>
Cologne Center for eHumanities <http://cceh.uni-koeln.de>
DH Center at the University of Cologne
Twitter Logo <https://twitter.com/CCeHum>@CCeHum
<https://twitter.com/CCeHum>
SZ
Sebastian Zimmer11 May 2018 12:52 #
Sorry to bother you again, but I think there is still something wrong with my code and I can't figure it out. This time I checked it consistently on BaseX 9.0.1 (Windows and Linux, console and web server), results are always the same:
xquery version "3.1";
declare namespace array = "http://www.w3.org/2005/xpath-functions/array";
let $array1 := []
let $array2 := array:for-each([], function($i) { lower-case($i) })
let $array3 := array:for-each([], function($i) { $i + 1 })
return (
empty($array1!?*),
empty($array2!?*),
empty($array3!?*),
empty(
for $i in 1 to array:size($array1)
return $array1($i)
),
empty(
for $i in 1 to array:size($array2)
return $array2($i)
),
empty(
for $i in 1 to array:size($array3)
return $array3($i)
)
)The results I get are:
true
false
true
true
true
true
Why isn't the second result "true" too?
Best regards,
Sebastian
Quoted text · Sebastian Zimmer · 134 lines
Am 11.05.2018 um 11:12 schrieb Sebastian Zimmer: > > Hi again, > > the problem is gone now after a reboot. It seems that the web server > was running on another version while the console was running with 9.0.1 > > Sorry for the inconvenience. > > Best, > Sebastian > > Am 11.05.2018 um 11:04 schrieb Sebastian Zimmer: >> >> Hi Giuseppe, >> >> thanks for checking. I double-checked again. The problem is even >> weirder now: >> >> When using the console, I too get 2x true: >> >> $ ./bin/basex "./webapp/array_test.xql" >> true >> true >> >> When using the web server, I still get this: >> >> $ curl localhost:8994/rest?run=array_test.xql >> false >> true >> >> At first I thought there was some cache at work, preventing the >> update, but it doesn't seem to be the case. I can edit the XQL und >> both outputs change accordingly, but the first boolean is still >> different. >> >> Best regards, >> Sebastian >> >> >> Am 11.05.2018 um 08:28 schrieb Giuseppe Celano: >>> Hi Sebastian, >>> >>> In my Basex 9.0.1 and 8.6.7 you get two "true". >>> >>> Best, >>> Giuseppe >>> >>> Universität Leipzig >>> Institute of Computer Science, NLP >>> Augustusplatz 10 >>> 04109 Leipzig >>> Deutschland >>> E-mail: celano at informatik.uni-leipzig.de >>> <mailto:celano at informatik.uni-leipzig.de> >>> E-mail: giuseppegacelano at gmail.com >>> Web site 1: http://www.dh.uni-leipzig.de/wo/team/ >>> Web site 2: https://sites.google.com/site/giuseppegacelano/ >>> >>>> On May 11, 2018, at 1:50 AM, Sebastian Zimmer >>>> <sebastian.zimmer at uni-koeln.de >>>> <mailto:sebastian.zimmer at uni-koeln.de>> wrote: >>>> >>>> Hi, >>>> >>>> I have this script where I use the lookup operator to perform a >>>> unary lookup: >>>> >>>> xquery version "3.1"; >>>> declare namespace array ="http://www.w3.org/2005/xpath-functions/array"; >>>> >>>> let $array := [] >>>> >>>> return ( >>>> empty($array!?*), (: returns false :) >>>> empty( >>>> for $i in 1 to array:size($array) >>>> return $array($i) >>>> ) (: returns true :) >>>> ) >>>> >>>> I'm curious that the first expression returns false even though it >>>> should be equivalent to the second expression, if I read the XQuery >>>> spec [1] right: >>>> >>>> If the context item is an array: >>>> If theKeySpecifier >>>> <https://www.w3.org/TR/2017/REC-xquery-31-20170321/#doc-xquery31-KeySpecifier>is >>>> a wildcard ("|*|"), theUnaryLookup >>>> <https://www.w3.org/TR/2017/REC-xquery-31-20170321/#doc-xquery31-UnaryLookup>operator >>>> is equivalent to the following expression: >>>> for $k in 1 to array:size(.) >>>> return .($k) >>>> >>>> But maybe I'm missing something. I'd be glad if you could help. >>>> >>>> Best regards, >>>> Sebastian Zimmer >>>> >>>> [1] https://www.w3.org/TR/2017/REC-xquery-31-20170321/#id-unary-lookup >>>> >>>> -- >>>> Sebastian Zimmer >>>> sebastian.zimmer at uni-koeln.de <mailto:sebastian.zimmer at uni-koeln.de> >>>> <cceh-logo-cyan.png> <http://cceh.uni-koeln.de/> >>>> >>>> Cologne Center for eHumanities <http://cceh.uni-koeln.de/> >>>> DH Center at the University of Cologne >>>> <twitter_logo.png> <https://twitter.com/CCeHum>@CCeHum >>>> <https://twitter.com/CCeHum> >>>> >>> >> >> -- >> Sebastian Zimmer >> sebastian.zimmer at uni-koeln.de <mailto:sebastian.zimmer at uni-koeln.de> >> CCeH Logo <http://cceh.uni-koeln.de> >> >> Cologne Center for eHumanities <http://cceh.uni-koeln.de> >> DH Center at the University of Cologne >> Twitter Logo <https://twitter.com/CCeHum>@CCeHum >> <https://twitter.com/CCeHum> >> > > -- > Sebastian Zimmer > sebastian.zimmer at uni-koeln.de <mailto:sebastian.zimmer at uni-koeln.de> > CCeH Logo <http://cceh.uni-koeln.de> > > Cologne Center for eHumanities <http://cceh.uni-koeln.de> > DH Center at the University of Cologne > Twitter Logo <https://twitter.com/CCeHum>@CCeHum > <https://twitter.com/CCeHum> >
--
Sebastian Zimmer
sebastian.zimmer at uni-koeln.de <mailto:sebastian.zimmer at uni-koeln.de> CCeH Logo <http://cceh.uni-koeln.de>
Cologne Center for eHumanities <http://cceh.uni-koeln.de>
DH Center at the University of Cologne
Twitter Logo <https://twitter.com/CCeHum>@CCeHum
<https://twitter.com/CCeHum>
GC
Giuseppe Celano11 May 2018 13:29 #
The error is in Basex 9.0.1 but not in 8.6.7. It seems to be caused by the presence of the function within the lambda function.
Universität Leipzig
Institute of Computer Science, NLP
Augustusplatz 10
04109 Leipzig
Deutschland
E-mail: celano at informatik.uni-leipzig.de
E-mail: giuseppegacelano at gmail.com
Web site 1: http://www.dh.uni-leipzig.de/wo/team/
Web site 2: https://sites.google.com/site/giuseppegacelano/
Quoted text · Sebastian Zimmer · 147 lines
> On May 11, 2018, at 12:52 PM, Sebastian Zimmer <sebastian.zimmer at uni-koeln.de> wrote: > > Sorry to bother you again, but I think there is still something wrong with my code and I can't figure it out. This time I checked it consistently on BaseX 9.0.1 (Windows and Linux, console and web server), results are always the same: > > xquery version "3.1"; > declare namespace array = "http://www.w3.org/2005/xpath-functions/array" <http://www.w3.org/2005/xpath-functions/array>; > > let $array1 := [] > let $array2 := array:for-each([], function($i) { lower-case($i) }) > let $array3 := array:for-each([], function($i) { $i + 1 }) > > return ( > empty($array1!?*), > empty($array2!?*), > empty($array3!?*), > empty( > for $i in 1 to array:size($array1) > return $array1($i) > ), > empty( > for $i in 1 to array:size($array2) > return $array2($i) > ), > empty( > for $i in 1 to array:size($array3) > return $array3($i) > ) > ) > The results I get are: > true > false > true > true > true > true > > Why isn't the second result "true" too? > > Best regards, > Sebastian > > Am 11.05.2018 um 11:12 schrieb Sebastian Zimmer: >> Hi again, >> >> the problem is gone now after a reboot. It seems that the web server was running on another version while the console was running with 9.0.1 >> >> Sorry for the inconvenience. >> >> Best, >> Sebastian >> >> Am 11.05.2018 um 11:04 schrieb Sebastian Zimmer: >>> Hi Giuseppe, >>> >>> thanks for checking. I double-checked again. The problem is even weirder now: >>> >>> When using the console, I too get 2x true: >>> >>> $ ./bin/basex "./webapp/array_test.xql" >>> true >>> true >>> >>> When using the web server, I still get this: >>> >>> $ curl localhost:8994/rest?run=array_test.xql >>> false >>> true >>> At first I thought there was some cache at work, preventing the update, but it doesn't seem to be the case. I can edit the XQL und both outputs change accordingly, but the first boolean is still different. >>> >>> Best regards, >>> Sebastian >>> >>> Am 11.05.2018 um 08:28 schrieb Giuseppe Celano: >>>> Hi Sebastian, >>>> >>>> In my Basex 9.0.1 and 8.6.7 you get two "true". >>>> >>>> Best, >>>> Giuseppe >>>> >>>> Universität Leipzig >>>> Institute of Computer Science, NLP >>>> Augustusplatz 10 >>>> 04109 Leipzig >>>> Deutschland >>>> E-mail: celano at informatik.uni-leipzig.de <mailto:celano at informatik.uni-leipzig.de> >>>> E-mail: giuseppegacelano at gmail.com <mailto:giuseppegacelano at gmail.com> >>>> Web site 1: http://www.dh.uni-leipzig.de/wo/team/ <http://www.dh.uni-leipzig.de/wo/team/> >>>> Web site 2: https://sites.google.com/site/giuseppegacelano/ <https://sites.google.com/site/giuseppegacelano/> >>>> >>>>> On May 11, 2018, at 1:50 AM, Sebastian Zimmer <sebastian.zimmer at uni-koeln.de <mailto:sebastian.zimmer at uni-koeln.de>> wrote: >>>>> >>>>> Hi, >>>>> >>>>> I have this script where I use the lookup operator to perform a unary lookup: >>>>> >>>>> xquery version "3.1"; >>>>> declare namespace array = "http://www.w3.org/2005/xpath-functions/array" <http://www.w3.org/2005/xpath-functions/array>; >>>>> >>>>> let $array := [] >>>>> >>>>> return ( >>>>> empty($array!?*), (: returns false :) >>>>> empty( >>>>> for $i in 1 to array:size($array) >>>>> return $array($i) >>>>> ) (: returns true :) >>>>> ) >>>>> I'm curious that the first expression returns false even though it should be equivalent to the second expression, if I read the XQuery spec [1] right: >>>>> >>>>> If the context item is an array: >>>>> If the KeySpecifier <https://www.w3.org/TR/2017/REC-xquery-31-20170321/#doc-xquery31-KeySpecifier> is a wildcard ("*"), the UnaryLookup <https://www.w3.org/TR/2017/REC-xquery-31-20170321/#doc-xquery31-UnaryLookup> operator is equivalent to the following expression: >>>>> for $k in 1 to array:size(.) >>>>> return .($k) >>>>> But maybe I'm missing something. I'd be glad if you could help. >>>>> Best regards, >>>>> Sebastian Zimmer >>>>> [1] https://www.w3.org/TR/2017/REC-xquery-31-20170321/#id-unary-lookup <https://www.w3.org/TR/2017/REC-xquery-31-20170321/#id-unary-lookup> >>>>> -- >>>>> Sebastian Zimmer >>>>> sebastian.zimmer at uni-koeln.de <mailto:sebastian.zimmer at uni-koeln.de> >>>>> <cceh-logo-cyan.png> <http://cceh.uni-koeln.de/> >>>>> Cologne Center for eHumanities <http://cceh.uni-koeln.de/> >>>>> DH Center at the University of Cologne >>>>> <twitter_logo.png> <https://twitter.com/CCeHum>@CCeHum <https://twitter.com/CCeHum> >>> >>> -- >>> Sebastian Zimmer >>> sebastian.zimmer at uni-koeln.de <mailto:sebastian.zimmer at uni-koeln.de> >>> <cceh-logo-cyan.png> <http://cceh.uni-koeln.de/> >>> Cologne Center for eHumanities <http://cceh.uni-koeln.de/> >>> DH Center at the University of Cologne >>> <twitter_logo.png> <https://twitter.com/CCeHum>@CCeHum <https://twitter.com/CCeHum> >> -- >> Sebastian Zimmer >> sebastian.zimmer at uni-koeln.de <mailto:sebastian.zimmer at uni-koeln.de> >> <cceh-logo-cyan.png> <http://cceh.uni-koeln.de/> >> Cologne Center for eHumanities <http://cceh.uni-koeln.de/> >> DH Center at the University of Cologne >> <twitter_logo.png> <https://twitter.com/CCeHum>@CCeHum <https://twitter.com/CCeHum> > -- > Sebastian Zimmer > sebastian.zimmer at uni-koeln.de <mailto:sebastian.zimmer at uni-koeln.de> > <cceh-logo-cyan.png> <http://cceh.uni-koeln.de/> > Cologne Center for eHumanities <http://cceh.uni-koeln.de/> > DH Center at the University of Cologne > <twitter_logo.png> <https://twitter.com/CCeHum>@CCeHum <https://twitter.com/CCeHum>
CG
Hi Sebastian,
Thanks for your bug report. I found the culprit, it was a little static typing error in our lookup expression optimizations [1].
A new snapshot is available [2]; BaseX 9.0.2 will probably be released around end of May.
Cheers,
Christian
[1] https://github.com/BaseXdb/basex/commit/75947cfee98d513ddb1620f84a092d c883ebcc19
[2] http://files.basex.org/releases/latest/
Quoted text · Sebastian Zimmer · 186 lines
On Fri, May 11, 2018 at 12:52 PM, Sebastian Zimmer < sebastian.zimmer at uni-koeln.de> wrote: > Sorry to bother you again, but I think there is still something wrong with > my code and I can't figure it out. This time I checked it consistently on > BaseX 9.0.1 (Windows and Linux, console and web server), results are always > the same: > > xquery version "3.1"; > declare namespace array = "http://www.w3.org/2005/xpath-functions/array" <http://www.w3.org/2005/xpath-functions/array>; > > let $array1 := [] > let $array2 := array:for-each([], function($i) { lower-case($i) }) > let $array3 := array:for-each([], function($i) { $i + 1 }) > > return ( > empty($array1!?*), > empty($array2!?*), > empty($array3!?*), > empty( > for $i in 1 to array:size($array1) > return $array1($i) > ), > empty( > for $i in 1 to array:size($array2) > return $array2($i) > ), > empty( > for $i in 1 to array:size($array3) > return $array3($i) > ) > ) > > The results I get are: > true > false > true > true > true > true > > Why isn't the second result "true" too? > > Best regards, > Sebastian > > Am 11.05.2018 um 11:12 schrieb Sebastian Zimmer: > > Hi again, > > the problem is gone now after a reboot. It seems that the web server was > running on another version while the console was running with 9.0.1 > > Sorry for the inconvenience. > > Best, > Sebastian > Am 11.05.2018 um 11:04 schrieb Sebastian Zimmer: > > Hi Giuseppe, > > thanks for checking. I double-checked again. The problem is even weirder > now: > > When using the console, I too get 2x true: > > $ ./bin/basex "./webapp/array_test.xql" > true > true > > When using the web server, I still get this: > > $ curl localhost:8994/rest?run=array_test.xql > false > true > > At first I thought there was some cache at work, preventing the update, > but it doesn't seem to be the case. I can edit the XQL und both outputs > change accordingly, but the first boolean is still different. > > Best regards, > Sebastian > > Am 11.05.2018 um 08:28 schrieb Giuseppe Celano: > > Hi Sebastian, > > In my Basex 9.0.1 and 8.6.7 you get two "true". > > Best, > Giuseppe > > Universität Leipzig > Institute of Computer Science, NLP > Augustusplatz 10 > <https://maps.google.com/?q=Augustusplatz+10+%0D%0A++++++++++++++++04109+Leipzig+%0D%0A++++++++++++++++Deutschland&entry=gmail&source=g> > 04109 Leipzig > Deutschland > E-mail: celano at informatik.uni-leipzig.de > <celano at informatik.uni-leipzig.de> > E-mail: giuseppegacelano at gmail.com > Web site 1: http://www.dh.uni-leipzig.de/wo/team/ > Web site 2: https://sites.google.com/site/giuseppegacelano/ > > On May 11, 2018, at 1:50 AM, Sebastian Zimmer < > sebastian.zimmer at uni-koeln.de> wrote: > > Hi, > > I have this script where I use the lookup operator to perform a unary > lookup: > > xquery version "3.1"; > declare namespace array = "http://www.w3.org/2005/xpath-functions/array" <http://www.w3.org/2005/xpath-functions/array>; > > let $array := [] > > return ( > empty($array!?*), (: returns false :) > empty( > for $i in 1 to array:size($array) > return $array($i) > ) (: returns true :) > ) > > I'm curious that the first expression returns false even though it should > be equivalent to the second expression, if I read the XQuery spec [1] right: > If the context item is an array: > If the KeySpecifier > <https://www.w3.org/TR/2017/REC-xquery-31-20170321/#doc-xquery31-KeySpecifier> > is a wildcard ("*"), the UnaryLookup > <https://www.w3.org/TR/2017/REC-xquery-31-20170321/#doc-xquery31-UnaryLookup> > operator is equivalent to the following expression: > > for $k in 1 to array:size(.) > return .($k) > > But maybe I'm missing something. I'd be glad if you could help. > > Best regards, > Sebastian Zimmer > > [1] https://www.w3.org/TR/2017/REC-xquery-31-20170321/#id-unary-lookup > -- > Sebastian Zimmer > sebastian.zimmer at uni-koeln.de > <cceh-logo-cyan.png> <http://cceh.uni-koeln.de/> > > Cologne Center for eHumanities <http://cceh.uni-koeln.de/> > DH Center at the University of Cologne > <twitter_logo.png> <https://twitter.com/CCeHum>@CCeHum > <https://twitter.com/CCeHum> > > > > -- > Sebastian Zimmer > sebastian.zimmer at uni-koeln.de > [image: CCeH Logo] <http://cceh.uni-koeln.de> > > Cologne Center for eHumanities <http://cceh.uni-koeln.de> > DH Center at the University of Cologne > [image: Twitter Logo] <https://twitter.com/CCeHum>@CCeHum > <https://twitter.com/CCeHum> > > > -- > Sebastian Zimmer > sebastian.zimmer at uni-koeln.de > [image: CCeH Logo] <http://cceh.uni-koeln.de> > > Cologne Center for eHumanities <http://cceh.uni-koeln.de> > DH Center at the University of Cologne > [image: Twitter Logo] <https://twitter.com/CCeHum>@CCeHum > <https://twitter.com/CCeHum> > > > -- > Sebastian Zimmer > sebastian.zimmer at uni-koeln.de > [image: CCeH Logo] <http://cceh.uni-koeln.de> > > Cologne Center for eHumanities <http://cceh.uni-koeln.de> > DH Center at the University of Cologne > [image: Twitter Logo] <https://twitter.com/CCeHum>@CCeHum > <https://twitter.com/CCeHum> >
Written for BaseX 9.0. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery