[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
Sun Feb 24 07:45:35 PST 2008


  Questions on User-Defined Functions
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!

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-2011 All Rights Reserved.