Re: [basex-talk] Query optimizer bug with nested for? - java.lang.NullPointerException at Path.index(Path.java:673)

2020-05-11 Thread Sebastian Guerrero
Hi Christian!
Wow, you are like a Terminator of coding! XD

Is *BaseX933-20200511.231351.exe *( snapshot of 23:14 ) the latest version?

I'm asking because I downloaded it and the error is still there, but now on
line 671 instead of the original line 673.

*Unexpected error: Improper use? Potential bug? Your feedback is welcome:*
*Contact: basex-talk@mailman.uni-konstanz.de
*
*Version: BaseX 9.3.3 beta*
*Java: Oracle Corporation, 1.8.0_251*
*OS: Windows 10, amd64*
*Stack Trace: *
*java.lang.NullPointerException*
* at org.basex.query.expr.path.Path.index(Path.java:671)*
* at org.basex.query.expr.path.Path.optimize(Path.java:157)*
* at org.basex.query.expr.gflwor.For.addPredicate(For.java:190)*
* at org.basex.query.expr.gflwor.For.toPredicate(For.java:218)*
* at org.basex.query.expr.gflwor.GFLWOR.optimizeWhere(GFLWOR.java:532)*
* at org.basex.query.expr.gflwor.GFLWOR.optimize(GFLWOR.java:109)*
* at org.basex.query.expr.gflwor.GFLWOR.compile(GFLWOR.java:100)*
* at org.basex.query.expr.Extension.compile(Extension.java:45)*


Cheers,
Sebastian.


On Mon, May 11, 2020 at 6:15 PM Christian Grün 
wrote:

