I am getting various "Static error" when I try to run my xQuery with DataDirect processor.
The simple example receives the following error:
[DataDirect][XQuery][err:XPST0005]Error at line 16, column 51. Static error. The static type of step 'parent::node()' is empty-sequence(). [Call stack: local:getNode@21.4]
declare function local:getNode($system as element(), $node as element()*, $noNode as element()*) as element()*
{
let $myNode := if (exists($noNode)) then $noNode/../.. else $node/..
return $myNode
};
The getNode() function accepts two sets of elements, and depending whether one set is empty, it retrieves the parent or grand-parent of another set.
But when I call this function with an empty sequence, DataDirect throws this exception. My intention was that the function should catch the empty sequence condition. How can I make this to work with DataDirect?