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

functions with out parameters

Martin Probst martin at x-hive.com
Tue Aug 15 13:18:58 PDT 2006


function out
Hi,

> Hi all, I need to design somehow xquery functions with inout  
> parameters. AFAIN xquery only supports input parameters. Do you  
> have any idea how to achieve that?

Functions in XQuery have a return type, which is an excellent way of  
_returning_ stuff from a function ;-)

If you have to return multiple values from one function call, you can  
either return a tuple, e.g.

declare function local:square-and-cubic($bar as xs:integer) as  
xs:integer+
{
   $bar * $bar, $bar * $bar * $bar
};
And then use it with indexes, e.g. $res[1] and $res[2].

Alternatively you can use XML to model your datatype:
declare function local:square-and-cubic($bar as xs:integer) as element()
{
   <result><square>{ $bar * $bar }</square><cubic>{ $bar * $bar *  
$bar }</cubic></result>
};

In many cases you might find that you already have an XML element  
type for the kind of result you expect, because you use that composed  
type in one of your schemas.

HTH,
Martin

Am 15.08.2006 um 11:43 schrieb Enric Jaen:

> Hi all, I need to design somehow xquery functions with inout  
> parameters. AFAIN xquery only supports input parameters. Do you  
> have any idea how to achieve that?
> Thanks in advance,
> -Enric
>
>
> _______________________________________________
> http://xquery.com/mailman/listinfo/talk
> http://xquery.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.