> Buenas noticias: The bug is fixed. A new snapshot is waiting for you [1].
>
> Cheers,
> Christian
>
> [1] http://files.basex.org/releases/latest/
>
>
>
> On Mon, May 11, 2020 at 9:47 PM Sebastian Guerrero 
> wrote:
> >
> > Hi Christian!, thanks for your reply :-)
> >
> > I've just downloaded the latest snapshot [1] and executed the query [2],
> and yes: the problem is still there.
> >
> > Cheers,
> > Sebastian.
> >
> > [1] https://imgur.com/ahgMg7p
> > [2] https://imgur.com/tDCAtCu
> >
> > On Mon, May 11, 2020 at 3:58 PM Christian Grün <
> christian.gr...@gmail.com> wrote:
> >>>
> >>> Maybe it's a newbie issue, but I would like your comments.
> >>
> >>
> >> …definitely something you shouldn't encounter as a newbie either ;)
> Thanks for reporting it.
> >>
> >> Does the exception also occur with the latest snapshot [1]?
> >>
> >> Cheers
> >> Christian
> >>
> >> [1] http://files.basex.org/releases/latest/
> >>
> >>
> >>
> >>
> >>>
> >>> I'm writing a RESTXQ method to search among a couple of databases. (
> >100 databases )
> >>>
> >>> Some databases are split into a couple of parts due to the number of
> nodes. For example US: it's separated into US00, US01 and US02.
> >>>
> >>> So, my problem is:
> >>>
> >>> if I replace "for $usPart in ('US00')" by "for $usPart in
> ('US00','US01',''US02)" in QUERY [A], I get this error:
> >>>
> >>> Improper use? Potential bug? Your feedback is welcome:
> >>> Contact: basex-talk@mailman.uni-konstanz.de
> >>> Version: BaseX 9.3.2
> >>> Java: Oracle Corporation, 1.8.0_251
> >>> OS: Windows 10, amd64
> >>> Stack Trace:
> >>> java.lang.NullPointerException
> >>> at org.basex.query.expr.path.Path.index(Path.java:673)
> >>> at org.basex.query.expr.path.Path.optimize(Path.java:157)
> >>> at org.basex.query.expr.gflwor.For.toPredicate(For.java:220)
> >>> at org.basex.query.expr.gflwor.GFLWOR.optimizeWhere(GFLWOR.java:532)
> >>> at org.basex.query.expr.gflwor.GFLWOR.optimize(GFLWOR.java:109)
> >>> at org.basex.query.expr.gflwor.GFLWOR.compile(GFLWOR.java:100)
> >>> at org.basex.query.expr.Extension.compile(Extension.java:45)
> >>> at org.basex.query.expr.SwitchGroup.compile(SwitchGroup.java:40)
> >>> at org.basex.query.expr.Switch.compile(Switch.java:60)
> >>> at org.basex.query.expr.gflwor.GFLWOR.compile(GFLWOR.java:96)
> >>> at org.basex.query.expr.gflwor.ForLet.compile(ForLet.java:43)
> >>> at org.basex.query.expr.gflwor.GFLWOR.compile(GFLWOR.java:90)
> >>> at org.basex.query.scope.MainModule.comp(MainModule.java:81)
> >>> at org.basex.query.QueryCompiler.compile(QueryCompiler.java:114)
> >>> at org.basex.query.QueryCompiler.compile(QueryCompiler.java:105)
> >>> at org.basex.query.QueryContext.compile(QueryContext.java:312)
> >>> at org.basex.query.QueryProcessor.compile(QueryProcessor.java:79)
> >>>
> >>>
> >>> Using "for $usPart in ('US00')" it works without any problem. With one
> element there is no problem, with two or more it fails.
> >>>
> >>> Any ideas about what I'm doing wrong?
> >>>
> >>> Here is the
> >>> QUERY [A]
> >>>
> -
> >>> declare namespace gb="http://www.ipo.gov.uk/schemas/tm;;
> >>>
> >>> let $text:="christian"
> >>> let $registries:=('GB','US')
> >>>
> >>> let $results :=
> >>>   for $registry in $registries
> >>>return
> >>>switch ($registry)
> >>>
> >>>case "US"
> >>>return
> >>>(# db:enforceindex #) {
> >>>   for $usPart in ('US00')
> >>>   for $tmUS in
> db:open($usPart)/trademark-applications-daily/application-information/file-segments/action-keys/case-file
> >>>   where
> $tmUS/case-file-header/mark-identification/text() contains text {$text}
> using stemming
> >>>   

Re: [basex-talk] GUI "create db" file patterns are not sticky

2020-05-11 Thread Christian Grün
> ADDARCHIVES works, CHOP works, INTPARSE works, but CREATEFILTER does not, or 
> at least I still get only "*.xml" as a suffix in the "File Patterns" box.

I found out why this doesn’t work: In the database creation dialog,
CREATEFILTER depends on the input format (XML, JSON, etc.). It is
always overwritten when the dialog is opened and when this value is
changed. Well… I’ll think about that.


Re: [basex-talk] Stack overflow with random-number-generator

2020-05-11 Thread Joe Wicentowski
I found a version that works.  In the original version I must not have
been using tail recursion correctly.  Here is the version that works.  Can
anyone explain why the first version doesn't properly trigger tail
recursion?

```
xquery version "3.1";

declare function local:get-random-numbers($how-many as xs:integer,
$generator as map(*), $accumulator) {
if ($how-many ge 1) then
local:get-random-numbers($how-many - 1, $generator?next(),
($accumulator, $generator?number))
else
$accumulator
};

declare function local:get-random-numbers($how-many as xs:integer) {
local:get-random-numbers($how-many, random-number-generator(), ())
};

let $n := 2000
return
local:get-random-numbers($n) => count()
```

On Mon, May 11, 2020 at 5:20 PM Joe Wicentowski  wrote:

> Hi all,
>
> I encountered a stack overflow error with the following code, which is
> designed to return as many random numbers as the user requests.  BaseX's
> error suggested, "Try tail recursion?"  I think I am already using tail
> recursion.  Changing the $n variable from 1407 to 1406 or lower avoids the
> error.  Any number 1407 or higher triggers the error.
>
> Thank you for any hints!
> Joe
>
> ```
> xquery version "3.1";
>
> declare function local:get-random-numbers($how-many as xs:integer,
> $generator as map(*)) {
> if ($how-many ge 1) then
> (
> $generator?number,
> local:get-random-numbers($how-many - 1, $generator?next())
> )
> else
> ()
> };
>
> declare function local:get-random-numbers($how-many as xs:integer) {
> local:get-random-numbers($how-many, random-number-generator())
> };
>
> let $n := 1407
> return
> local:get-random-numbers($n) => count()
> ```
>


Re: [basex-talk] Query optimizer bug with nested for? - java.lang.NullPointerException at Path.index(Path.java:673)

2020-05-11 Thread Christian Grün
I’ll have a look at this tomorrow!


Sebastian Guerrero  schrieb am Mo., 11. Mai 2020, 21:47:

> Hi Christian!, thanks for your reply :-)
>
> I've just downloaded the latest snapshot [1] and executed the query [2],
> and yes: the problem is still there.
>
> Cheers,
> Sebastian.
>
> [1] https://imgur.com/ahgMg7p
> [2] https://imgur.com/tDCAtCu
>
> On Mon, May 11, 2020 at 3:58 PM Christian Grün 
> wrote:
>
>> Maybe it's a newbie issue, but I would like your comments.
>>>
>>
>> …definitely something you shouldn't encounter as a newbie either ;)
>> Thanks for reporting it.
>>
>> Does the exception also occur with the latest snapshot [1]?
>>
>> Cheers
>> Christian
>>
>> [1] http://files.basex.org/releases/latest/
>>
>>
>>
>>
>>
>>> I'm writing a RESTXQ method to search among a couple of databases. (
>>> >100 databases )
>>>
>>> Some databases are split into a couple of parts due to the number of
>>> nodes. For example US: it's separated into US00, US01 and US02.
>>>
>>> So, my problem is:
>>>
>>> if I replace "*for $usPart in ('US00')*" by "*for $usPart in
>>> ('US00','US01',''US02)*" in *QUERY [A]*, I get this error:
>>>
>>> *Improper use? Potential bug? Your feedback is welcome:*
>>> *Contact: basex-talk@mailman.uni-konstanz.de
>>> *
>>> *Version: BaseX 9.3.2*
>>> *Java: Oracle Corporation, 1.8.0_251*
>>> *OS: Windows 10, amd64*
>>> *Stack Trace: *
>>> *java.lang.NullPointerException*
>>> * at org.basex.query.expr.path.Path.index(Path.java:673)*
>>> * at org.basex.query.expr.path.Path.optimize(Path.java:157)*
>>> * at org.basex.query.expr.gflwor.For.toPredicate(For.java:220)*
>>> * at org.basex.query.expr.gflwor.GFLWOR.optimizeWhere(GFLWOR.java:532)*
>>> * at org.basex.query.expr.gflwor.GFLWOR.optimize(GFLWOR.java:109)*
>>> * at org.basex.query.expr.gflwor.GFLWOR.compile(GFLWOR.java:100)*
>>> * at org.basex.query.expr.Extension.compile(Extension.java:45)*
>>> * at org.basex.query.expr.SwitchGroup.compile(SwitchGroup.java:40)*
>>> * at org.basex.query.expr.Switch.compile(Switch.java:60)*
>>> * at org.basex.query.expr.gflwor.GFLWOR.compile(GFLWOR.java:96)*
>>> * at org.basex.query.expr.gflwor.ForLet.compile(ForLet.java:43)*
>>> * at org.basex.query.expr.gflwor.GFLWOR.compile(GFLWOR.java:90)*
>>> * at org.basex.query.scope.MainModule.comp(MainModule.java:81)*
>>> * at org.basex.query.QueryCompiler.compile(QueryCompiler.java:114)*
>>> * at org.basex.query.QueryCompiler.compile(QueryCompiler.java:105)*
>>> * at org.basex.query.QueryContext.compile(QueryContext.java:312)*
>>> * at org.basex.query.QueryProcessor.compile(QueryProcessor.java:79)*
>>>
>>>
>>> Using "*for $usPart in ('US00')*" it works without any problem. With
>>> one element there is no problem, with two or more it fails.
>>>
>>> Any ideas about what I'm doing wrong?
>>>
>>> Here is the
>>> *QUERY [A]*
>>>
>>> -
>>> declare namespace gb="http://www.ipo.gov.uk/schemas/tm;;
>>>
>>> let $text:="christian"
>>> let $registries:=('GB','US')
>>>
>>> let $results :=
>>>   for $registry in $registries
>>>return
>>>switch ($registry)
>>>
>>>case "US"
>>>return
>>>(# db:enforceindex #) {
>>>   for $usPart in ('US00')
>>>   for $tmUS in
>>> db:open($usPart)/trademark-applications-daily/application-information/file-segments/action-keys/case-file
>>>   where
>>> $tmUS/case-file-header/mark-identification/text() contains text {$text}
>>> using stemming
>>>   return
>>> US{$tmUS/case-file-header/mark-identification/text()}
>>> }
>>>
>>>case "GB"
>>>return
>>>(# db:enforceindex #) {
>>>for $tmGB in
>>> db:open('GB')/gb:MarkLicenceeExportList/gb:TradeMark
>>>   where
>>> $tmGB/gb:WordMarkSpecification/gb:MarkVerbalElementText/text() contains
>>> text {$text}
>>> return
>>> GB{$tmGB/gb:WordMarkSpecification/gb:MarkVerbalElementText/text()}
>>>
>>> }
>>>
>>> default return ""
>>>
>>> return
>>> 
>>> {count($results)}
>>> 
>>> {
>>> for $result in $results
>>> return $result
>>> }
>>> 
>>> 
>>>
>>> -
>>>
>>> Regards,
>>> Sebastian
>>>
>>


Re: [basex-talk] repeatedly full-text marking the same text node

2020-05-11 Thread Christian Grün
> The thing that I would most want to see is some way to capture multi-word 
> matches using full-text search; "full phrase search", in effect. I can see 
> that as the start and end of a range of internal result positions but will 
> admit to wanting something less at risk of my arithmetic errors.

Providing access to the starts and ends may be difficult due to all
the logical operators that can be used (ftor, ftand, ftnot, not in). A
simple example:

  let $xml := <_>a b c d update {}
  return ft:mark($xml[text() contains text 'b c' ftand 'c d'])

We could possibly make the full data structures available that need to
be internally generated. I fear people wouldn’t really work with it as
they are fairly complex (a look into the specification may give you an
impression of that [1]).

But thanks for your thoughts, I’ll let them grow.

[1] https://www.w3.org/TR/xpath-full-text-10/#FTOperatorsSemanticsSec


Re: [basex-talk] repeatedly full-text marking the same text node

2020-05-11 Thread Liam R. E. Quin
On Mon, 2020-05-11 at 22:29 +0200, Christian Grün wrote:

> Providing access to the starts and ends may be difficult due to all
> the logical operators that can be used 

