From: Pieter D. <pie...@gm...> - 2010-08-09 14:32:19
|
On Mon, Aug 9, 2010 at 3:39 PM, Dmitriy Shabanov <sha...@gm...>wrote: > On Mon, 2010-08-09 at 11:50 +0200, Pieter Deelen wrote: > > Let's forget about the string function for a moment and introduce function > f: > > declare function local:f($elt as element()) { > "f" > }; > > Then if I evaluate the following expression > > (<a/>, <b/>)/local:f(.) > > I expect (and get from both eXist 1.4 and Saxon 9) > > ("f", "f") > > So the function f is called twice, the first time with <a/> as parameter, > and the second time with <b/>. > > Similarly, (<a/>)/local:f(.) returns ("f"): the function f is called once, > for <a/>. > > So if I evaluate > > ()/local:f(.) > > I would expect the function f to be called not at all and the empty > sequence as result. Instead, eXist shows the following error: > > "The actual cardinality for parameter 1 does not match the cardinality > declared in the function's signature: local:f($a as element()) item()*. > Expected cardinality: exactly one, got 0." > > I.e., eXist tries to call the function f, but this fails because the > function's signature does not allow it. > > Saxon gives me the result I expect. > > > Change function definition & getting more serious, low level, engine bug > > ====================================================== > declare function local:f($elt) { > "f" > }; > > ()/local:f(.) > ====================================================== > > return ("f"), that is not correct. > > Can we split the bug into two: > > 1. xs:string( () ) should be empty string > There are a few subtle differences between xs:string (which is a type constructor) and fn:string (which is a standard function). As far as I am aware, xs:string(()) should yield () and fn:string(()) should yield "". I can't find the exact spec right now, but both eXist and Saxon produce the same results. > 2. function call on empty sequence > That was the actual problem I was hinting at. I had hoped it would be clearer if I used standard functions. > > -- > Cheers, > > Dmitriy Shabanov > > |