Hi,

I am trying to create units tests for my functions and have encountered
an error when I attempt to pass an element to the function.

I've omitted the namespace declarations from the example for brevity.

The function defintion is:

declare function mine:doSomething($item as element()) as element()
{
        return $item/ns:someElement
};

This works fine when invoked with $item obtained from a string version
of a SOAP document passed in declared as follows:

declare variable $source external;
let $item :=
xdmp:unquote($source)/SOAP-ENV:Envelope/SOAP-ENV:Body/ns:item
let $result := mine:doSomething($item)
return $result

The problem is when I attempt to call the function from a unit test
where I construct a shorter document like 

let $item := xdmp:unquote("<ns:item
xmlns:ns="http://urn:my:namespace";><ns:subItem>text</ns:subItem></ns:ite
m>") /ns:item
let $result := mine:doSomething($item)
return $result

I get the following error

[1.0-ml] XDMP-AS: (err:XPTY0004)
mine:doSomething(<ns:item><ns:subItem>text</ns:subItem></ns:item>) --
invalid coercion: () as element()

I've tried using an element constructor to create an element to pass to
the function but I still get the same invalid coercion: () as element()
error.

Any ideas how I can get the abbreviated form to work?

Thanks,

Bob
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to