[xquery-talk] value not bound exception while using empty()

Dirk Kirsten dk at basex.org
Wed Jun 19 04:28:38 PDT 2013


As you have to bind external variables in XQuery 1.0, just bind it to an 
empty sequence. So in your scenario: In case you get an empty result set 
for your values / nodes, just bind the external variable $a to an empty 
sequence. This way you can than also check for fn:empty($a).

Cheers,
Dirk

On 06/19/2013 01:12 PM, Kunal Chauhan wrote:
> Yes, that I know. I bind several different items.
>
> but the scenario is after some processing I get some value / nodes which
> I need to bind to execute query.
> in this case, I didn't get any value / node.
> Still I need to run the query.
>
> declare variable $a external;
> return empty($a)
>
> Query is generated dynamically, variable is defined but for $a I didn't
> get any value.
> So, I am unable to bind it.
> and that's why I getting an error.
>
>
>
>
> On Wed, Jun 19, 2013 at 4:20 PM, Michael Kay <mike at saxonica.com
> <mailto:mike at saxonica.com>> wrote:
>
>     Yes, of course you can bind a value from the application. In XQJ
>     that's done using the bind...() methods of XQDynamicContext.
>
>     Michael Kay
>     Saxonica
>
>     On 19 Jun 2013, at 08:58, Kunal Chauhan wrote:
>
>>     Yes Michael, You are right.
>>     as soon as I run this query through java code where I am using
>>     XQuery 1.0 and XQJ implementation. It gives me an error.
>>
>>     earlier I tried with Query editor so it works. but after
>>     integrating it with java code it doesn't.
>>
>>     Is there any way to bind an empty sequence  or any other work around?
>>
>>
>>
>>     On Wed, Jun 19, 2013 at 12:52 PM, Michael Kay <mike at saxonica.com
>>     <mailto:mike at saxonica.com>> wrote:
>>
>>         Actually, this is XQuery 3.0 syntax.
>>
>>         XQuery 1.0 gives you no way to define a default value for an
>>         external variable (a crazy omission).
>>
>>         You clearly have an expectation that the default value for an
>>         external variable should be an empty sequence. You may regard
>>         that as intuitive, but it's not what the spec says.
>>
>>         Michael Kay
>>         Saxonica
>>
>>
>>
>>         On 19 Jun 2013, at 07:34, Kunal Chauhan wrote:
>>
>>>         Thanks David, Thanks for your quick response.
>>>         It's works.
>>>         can you tell me logic behind this ?
>>>
>>>
>>>         On Wed, Jun 19, 2013 at 11:44 AM, David Lee <dlee at calldei.com
>>>         <mailto:dlee at calldei.com>> wrote:
>>>
>>>             try ____
>>>
>>>             __ __
>>>
>>>             declare variable $a external := ();____
>>>
>>>             __ __
>>>
>>>             __
>>>
>>
>>
>>
>>     --
>>     *Kunal Chauhan*
>>     mail4ck at gmail.com <mailto:mail4ck at gmail.com>
>>     [+918655517141]
>>     _______________________________________________
>>     talk at x-query.com <mailto:talk at x-query.com>
>>     http://x-query.com/mailman/listinfo/talk
>
>
>
>
> --
> *Kunal Chauhan*
> mail4ck at gmail.com <mailto:mail4ck at gmail.com>
> [+918655517141]
>
>
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk
>

-- 
Dirk Kirsten, BaseX GmbH, http://basex.org
|-- Firmensitz: Blarerstrasse 56, 78462 Konstanz
|-- Registergericht Freiburg, HRB: 708285, Geschäftsführer:
|   Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle
`-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22


More information about the talk mailing list