|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] Questions on User-Defined FunctionsWei, Alice J. ajwei at indiana.eduSun Feb 24 07:45:35 PST 2008
Dear Michael:
Nope, all I want is just something simple that can perform
<statistics>
{count(distinct-values((
fn:collection("xmldb:exist://db/my"))//ad))}
</statistics>
which brings the output of <statistics>229</statistics>
I modified my code to what you suggested,
declare function local:total($po as element(ad)*)
as xs:integer {
count(distinct-values($po))
};
local:total(collection("xmldb:exist://db/my")//ad)
and it did bring the number 229, which I wanted. However, the number is now in superscript, and I wanted to add the <statistics> tags back in.
Would I need to declare anything else?
I intend to create a web application out of XQuery, and I am not sure if user-defined functions is the way to go.
Any suggestion is welcome.
======================================================
Alice Wei
MIS 2008
School of Library and Information Science
Indiana University Bloomington
http://x-query.com/mailman/listinfo/talk
________________________________________
From: Michael Kay [http://x-query.com/mailman/listinfo/talk]
Sent: Sunday, February 24, 2008 4:12 AM
To: Wei, Alice J.; http://x-query.com/mailman/listinfo/talk
Subject: RE: Questions on User-Defined Functions
You've declared the function as expecting a single element named
"statistics" but you are passing it a sequence of elements named "ad". You
could change it to say "$po as element(ad)*" (The * means zero or more). I
assume your function is really doing something more complex than counting
the items in the input; teh actual parameter declaration should be based on
the assumptions that the body of the function needs to make about the input.
Michael Kay
http://www.saxonica.com/
======================================================
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! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