A way to go from ($input, $phrases) to a $input autmented with
db:milestone elements each containing starts="0 7 23" ends="2 6 18"
attributes (where the numbers are positional in the sequene of phrases)
might be good. Or the mileston element could iclude the phrase,

I saw his 
   naked hooves
   unshod
bare
   feet

as two problems are (1) overlapping results, and (2) query expansion
using a thesaurus and/or stemming.

Liam

> (ftor, ftand, ftnot, not in). A
> simple example:
> 
>   let $xml := <_>a b c d update {}
>   return ft:mark($xml[text() contains text 'b c' ftand 'c d'])
> 
> We could possibly make the full data structures available that need
> to
> be internally generated. I fear people wouldn’t really work with it
> as
> they are fairly complex (a look into the specification may give you
> an
> impression of that [1]).
> 
> But thanks for your thoughts, I’ll let them grow.
> 
> [1] https://www.w3.org/TR/xpath-full-text-10/#FTOperatorsSemanticsSec
-- 
Liam Quin, https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations:  http://www.fromoldbooks.org



Re: [basex-talk] Query optimizer bug with nested for? - java.lang.NullPointerException at Path.index(Path.java:673)

2020-05-11 Thread Sebastian Guerrero
Yes!, you were right!

I've bought a new 2TB M.2 disk to play with BaseX and I've got confused:
instead of install in *A:* I installed the new snapshot on the old *C:*

Now it works like a charm !! [1]

Thank you very very much, Christian, by your time.

Best regards!
Sebastian.

[1] https://imgur.com/DQi5aNP

On Mon, May 11, 2020 at 6:48 PM Christian Grün 
wrote:

> > I'm asking because I downloaded it and the error is still there, but now
> on line 671 instead of the original line 673.
>
> Hm, maybe it was the previous 9.3.3 snapshot you launched?
>
> Feel free to provide me with a minimized query that allows me to
> reproduce the bug if it persists. On GitHub, I have referenced a query
> that I used for testing [1].
>
> Best,
> Christian
>
> [1] https://github.com/BaseXdb/basex/issues/1860
>
>
>
>
> > Unexpected error: Improper use? Potential bug? Your feedback is welcome:
> > Contact: basex-talk@mailman.uni-konstanz.de
> > Version: BaseX 9.3.3 beta
> > Java: Oracle Corporation, 1.8.0_251
> > OS: Windows 10, amd64
> > Stack Trace:
> > java.lang.NullPointerException
> > at org.basex.query.expr.path.Path.index(Path.java:671)
> > at org.basex.query.expr.path.Path.optimize(Path.java:157)
> > at org.basex.query.expr.gflwor.For.addPredicate(For.java:190)
> > at org.basex.query.expr.gflwor.For.toPredicate(For.java:218)
> > at org.basex.query.expr.gflwor.GFLWOR.optimizeWhere(GFLWOR.java:532)
> > at org.basex.query.expr.gflwor.GFLWOR.optimize(GFLWOR.java:109)
> > at org.basex.query.expr.gflwor.GFLWOR.compile(GFLWOR.java:100)
> > at org.basex.query.expr.Extension.compile(Extension.java:45)
> >
> >
> > Cheers,
> > Sebastian.
> >
> >
> > On Mon, May 11, 2020 at 6:15 PM Christian Grün <
> christian.gr...@gmail.com> wrote:
> >>
> >> Buenas noticias: The bug is fixed. A new snapshot is waiting for you
> [1].
> >>
> >> Cheers,
> >> Christian
> >>
> >> [1] http://files.basex.org/releases/latest/
> >>
> >>
> >>
> >> On Mon, May 11, 2020 at 9:47 PM Sebastian Guerrero 
> wrote:
> >> >
> >> > Hi Christian!, thanks for your reply :-)
> >> >
> >> > I've just downloaded the latest snapshot [1] and executed the query
> [2], and yes: the problem is still there.
> >> >
> >> > Cheers,
> >> > Sebastian.
> >> >
> >> > [1] https://imgur.com/ahgMg7p
> >> > [2] https://imgur.com/tDCAtCu
> >> >
> >> > On Mon, May 11, 2020 at 3:58 PM Christian Grün <
> christian.gr...@gmail.com> wrote:
> >> >>>
> >> >>> Maybe it's a newbie issue, but I would like your comments.
> >> >>
> >> >>
> >> >> …definitely something you shouldn't encounter as a newbie either ;)
> Thanks for reporting it.
> >> >>
> >> >> Does the exception also occur with the latest snapshot [1]?
> >> >>
> >> >> Cheers
> >> >> Christian
> >> >>
> >> >> [1] http://files.basex.org/releases/latest/
> >> >>
> >> >>
> >> >>
> >> >>
> >> >>>
> >> >>> I'm writing a RESTXQ method to search among a couple of databases.
> ( >100 databases )
> >> >>>
> >> >>> Some databases are split into a couple of parts due to the number
> of nodes. For example US: it's separated into US00, US01 and US02.
> >> >>>
> >> >>> So, my problem is:
> >> >>>
> >> >>> if I replace "for $usPart in ('US00')" by "for $usPart in
> ('US00','US01',''US02)" in QUERY [A], I get this error:
> >> >>>
> >> >>> Improper use? Potential bug? Your feedback is welcome:
> >> >>> Contact: basex-talk@mailman.uni-konstanz.de
> >> >>> Version: BaseX 9.3.2
> >> >>> Java: Oracle Corporation, 1.8.0_251
> >> >>> OS: Windows 10, amd64
> >> >>> Stack Trace:
> >> >>> java.lang.NullPointerException
> >> >>> at org.basex.query.expr.path.Path.index(Path.java:673)
> >> >>> at org.basex.query.expr.path.Path.optimize(Path.java:157)
> >> >>> at org.basex.query.expr.gflwor.For.toPredicate(For.java:220)
> >> >>> at org.basex.query.expr.gflwor.GFLWOR.optimizeWhere(GFLWOR.java:532)
> >> >>> at org.basex.query.expr.gflwor.GFLWOR.optimize(GFLWOR.java:109)
> >> >>> at org.basex.query.expr.gflwor.GFLWOR.compile(GFLWOR.java:100)
> >> >>> at org.basex.query.expr.Extension.compile(Extension.java:45)
> >> >>> at org.basex.query.expr.SwitchGroup.compile(SwitchGroup.java:40)
> >> >>> at org.basex.query.expr.Switch.compile(Switch.java:60)
> >> >>> at org.basex.query.expr.gflwor.GFLWOR.compile(GFLWOR.java:96)
> >> >>> at org.basex.query.expr.gflwor.ForLet.compile(ForLet.java:43)
> >> >>> at org.basex.query.expr.gflwor.GFLWOR.compile(GFLWOR.java:90)
> >> >>> at org.basex.query.scope.MainModule.comp(MainModule.java:81)
> >> >>> at org.basex.query.QueryCompiler.compile(QueryCompiler.java:114)
> >> >>> at org.basex.query.QueryCompiler.compile(QueryCompiler.java:105)
> >> >>> at org.basex.query.QueryContext.compile(QueryContext.java:312)
> >> >>> at org.basex.query.QueryProcessor.compile(QueryProcessor.java:79)
> >> >>>
> >> >>>
> >> >>> Using "for $usPart in ('US00')" it works without any problem. With
> one element there is no problem, with two or more it fails.
> >> >>>
> >> >>> Any ideas about what I'm doing wrong?
> >> >>>
> >> >>> Here is the
> >> >>> QUERY [A]
> 

