[xquery-talk] functions with out parameters
Martin Probst
martin at x-hive.com
Tue Aug 15 13:18:58 PDT 2006
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
>
>
> _______________________________________________
> talk at xquery.com
> http://xquery.com/mailman/listinfo/talk
>
More information about the talk
mailing list