An ArrayIndexOutOfBounds exception occurs when calling the toString() method of an XdmNode that represents a namespace node.
The underlying cause of this is in the TreeReceiver class, which is invoked via QueryResult.serialize() when the sequence to be serialized includes a namespace node.
Two patches will be raised:
(a) to cause TreeReceiver.namespace() to throw a NoOpenStartTag exception instead of ArrayIndexOutOfBounds when a top-level namespace node is passed (this mirrors the behaviour with attribute nodes)
(b) to special case namespace nodes in XdmNode.toString(), in rather the same way that attribute nodes are already special-cased, generating the string xmlns="uri" or xmlns:pre="uri" as appropriate.