Re: [basex-talk] Query optimizer bug with nested for? - java.lang.NullPointerException at Path.index(Path.java:673)

2020-05-11 Thread Sebastian Guerrero
Hi Christian!, thanks for your reply :-)

I've just downloaded the latest snapshot [1] and executed the query [2],
and yes: the problem is still there.

Cheers,
Sebastian.

[1] https://imgur.com/ahgMg7p
[2] https://imgur.com/tDCAtCu

On Mon, May 11, 2020 at 3:58 PM Christian Grün 
wrote:

> Maybe it's a newbie issue, but I would like your comments.
>>
>
> …definitely something you shouldn't encounter as a newbie either ;) Thanks
> for reporting it.
>
> Does the exception also occur with the latest snapshot [1]?
>
> Cheers
> Christian
>
> [1] http://files.basex.org/releases/latest/
>
>
>
>
>
>> I'm writing a RESTXQ method to search among a couple of databases. ( >100
>> databases )
>>
>> Some databases are split into a couple of parts due to the number of
>> nodes. For example US: it's separated into US00, US01 and US02.
>>
>> So, my problem is:
>>
>> if I replace "*for $usPart in ('US00')*" by "*for $usPart in
>> ('US00','US01',''US02)*" in *QUERY [A]*, I get this error:
>>
>> *Improper use? Potential bug? Your feedback is welcome:*
>> *Contact: basex-talk@mailman.uni-konstanz.de
>> *
>> *Version: BaseX 9.3.2*
>> *Java: Oracle Corporation, 1.8.0_251*
>> *OS: Windows 10, amd64*
>> *Stack Trace: *
>> *java.lang.NullPointerException*
>> * at org.basex.query.expr.path.Path.index(Path.java:673)*
>> * at org.basex.query.expr.path.Path.optimize(Path.java:157)*
>> * at org.basex.query.expr.gflwor.For.toPredicate(For.java:220)*
>> * at org.basex.query.expr.gflwor.GFLWOR.optimizeWhere(GFLWOR.java:532)*
>> * at org.basex.query.expr.gflwor.GFLWOR.optimize(GFLWOR.java:109)*
>> * at org.basex.query.expr.gflwor.GFLWOR.compile(GFLWOR.java:100)*
>> * at org.basex.query.expr.Extension.compile(Extension.java:45)*
>> * at org.basex.query.expr.SwitchGroup.compile(SwitchGroup.java:40)*
>> * at org.basex.query.expr.Switch.compile(Switch.java:60)*
>> * at org.basex.query.expr.gflwor.GFLWOR.compile(GFLWOR.java:96)*
>> * at org.basex.query.expr.gflwor.ForLet.compile(ForLet.java:43)*
>> * at org.basex.query.expr.gflwor.GFLWOR.compile(GFLWOR.java:90)*
>> * at org.basex.query.scope.MainModule.comp(MainModule.java:81)*
>> * at org.basex.query.QueryCompiler.compile(QueryCompiler.java:114)*
>> * at org.basex.query.QueryCompiler.compile(QueryCompiler.java:105)*
>> * at org.basex.query.QueryContext.compile(QueryContext.java:312)*
>> * at org.basex.query.QueryProcessor.compile(QueryProcessor.java:79)*
>>
>>
>> Using "*for $usPart in ('US00')*" it works without any problem. With one
>> element there is no problem, with two or more it fails.
>>
>> Any ideas about what I'm doing wrong?
>>
>> Here is the
>> *QUERY [A]*
>>
>> -
>> declare namespace gb="http://www.ipo.gov.uk/schemas/tm;;
>>
>> let $text:="christian"
>> let $registries:=('GB','US')
>>
>> let $results :=
>>   for $registry in $registries
>>return
>>switch ($registry)
>>
>>case "US"
>>return
>>(# db:enforceindex #) {
>>   for $usPart in ('US00')
>>   for $tmUS in
>> db:open($usPart)/trademark-applications-daily/application-information/file-segments/action-keys/case-file
>>   where $tmUS/case-file-header/mark-identification/text()
>> contains text {$text} using stemming
>>   return
>> US{$tmUS/case-file-header/mark-identification/text()}
>> }
>>
>>case "GB"
>>return
>>(# db:enforceindex #) {
>>for $tmGB in
>> db:open('GB')/gb:MarkLicenceeExportList/gb:TradeMark
>>   where
>> $tmGB/gb:WordMarkSpecification/gb:MarkVerbalElementText/text() contains
>> text {$text}
>> return
>> GB{$tmGB/gb:WordMarkSpecification/gb:MarkVerbalElementText/text()}
>>
>> }
>>
>> default return ""
>>
>> return
>> 
>> {count($results)}
>> 
>> {
>> for $result in $results
>> return $result
>> }
>> 
>> 
>>
>> -
>>
>> Regards,
>> Sebastian
>>
>


Re: [basex-talk] Query optimizer bug with nested for? - java.lang.NullPointerException at Path.index(Path.java:673)

2020-05-11 Thread Christian Grün
Buenas noticias: The bug is fixed. A new snapshot is waiting for you [1].

Cheers,
Christian

[1] http://files.basex.org/releases/latest/



