[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

Questions on User-Defined Functions

Wei, Alice J. ajwei at indiana.edu
Sat Feb 23 21:51:22 PST 2008


  Questions on User-Defined Functions
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
http://x-query.com/mailman/listinfo/talk



Purchase Stylus Studio Online Today!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.