Hi Tim,
For functions written in XQuery, you are correct, you just need to
overload the function by creating multiple functions with the same name,
differing only by trailing parameters.
The built-in functions are not written in XQuery, but are compiled into
MarkLogic Server, and those perform similar functionality, but are not
necessarily written that way.
In any case, to write your own functions with optional arguments, you
must overload the function. Here is a trivial example:
xquery version "1.0-ml";
declare function local:hello() as xs:string {"hello"};
declare function local:hello($x as xs:string) {$x};
local:hello(),
local:hello("this is a different string")
(: returns:
hello
this is a different string
:)
Hope that helps.
-Danny
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Tim Finney
Sent: Tuesday, December 09, 2008 5:03 PM
To: General Mark Logic Developer Discussion
Subject: [MarkLogic Dev General] Functions with optional arguments
Dear All,
I notice that some of the built-in functions have optional arguments.
For example, both of these are OK:
xdmp:get-request-field("foo")
xdmp:get-request-field("foo", "bar")
How is this done? Is it just a matter of writing more than one function
definition, each with a different signature, or is there another way?
Best,
Tim Finney
XQuery programmer
UVa Press
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general