On Mon, May 11, 2020 at 9:47 PM Sebastian Guerrero  wrote:
>
> Hi Christian!, thanks for your reply :-)
>
> I've just downloaded the latest snapshot [1] and executed the query [2], and 
> yes: the problem is still there.
>
> Cheers,
> Sebastian.
>
> [1] https://imgur.com/ahgMg7p
> [2] https://imgur.com/tDCAtCu
>
> On Mon, May 11, 2020 at 3:58 PM Christian Grün  
> wrote:
>>>
>>> Maybe it's a newbie issue, but I would like your comments.
>>
>>
>> …definitely something you shouldn't encounter as a newbie either ;) Thanks 
>> for reporting it.
>>
>> Does the exception also occur with the latest snapshot [1]?
>>
>> Cheers
>> Christian
>>
>> [1] http://files.basex.org/releases/latest/
>>
>>
>>
>>
>>>
>>> I'm writing a RESTXQ method to search among a couple of databases. ( >100 
>>> databases )
>>>
>>> Some databases are split into a couple of parts due to the number of nodes. 
>>> For example US: it's separated into US00, US01 and US02.
>>>
>>> So, my problem is:
>>>
>>> if I replace "for $usPart in ('US00')" by "for $usPart in 
>>> ('US00','US01',''US02)" in QUERY [A], I get this error:
>>>
>>> Improper use? Potential bug? Your feedback is welcome:
>>> Contact: basex-talk@mailman.uni-konstanz.de
>>> Version: BaseX 9.3.2
>>> Java: Oracle Corporation, 1.8.0_251
>>> OS: Windows 10, amd64
>>> Stack Trace:
>>> java.lang.NullPointerException
>>> at org.basex.query.expr.path.Path.index(Path.java:673)
>>> at org.basex.query.expr.path.Path.optimize(Path.java:157)
>>> at org.basex.query.expr.gflwor.For.toPredicate(For.java:220)
>>> at org.basex.query.expr.gflwor.GFLWOR.optimizeWhere(GFLWOR.java:532)
>>> at org.basex.query.expr.gflwor.GFLWOR.optimize(GFLWOR.java:109)
>>> at org.basex.query.expr.gflwor.GFLWOR.compile(GFLWOR.java:100)
>>> at org.basex.query.expr.Extension.compile(Extension.java:45)
>>> at org.basex.query.expr.SwitchGroup.compile(SwitchGroup.java:40)
>>> at org.basex.query.expr.Switch.compile(Switch.java:60)
>>> at org.basex.query.expr.gflwor.GFLWOR.compile(GFLWOR.java:96)
>>> at org.basex.query.expr.gflwor.ForLet.compile(ForLet.java:43)
>>> at org.basex.query.expr.gflwor.GFLWOR.compile(GFLWOR.java:90)
>>> at org.basex.query.scope.MainModule.comp(MainModule.java:81)
>>> at org.basex.query.QueryCompiler.compile(QueryCompiler.java:114)
>>> at org.basex.query.QueryCompiler.compile(QueryCompiler.java:105)
>>> at org.basex.query.QueryContext.compile(QueryContext.java:312)
>>> at org.basex.query.QueryProcessor.compile(QueryProcessor.java:79)
>>>
>>>
>>> Using "for $usPart in ('US00')" it works without any problem. With one 
>>> element there is no problem, with two or more it fails.
>>>
>>> Any ideas about what I'm doing wrong?
>>>
>>> Here is the
>>> QUERY [A]
>>> -
>>> declare namespace gb="http://www.ipo.gov.uk/schemas/tm;;
>>>
>>> let $text:="christian"
>>> let $registries:=('GB','US')
>>>
>>> let $results :=
>>>   for $registry in $registries
>>>return
>>>switch ($registry)
>>>
>>>case "US"
>>>return
>>>(# db:enforceindex #) {
>>>   for $usPart in ('US00')
>>>   for $tmUS in 
>>> db:open($usPart)/trademark-applications-daily/application-information/file-segments/action-keys/case-file
>>>   where $tmUS/case-file-header/mark-identification/text() 
>>> contains text {$text} using stemming
>>>   return 
>>> US{$tmUS/case-file-header/mark-identification/text()}
>>> }
>>>
>>>case "GB"
>>>return
>>>(# db:enforceindex #) {
>>>for $tmGB in 
>>> db:open('GB')/gb:MarkLicenceeExportList/gb:TradeMark
>>>   where 
>>> $tmGB/gb:WordMarkSpecification/gb:MarkVerbalElementText/text() contains 
>>> text {$text}
>>> return 
>>> GB{$tmGB/gb:WordMarkSpecification/gb:MarkVerbalElementText/text()}
>>> }
>>>
>>> default return ""
>>>
>>> return
>>> 
>>> {count($results)}
>>> 
>>> {
>>> for $result in $results
>>> return $result
>>> }
>>> 
>>> 
>>>   
>>> -
>>>
>>> Regards,
>>> Sebastian


Re: [basex-talk] Stack overflow with random-number-generator

2020-05-11 Thread Martin Honnen

On 11.05.2020 23:33, Joe Wicentowski wrote:

I found a version that works.  In the original version I must not have
been using tail recursion correctly.  Here is the version that works.
Can anyone explain why the first version doesn't properly trigger tail
recursion?


No, but I think you can also apply fold-left

fold-left(
  1 to 2000,
  random-number-generator(),
  function($a, $i) { head($a)?next(), head($a)?number, tail($a) }
) => tail() => count()

instead of setting up your own tail recursive functions.




Re: [basex-talk] Query optimizer bug with nested for? - java.lang.NullPointerException at Path.index(Path.java:673)

2020-05-11 Thread Christian Grün
> I'm asking because I downloaded it and the error is still there, but now on 
> line 671 instead of the original line 673.

Hm, maybe it was the previous 9.3.3 snapshot you launched?

Feel free to provide me with a minimized query that allows me to
reproduce the bug if it persists. On GitHub, I have referenced a query
that I used for testing [1].

Best,
Christian

[1] https://github.com/BaseXdb/basex/issues/1860




