To add to what Wayne has said:
Function mapping isn't forcing a function that accepts a singleton to accept a
sequence. It just allows you to process a sequence using a function that takes
a singleton (by repeatedly calling that function under-the-covers). So type
checking isn't broken with function mapping, although when you first bump into
it it can feel that way.
Since XQuery is all about processing sequences (every expression evaluates to a
sequence of items, after all), function mapping allows you to process sequences
in a very natural way.
--Colleen
-----Original Message-----
From: [EMAIL PROTECTED] on behalf of Wayne Feick
Sent: Thu 11/6/2008 9:31 AM
To: [EMAIL PROTECTED]; General Mark Logic Developer Discussion
Subject: Re: [MarkLogic Dev General] Empty argument fails silently?
Hi Florent,
This allows you to omit a FLWOR from your code. Instead of
for $x in (1, 2, 3, 4, 5)
return some-func($x)
you can just write
some-func((1, 2, 3, 4, 5))
A more concrete, real-life example would be
xdmp:document-insert(
$uri, $doc,
(xdmp:permission("owner-role", ("read", "update")),
xdmp:permission(("reader-role1", "reader-role2",
"reader-role3"), "read")))
With function mapping coming in handy for generating the permissions
list.
It's just about writing more succinct code.
Also, if you declare your function to take an optional argument like
"xs:string?" then function mapping will not happen and you'll get an
exception if you pass more than one value.
Wayne.
On Thu, 2008-11-06 at 17:57 +0100, Florent Georges wrote:
> Colleen Whitney wrote:
>
> > This is the result of function mapping
>
> I can't find out of the top of my head any use case that this new
> feature is intended to solve. And of course, no use case that is worth
> adding such a feature that breaks the type checking system.
>
> Did I miss something obvious?
>
> Regards,
>
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general