[xquery-talk] Empty or Null Array?

Eliot Kimber ekimber at contrext.com
Thu Jul 16 07:29:26 PDT 2015

I do see that I can do:

let $array := [()]

To create an array with one member that is an empty sequence.

My business problem is I need to pass an array of sequences to a recursive
function, where each recursion takes the cadr of the array. When the array
is empty, recursion stops. So the question is, how to determine that an
array is "empty" given that an array must have at least one member.

It looks like the answer is "an array is empty when the only member is an
empty sequence".

Is my analysis correct?


Eliot Kimber, Owner
Contrext, LLC

On 7/16/15, 9:11 AM, "Eliot Kimber" <talk-bounces at x-query.com on behalf of
ekimber at contrext.com> wrote:

>I'm using an array to pass values down a recursive function call chain.
>I noticed that, at least with BaseX but also based on my reading of the
>3.1 spec, that you cannot construct an empty array.
>Is this correct?
>If so, how can one have a function where the array is effectively empty?
>E.g., given this function declaration:
>declare ns:myFunc($arg1 as xs:string+, $arg2 as array(*)?, $arg3 as
>xs:string) {};
>How can I satisfy the second argument when in fact I have no items for the
>I tried passing in () but BaseX says "Cannot cast empty-sequence() to
>array(*)", which makes sense.
>I would expect array{} to be a valid constructor, such that
>array:size(array{}) = 0 is true but that does not appear to be allowed for
>in the 3.1 spec.
>What have I missed?
>Eliot Kimber, Owner
>Contrext, LLC
>talk at x-query.com

More information about the talk mailing list