> Unexpected error: Improper use? Potential bug? Your feedback is welcome:
> Contact: basex-talk@mailman.uni-konstanz.de
> Version: BaseX 9.3.3 beta
> Java: Oracle Corporation, 1.8.0_251
> OS: Windows 10, amd64
> Stack Trace:
> java.lang.NullPointerException
> at org.basex.query.expr.path.Path.index(Path.java:671)
> at org.basex.query.expr.path.Path.optimize(Path.java:157)
> at org.basex.query.expr.gflwor.For.addPredicate(For.java:190)
> at org.basex.query.expr.gflwor.For.toPredicate(For.java:218)
> at org.basex.query.expr.gflwor.GFLWOR.optimizeWhere(GFLWOR.java:532)
> at org.basex.query.expr.gflwor.GFLWOR.optimize(GFLWOR.java:109)
> at org.basex.query.expr.gflwor.GFLWOR.compile(GFLWOR.java:100)
> at org.basex.query.expr.Extension.compile(Extension.java:45)
>
>
> Cheers,
> Sebastian.
>
>
> On Mon, May 11, 2020 at 6:15 PM Christian Grün  
> wrote:
>>
>> Buenas noticias: The bug is fixed. A new snapshot is waiting for you [1].
>>
>> Cheers,
>> Christian
>>
>> [1] http://files.basex.org/releases/latest/
>>
>>
>>
>> On Mon, May 11, 2020 at 9:47 PM Sebastian Guerrero  wrote:
>> >
>> > Hi Christian!, thanks for your reply :-)
>> >
>> > I've just downloaded the latest snapshot [1] and executed the query [2], 
>> > and yes: the problem is still there.
>> >
>> > Cheers,
>> > Sebastian.
>> >
>> > [1] https://imgur.com/ahgMg7p
>> > [2] https://imgur.com/tDCAtCu
>> >
>> > On Mon, May 11, 2020 at 3:58 PM Christian Grün  
>> > wrote:
>> >>>
>> >>> Maybe it's a newbie issue, but I would like your comments.
>> >>
>> >>
>> >> …definitely something you shouldn't encounter as a newbie either ;) 
>> >> Thanks for reporting it.
>> >>
>> >> Does the exception also occur with the latest snapshot [1]?
>> >>
>> >> Cheers
>> >> Christian
>> >>
>> >> [1] http://files.basex.org/releases/latest/
>> >>
>> >>
>> >>
>> >>
>> >>>
>> >>> I'm writing a RESTXQ method to search among a couple of databases. ( 
>> >>> >100 databases )
>> >>>
>> >>> Some databases are split into a couple of parts due to the number of 
>> >>> nodes. For example US: it's separated into US00, US01 and US02.
>> >>>
>> >>> So, my problem is:
>> >>>
>> >>> if I replace "for $usPart in ('US00')" by "for $usPart in 
>> >>> ('US00','US01',''US02)" in QUERY [A], I get this error:
>> >>>
>> >>> Improper use? Potential bug? Your feedback is welcome:
>> >>> Contact: basex-talk@mailman.uni-konstanz.de
>> >>> Version: BaseX 9.3.2
>> >>> Java: Oracle Corporation, 1.8.0_251
>> >>> OS: Windows 10, amd64
>> >>> Stack Trace:
>> >>> java.lang.NullPointerException
>> >>> at org.basex.query.expr.path.Path.index(Path.java:673)
>> >>> at org.basex.query.expr.path.Path.optimize(Path.java:157)
>> >>> at org.basex.query.expr.gflwor.For.toPredicate(For.java:220)
>> >>> at org.basex.query.expr.gflwor.GFLWOR.optimizeWhere(GFLWOR.java:532)
>> >>> at org.basex.query.expr.gflwor.GFLWOR.optimize(GFLWOR.java:109)
>> >>> at org.basex.query.expr.gflwor.GFLWOR.compile(GFLWOR.java:100)
>> >>> at org.basex.query.expr.Extension.compile(Extension.java:45)
>> >>> at org.basex.query.expr.SwitchGroup.compile(SwitchGroup.java:40)
>> >>> at org.basex.query.expr.Switch.compile(Switch.java:60)
>> >>> at org.basex.query.expr.gflwor.GFLWOR.compile(GFLWOR.java:96)
>> >>> at org.basex.query.expr.gflwor.ForLet.compile(ForLet.java:43)
>> >>> at org.basex.query.expr.gflwor.GFLWOR.compile(GFLWOR.java:90)
>> >>> at org.basex.query.scope.MainModule.comp(MainModule.java:81)
>> >>> at org.basex.query.QueryCompiler.compile(QueryCompiler.java:114)
>> >>> at org.basex.query.QueryCompiler.compile(QueryCompiler.java:105)
>> >>> at org.basex.query.QueryContext.compile(QueryContext.java:312)
>> >>> at org.basex.query.QueryProcessor.compile(QueryProcessor.java:79)
>> >>>
>> >>>
>> >>> Using "for $usPart in ('US00')" it works without any problem. With one 
>> >>> element there is no problem, with two or more it fails.
>> >>>
>> >>> Any ideas about what I'm doing wrong?
>> >>>
>> >>> Here is the
>> >>> QUERY [A]
>> >>> -
>> >>> declare namespace gb="http://www.ipo.gov.uk/schemas/tm;;
>> >>>
>> >>> let $text:="christian"
>> >>> let $registries:=('GB','US')
>> >>>
>> >>> let $results :=
>> >>>   for $registry in $registries
>> >>>return
>> >>>switch ($registry)
>> >>>
>> >>>case "US"
>> >>>return
>> >>>(# db:enforceindex #) {
>> >>>   for $usPart in ('US00')
>> >>>   

Re: [basex-talk] GUI "create db" file patterns are not sticky

2020-05-11 Thread Graydon
On Mon, May 11, 2020 at 10:49:10PM +0200, Christian Grün scripsit:
> > ADDARCHIVES works, CHOP works, INTPARSE works, but CREATEFILTER does not, 
> > or at least I still get only "*.xml" as a suffix in the "File Patterns" box.
> 
> I found out why this doesn’t work: In the database creation dialog,
> CREATEFILTER depends on the input format (XML, JSON, etc.). It is
> always overwritten when the dialog is opened and when this value is
> changed. Well… I’ll think about that.

Thank you!

-- Graydon


Re: [basex-talk] Directory and files are neither a file or a directory on Basex 9.3.2 when read from Docker volume

2020-05-11 Thread Christian Grün
Hi France,

Does your code work without Docker?

> let $src-dir-items := file:list('ContentDBs')
...
> let $debug := file:append('debug-a.xml', 'item: ' || $i || ' is dir: 
> ' || file:is-dir($i) ||  '')
> let $debug := file:append('debug-a.xml', 'item: ' || $i || ' is file: 
> ' || file:is-file($i) ||  '')
> return $i

Please note that file:list only returns the name of the files, not the
paths. You can try file:children instead [1].

Hope this helps,
Christian

[1] https://docs.basex.org/wiki/File_Module#file:children


Re: [basex-talk] GUI "create db" file patterns are not sticky

2020-05-11 Thread Christian Grün
Hi Graydon,

In the BaseX GUI dialog, some options are pure GUI options, and
others, such as CREATEFILTER, are standard database options. The
latter ones are discarded, as they would also affect other BaseX
instances, such as the standalone mode. If you finish a GUI dialog
operation, you can have a look at the Info View panel, in which those
options will be listed. They are assigned via the SET command.

If you want to make database options persistent, you can manually add
them at the bottom of the .basex configuration file [1]. It’s
recommendable to quit the GUI before editing the file, as the
graphical user interface might overwrite your changes when it’s
closed.

Hope this helps,
Christian

[1] https://docs.basex.org/wiki/Configuration#Configuration_Files


On Thu, May 7, 2020 at 6:11 PM Graydon Saunders  wrote:
>
> This is a very small feature request.
>
> Everything else about the Create Database GUI is sticky -- when changed it 
> stays changed -- EXCEPT the file patterns.  Would it be possible to make the 
> file patterns sticky as well?
>
> I often need to create a new database repeatedly since I'm using XQuery to 
> test output from XSLT processes during development.  Remembering to add all 
> the file patterns is not excessively burdensome but I would like to not have 
> to do it.
>
> Thanks!
> Graydon


Re: [basex-talk] Performance loss between version 9.2.4 and 9.3.2 when executing specific xQuery

2020-05-11 Thread Christian Grün
Hi Michael,

I checked your use case in greater depth, and I found the change in
our code that caused the slowdown [1].

A) The nutshell answer : Just use the attached query!

B) The extensive technical answer:

• In previous versions of BaseX, most paths in FLWOR expressions were
»inlined« in the code to trigger further optimizations, such as index
rewritings.
• The enforced inlining led to cases in which the execution time was
worse than for unoptimized queries.
• As a user cannot prevent variables from being inlined, we have
switched to a more predictive pattern in our inlining heuristics:
Paths will only be moved around anymore if we can ensure that the
execution time will not suffer.

A little example:

  let $nodes := db:open('db')/to/this/only/once
  for $i in 1 to 1000
  return $nodes

If $nodes is inlined by the optimizer (i.e., if the variable reference
$nodes in the last line is replaced by the actual path), the path will
be evaluated 1000 times instead of once. The revised query optimizer
won’t inline such paths anymore.

Your particular query benefited from the offensive rewriting, though.
In the first step, "db:open('gnd-sachbegriff')/collection/record" was
inlined by the optimizer:

  let $recFromExistingData := db:open('gnd-sachbegriff')/
collection/record[controlfield[@tag = '001'] = $id]

In the second step, the path was rewritten for index access:

  let $recFromExistingData := db:text('gnd-sachbegriff', $id)/
parent::controlfield[@tag = '001']/parent::record

The index rewriting (which you can spot in the Info View by looking
for "apply text index") led to a much faster evaluation of your query
because it reduces the execution time from quadratic to linear.

If you adopt one of the code lines above, your query will be evaluated
faster again.

In the attached query, db:open is still assigned to variables. As
db:open will only be evaluated once and already at compile time, the
document nodes that will be bound to $sachbegriffe can always be
inlined.

Hope this helps,
Christian

[1] https://github.com/BaseXdb/basex/issues/1722


02-performance-loss-query-cg.xq
Description: Binary data


Re: [basex-talk] Performance loss between version 9.2.4 and 9.3.2 when executing specific xQuery

2020-05-11 Thread BIRKNER Michael
Hi Christian,


thank you very much for looking into this and also for the query. I can confirm 
that by using your rewritten query the performance problem is gone!


Also thank you for taking the time to explain the technical reasons!


Best regards,

Michael


Mag. Michael Birkner
AK Wien - Bibliothek
1040, Prinz Eugen Straße 20-22
T: +43 1 501 65 12455
F: +43 1 501 65 142455
M: +43 664 88957669

michael.birk...@akwien.at
wien.arbeiterkammer.at

Besuchen Sie uns auch auf:
facebook | 
twitter | 
youtube
--
Die AK setzt sich seit 100 Jahren für Gerechtigkeit ein.
Damals. Heute. Für immer.

arbeiterkammer.at/100



Von: Christian Grün 
Gesendet: Montag, 11. Mai 2020 13:02
An: BIRKNER Michael
Cc: basex-talk@mailman.uni-konstanz.de
Betreff: Re: [basex-talk] Performance loss between version 9.2.4 and 9.3.2 when 
executing specific xQuery

Hi Michael,

I checked your use case in greater depth, and I found the change in
our code that caused the slowdown [1].

A) The nutshell answer : Just use the attached query!

