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 <trademark><ipo>US</ipo><text>{$tmUS/case-file-header/mark-identification/text()}</text></trademark>
                }

           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 <trademark><ipo>GB</ipo><text>{$tmGB/gb:WordMarkSpecification/gb:MarkVerbalElementText/text()}</text></trademark>              
                }      

            default return ""

    return
    <result>
        <total>{count($results)}</total>
        <trademarks>
        {
            for $result in $results
            return $result
        }
        </trademarks>        
    </result>
  -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  

Regards,
Sebastian