Re: [bdbxml] hasNext() fails on an empty result

George Feinberg <[email protected]> Fri, 12 Aug 2005 12:05:47 -0400
Newsgroups gmane.comp.db.dbxml.general
Message-ID <[email protected]>
On Aug 12, 2005, at 9:50 AM, Ivan Bogouchev / Иван Богушев  
wrote:

> 2005/8/12, George Feinberg <[email protected]>:
> That sort of exception is never a feature.
>
> What version of BDB XML are you using, and platform?
>
>  bdbxml 2.1.8 binary distribution on windows XP, jdk1.5.0_03 (sorry  
> I forgot to give that before)
>
>
> Is this on all empty query results?  A simple test program is often
> helpful, in case there is something subtle going on.
>
>
> Actually I isolated the error to a xquery function:
>
> declare function lo:getClass ($name) as node() {
>     let $ret := collection($container) / k:Class [ @name = $name ]
>     return $ret
> };
>
> So the exception is generated when $ret is empty.
> But when i remove the "as node()" from the declaration there is no  
> problem with the empty $ret

Technically, when the result is empty, the version with "as node()"  
should throw
an XQuery runtime exception because an empty result doesn't match the  
return type.

The exception I see is:
XmlException: com.sleepycat.dbxml.XmlException: Error: SequenceType  
matching failed: the sequence does not contain items [err:XP0006],  
errcode = XPATH_EVALUATION_ERROR

That should be happening in 2.1.8.  If you could create a tiny Java  
test case
I can isolate the specific problem you are having.

Regards,

George