B) The extensive technical answer:

• In previous versions of BaseX, most paths in FLWOR expressions were
»inlined« in the code to trigger further optimizations, such as index
rewritings.
• The enforced inlining led to cases in which the execution time was
worse than for unoptimized queries.
• As a user cannot prevent variables from being inlined, we have
switched to a more predictive pattern in our inlining heuristics:
Paths will only be moved around anymore if we can ensure that the
execution time will not suffer.

A little example:

  let $nodes := db:open('db')/to/this/only/once
  for $i in 1 to 1000
  return $nodes

If $nodes is inlined by the optimizer (i.e., if the variable reference
$nodes in the last line is replaced by the actual path), the path will
be evaluated 1000 times instead of once. The revised query optimizer
won’t inline such paths anymore.

Your particular query benefited from the offensive rewriting, though.
In the first step, "db:open('gnd-sachbegriff')/collection/record" was
inlined by the optimizer:

  let $recFromExistingData := db:open('gnd-sachbegriff')/
collection/record[controlfield[@tag = '001'] = $id]

In the second step, the path was rewritten for index access:

  let $recFromExistingData := db:text('gnd-sachbegriff', $id)/
parent::controlfield[@tag = '001']/parent::record

The index rewriting (which you can spot in the Info View by looking
for "apply text index") led to a much faster evaluation of your query
because it reduces the execution time from quadratic to linear.

If you adopt one of the code lines above, your query will be evaluated
faster again.

In the attached query, db:open is still assigned to variables. As
db:open will only be evaluated once and already at compile time, the
document nodes that will be bound to $sachbegriffe can always be
inlined.

Hope this helps,
Christian

