Hi Devesh,

The cardinality in XQuery sequence types (be it ? * or +) gives you
control on the acceptable number of items in each input sequence. In
XQuery, the Kleene star and the question mark ? accept the empty
sequence, but do not make the function argument optional, nor change
the arity of the function (in your case, it is binary).

Looking at the first function you give as an example, there are extra
pairs of square brackets. This could be a MarkLogic-specific
extension, that (I am speculating here, as I am discovering this
syntax now, so anybody please feel free to correct me) may be a
syntactic sugar (very convenient if I may say!) leading to the desired
behavior by implicitly adding functions with lower arities.

Have you tried to add square brackets like so?

local:get-rdf-builder(
  [$prefix-map as map:map?],
  [$graph as sem:iri?])
as function(item(), item(), item()) as sem:triple

I hope it helps.

Kind regards,
Ghislain


On Wed, Aug 12, 2015 at 9:19 AM, Tyagi, Devesh <[email protected]> wrote:
> a correction, function signature is
>
>
> local:get-rdf-builder($prefix-map as map:map?, $graph as sem:iri?) as
> function(item(), item(), item()) as sem:triple
>
> Regards,
> Devesh
>
> ________________________________
> From: [email protected]
> <[email protected]> on behalf of Tyagi, Devesh
> <[email protected]>
> Sent: Wednesday, August 12, 2015 12:45 PM
> To: [email protected]
> Subject: [MarkLogic Dev General] Confusing behavior of '?' cardinality in
> arguments
>
>
> Hi,
>
>
> While using following function
>
> sem:rdf-builder(
>    [$prefixes as map:map?],
>    [$graph as sem:iri?]
> ) as function(item(),item(),item()) as sem:triple
>
> we can invoke it as follows
>
> sem:rdf-builder().
>
> But when I am creating my own function as follows
>
> local:get-rdf-builder($prefix-map as map:map*, $graph as sem:iri*) as
> function(item(), item(), item()) as sem:triple
>
> and invoked it as
>
> local:get-rdf-builder()
>
> It raises the following exception
>
> get-rdf-builder() -- Too few args, expected 2 but got 0
>
> Works fine for local:get-rdf-builder((),()).
>
> I am executing this in Marklogic QConsole.
>
> Any help would be appreciated.
>
> Regards,
>
> Devesh
>
>
> "This e-mail and any attachments transmitted with it are for the sole use of
> the intended recipient(s) and may contain confidential , proprietary or
> privileged information. If you are not the intended recipient, please
> contact the sender by reply e-mail and destroy all copies of the original
> message. Any unauthorized review, use, disclosure, dissemination,
> forwarding, printing or copying of this e-mail or any action taken in
> reliance on this e-mail is strictly prohibited and may be unlawful."
> "This e-mail and any attachments transmitted with it are for the sole use of
> the intended recipient(s) and may contain confidential , proprietary or
> privileged information. If you are not the intended recipient, please
> contact the sender by reply e-mail and destroy all copies of the original
> message. Any unauthorized review, use, disclosure, dissemination,
> forwarding, printing or copying of this e-mail or any action taken in
> reliance on this e-mail is strictly prohibited and may be unlawful."
>
> _______________________________________________
> General mailing list
> [email protected]
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to