[xquery-talk] Questions on User-Defined Functions
Wei, Alice J.
ajwei at indiana.edu
Sat Feb 23 21:51:22 PST 2008
Hi, XQueriers:
I have here one debugging issue here with XQuery using User-Defined Function.
This is what I have now:
declare function local:total($po as element(statistics))
as xs:integer {
count($po)
};
local:total(collection("xmldb:exist://db/my")//ad)
The error I got is:
Error while evaluating expression: declare function local:total($po as element(statistics)) as xs:integer { count($po) }; local:total(collection("xmldb:exist://db/cbml")//ad). The actual cardinality for parameter 1 does not match the cardinality declared in the function's signature: local:total($a as element) xs:integer. Expected cardinality: exactly one, got 517. [at line 115, column 21] In call to function: local:total(element) [5:1]
The code is based on the XQuery of
<statistics>
{count(distinct-values((
fn:collection("xmldb:exist://db/my"))//ad))}
</statistics>
which brings the output of <statistics>229</statistics>
What have I done wrong here?
The other question I have is that since I intend to create a web application out of XQuery, whether or not I should use user-defined functions. Any suggestion is welcome.
Alice
======================================================
Alice Wei
MIS 2008
School of Library and Information Science
Indiana University Bloomington
ajwei at indiana.edu
More information about the talk
mailing list