[1] https://github.com/BaseXdb/basex/issues/1722
[https://wien.arbeiterkammer.at/ak100_maildisclaimer.png]
Beachten Sie, dass Sie uns ab sofort unter einer geänderten Rufnummer 
erreichen. Bitte speichern Sie gleich Ihren Kontakt zur AK Wien ein unter 501 
65 1, gefolgt von der gewohnten Durchwahl.
Dieses Mail ist ausschließlich für die Verwendung durch die/den darin genannten 
AdressatInnen bestimmt und kann vertrauliche bzw rechtlich geschützte 
Informationen enthalten, deren Verwendung ohne Genehmigung durch den/ die 
AbsenderIn rechtswidrig sein kann.
Falls Sie dieses Mail irrtümlich erhalten haben, informieren Sie uns bitte und 
löschen Sie die Nachricht.
UID: ATU 16209706 I https://wien.arbeiterkammer.at/datenschutz


[basex-talk] I am confused how to specify multiple possible reponses in RestXQ with %rest:produces

2020-05-11 Thread Omar Siam
Hi,

Today someone on the exist-open mailing list pointed out how they
interpret %rest:produces: If your function produces more types of
responses you specify all mime types just the same as with
%rest:consumes: %rest:poroduces("application/xml", "application/json",
...) That is as a list of possible reponses all in one annotation.

The BaseX docs at https://docs.basex.org/wiki/RESTXQ#Content_Negotiation
however are ambigous about this I think. There is an example there with
just two %rest:produces annotations on two lines with only one mime type
(and a qs value). I think that lead me to belief that to specify
multiple possible responses of different mime types you repeat
%rest:produces.

Rereading the section these two example annotations could also ilustrate
the use of %rest:produces in two different functions.

Can you please clarify this if possible?

Best regards

Omar Siam



Re: [basex-talk] repeatedly full-text marking the same text node

2020-05-11 Thread Christian Grün
Hi Graydon,

Thanks for sharing your use case.

> However, so far as I can tell, full text only works directly on a database 
> node.  If I try to pass the node in a function, I get "No database node" 
> errors from attempting full-text operations.

You can convert an XML node to the internal “database node”
representation by applying a dummy operation:

  let $xml := hello world update {}
  return ft:mark($xml[text() contains text 'hello'])

Does this already help? See the Wiki articles [1,2] for some revised
information.

I have already asked myself in the past if we shouldn’t include a
function that expose internal result positions to the user?
Suggestions are welcome.

Best,
Christian

[1] https://docs.basex.org/wiki/Full-Text_Module#ft:mark
[2] https://docs.basex.org/wiki/Database_Module#Database_Nodes


Re: [basex-talk] GUI "create db" file patterns are not sticky

2020-05-11 Thread Graydon
On Mon, May 11, 2020 at 09:23:34AM +0200, Christian Grün scripsit:
> Hi Graydon,

Hi Christian --

[sensible reasons for why it does that snipped]
> If you want to make database options persistent, you can manually add
> them at the bottom of the .basex configuration file [1]. It’s
> recommendable to quit the GUI before editing the file, as the
> graphical user interface might overwrite your changes when it’s
> closed.

So if I edit ~/.basex so that the last lines are:

# Local Options
ARCHIVENAME = true

# create databases
CREATEFILTER = *.xml,*.met
ADDARCHIVES = false
CHOP = false
INTPARSE = true


ADDARCHIVES works, CHOP works, INTPARSE works, but CREATEFILTER does not, or at 
least I still get only "*.xml" as a suffix in the "File Patterns" box.

Am I doing this wrong? This is with 9.3.2.

Thanks!
Graydon


Re: [basex-talk] repeatedly full-text marking the same text node

2020-05-11 Thread Graydon
On Mon, May 11, 2020 at 07:51:02PM +0200, Christian Grün scripsit:
> Hi Graydon,

Hi Christian --

> Thanks for sharing your use case.
> 
> > However, so far as I can tell, full text only works directly on a database 
> > node.  If I try to pass the node in a function, I get "No database node" 
> > errors from attempting full-text operations.
> 
> You can convert an XML node to the internal “database node”
> representation by applying a dummy operation:
> 
>   let $xml := hello world update {}
>   return ft:mark($xml[text() contains text 'hello'])
> 
> Does this already help? See the Wiki articles [1,2] for some revised
> information.

That helps and I will check, but not this week.  (This part of the current 
deadline has been addressed by clubbing the problem with a rock, er, 
xsl:iterate, and that'll do for now.  The general pattern is something I need 
to do a lot so I'll be coming back to this.)

Thank you very much for the docs update!

> I have already asked myself in the past if we shouldn’t include a
> function that expose internal result positions to the user?
> Suggestions are welcome.

The thing that I would most want to see is some way to capture multi-word 
matches using full-text search; "full phrase search", in effect. I can see that 
as the start and end of a range of internal result positions but will admit to 
wanting something less at risk of my arithmetic errors.

-- Graydon


[basex-talk] Query optimizer bug with nested for? - java.lang.NullPointerException at Path.index(Path.java:673)

2020-05-11 Thread Sebastian Guerrero
Hi everybody!

Maybe it's a newbie issue, but I would like your comments.

I'm writing a RESTXQ method to search among a couple of databases. ( >100
databases )

Some databases are split into a couple of parts due to the number of nodes.
For example US: it's separated into US00, US01 and US02.

So, my problem is:

if I replace "*for $usPart in ('US00')*" by "*for $usPart in
('US00','US01',''US02)*" in *QUERY [A]*, I get this error:

*Improper use? Potential bug? Your feedback is welcome:*
*Contact: basex-talk@mailman.uni-konstanz.de
*
*Version: BaseX 9.3.2*
*Java: Oracle Corporation, 1.8.0_251*
*OS: Windows 10, amd64*
*Stack Trace: *
*java.lang.NullPointerException*
* at org.basex.query.expr.path.Path.index(Path.java:673)*
* at org.basex.query.expr.path.Path.optimize(Path.java:157)*
* at org.basex.query.expr.gflwor.For.toPredicate(For.java:220)*
* at org.basex.query.expr.gflwor.GFLWOR.optimizeWhere(GFLWOR.java:532)*
* at org.basex.query.expr.gflwor.GFLWOR.optimize(GFLWOR.java:109)*
* at org.basex.query.expr.gflwor.GFLWOR.compile(GFLWOR.java:100)*
* at org.basex.query.expr.Extension.compile(Extension.java:45)*
* at org.basex.query.expr.SwitchGroup.compile(SwitchGroup.java:40)*
* at org.basex.query.expr.Switch.compile(Switch.java:60)*
* at org.basex.query.expr.gflwor.GFLWOR.compile(GFLWOR.java:96)*
* at org.basex.query.expr.gflwor.ForLet.compile(ForLet.java:43)*
* at org.basex.query.expr.gflwor.GFLWOR.compile(GFLWOR.java:90)*
* at org.basex.query.scope.MainModule.comp(MainModule.java:81)*
* at org.basex.query.QueryCompiler.compile(QueryCompiler.java:114)*
* at org.basex.query.QueryCompiler.compile(QueryCompiler.java:105)*
* at org.basex.query.QueryContext.compile(QueryContext.java:312)*
* at org.basex.query.QueryProcessor.compile(QueryProcessor.java:79)*


Using "*for $usPart in ('US00')*" it works without any problem. With one
element there is no problem, with two or more it fails.

Any ideas about what I'm doing wrong?

Here is the
*QUERY [A]*
-
declare namespace gb="http://www.ipo.gov.uk/schemas/tm;;

let $text:="christian"
let $registries:=('GB','US')

let $results :=
  for $registry in $registries
   return
   switch ($registry)

   case "US"
   return
   (# db:enforceindex #) {
  for $usPart in ('US00')
  for $tmUS in
db:open($usPart)/trademark-applications-daily/application-information/file-segments/action-keys/case-file
  where $tmUS/case-file-header/mark-identification/text()
contains text {$text} using stemming
  return
US{$tmUS/case-file-header/mark-identification/text()}
}

   case "GB"
   return
   (# db:enforceindex #) {
   for $tmGB in
db:open('GB')/gb:MarkLicenceeExportList/gb:TradeMark
  where
$tmGB/gb:WordMarkSpecification/gb:MarkVerbalElementText/text() contains
text {$text}
return
GB{$tmGB/gb:WordMarkSpecification/gb:MarkVerbalElementText/text()}

}

default return ""

return

{count($results)}

{
for $result in $results
return $result
}



-

Regards,
Sebastian


Re: [basex-talk] Query optimizer bug with nested for? - java.lang.NullPointerException at Path.index(Path.java:673)

2020-05-11 Thread Christian Grün
>
> Maybe it's a newbie issue, but I would like your comments.
>

…definitely something you shouldn't encounter as a newbie either ;) Thanks
for reporting it.

Does the exception also occur with the latest snapshot [1]?

Cheers
Christian

[1] http://files.basex.org/releases/latest/





> I'm writing a RESTXQ method to search among a couple of databases. ( >100
> databases )
>
> Some databases are split into a couple of parts due to the number of
> nodes. For example US: it's separated into US00, US01 and US02.
>
> So, my problem is:
>
> if I replace "*for $usPart in ('US00')*" by "*for $usPart in
> ('US00','US01',''US02)*" in *QUERY [A]*, I get this error:
>
> *Improper use? Potential bug? Your feedback is welcome:*
> *Contact: basex-talk@mailman.uni-konstanz.de
> *
> *Version: BaseX 9.3.2*
> *Java: Oracle Corporation, 1.8.0_251*
> *OS: Windows 10, amd64*
> *Stack Trace: *
> *java.lang.NullPointerException*
> * at org.basex.query.expr.path.Path.index(Path.java:673)*
> * at org.basex.query.expr.path.Path.optimize(Path.java:157)*
> * at org.basex.query.expr.gflwor.For.toPredicate(For.java:220)*
> * at org.basex.query.expr.gflwor.GFLWOR.optimizeWhere(GFLWOR.java:532)*
> * at org.basex.query.expr.gflwor.GFLWOR.optimize(GFLWOR.java:109)*
> * at org.basex.query.expr.gflwor.GFLWOR.compile(GFLWOR.java:100)*
> * at org.basex.query.expr.Extension.compile(Extension.java:45)*
> * at org.basex.query.expr.SwitchGroup.compile(SwitchGroup.java:40)*
> * at org.basex.query.expr.Switch.compile(Switch.java:60)*
> * at org.basex.query.expr.gflwor.GFLWOR.compile(GFLWOR.java:96)*
> * at org.basex.query.expr.gflwor.ForLet.compile(ForLet.java:43)*
> * at org.basex.query.expr.gflwor.GFLWOR.compile(GFLWOR.java:90)*
> * at org.basex.query.scope.MainModule.comp(MainModule.java:81)*
> * at org.basex.query.QueryCompiler.compile(QueryCompiler.java:114)*
> * at org.basex.query.QueryCompiler.compile(QueryCompiler.java:105)*
> * at org.basex.query.QueryContext.compile(QueryContext.java:312)*
> * at org.basex.query.QueryProcessor.compile(QueryProcessor.java:79)*
>
>
> Using "*for $usPart in ('US00')*" it works without any problem. With one
> element there is no problem, with two or more it fails.
>
> Any ideas about what I'm doing wrong?
>
> Here is the
> *QUERY [A]*
>
> -
> declare namespace gb="http://www.ipo.gov.uk/schemas/tm;;
>
> let $text:="christian"
> let $registries:=('GB','US')
>
> let $results :=
>   for $registry in $registries
>return
>switch ($registry)
>
>case "US"
>return
>(# db:enforceindex #) {
>   for $usPart in ('US00')
>   for $tmUS in
> db:open($usPart)/trademark-applications-daily/application-information/file-segments/action-keys/case-file
>   where $tmUS/case-file-header/mark-identification/text()
> contains text {$text} using stemming
>   return
> US{$tmUS/case-file-header/mark-identification/text()}
> }
>
>case "GB"
>return
>(# db:enforceindex #) {
>for $tmGB in
> db:open('GB')/gb:MarkLicenceeExportList/gb:TradeMark
>   where
> $tmGB/gb:WordMarkSpecification/gb:MarkVerbalElementText/text() contains
> text {$text}
> return
> GB{$tmGB/gb:WordMarkSpecification/gb:MarkVerbalElementText/text()}
>
> }
>
> default return ""
>
> return
> 
> {count($results)}
> 
> {
> for $result in $results
> return $result
> }
> 
> 
>
> -
>
> Regards,
> Sebastian
>