From: Kemal P. <ke...@pa...> - 2012-11-11 10:48:13
|
Ok, always good to see bugs fixed, at least it forces me to write correct code :) But the thing is, putting a "?" was the first thing I tried: *declare function local:buildLightXmlObjectList($results as element()*, $scope as element()?, $hits-perpage as xs:integer, $hit-start as xs:integer) as element() {* * do some stuff* *};* But now I got this error: *ERROR XPTY0004: The actual cardinality for parameter 2 does not match the cardinality declared in the function's signature: result:buildResultListItem($result as element(), $scope as element()) element(). Expected cardinality: exactly one, got 0.* Being no XQuery expert I always hesitate to declare something a bug, but this does sound confusing to me. I mean, the "?" should denote "zero or one", right? But it says that et expects exactly one... 2012/11/11 Wolfgang Meier <wol...@ex...> > > I am sitting with some XQuery functions which I wrote last year and > which use to run just fine in my eXist DB 1.4. Yesterday I built the latest > version of eXist from the trunk and now I have a problem invoking the > following function: > > > > declare function local:buildLightXmlObjectList($results as element()*, > $scope as element(), $hits-perpage as xs:integer, $hit-start as xs:integer) > as element() { > > do some stuff > > }; > > > > The thing is, in some situations I call the function with an empty > second argument, like this (i do handle the case when the argument is > empty): > The declaration $scope as element() requires exactly one element, so the > XQuery engine must generate an error if you pass in the empty sequence. > eXist-db 1.4.x allowed the empty sequence, but this was definitely a bug > and I fixed this recently. > > Fixing your function declaration is easy - just add a ? to the declared > type: > > $scope as element()? > > Wolfgang > |