Hi Devesh,
Thank you for your feedback. I see. Maybe I was too optimistic then,
and the square brackets are only a documentation convention (e.g.,
http://docs.marklogic.com/sem:rdf-builder?q=sem:rdf-builder&v=8.0&api=true
).
If there is no such syntactic sugar, then, you may need to explicitly
declare these other functions, like so:
=======
declare function local:get-rdf-builder()
as function(item(), item(), item()) as sem:triple
{
local:get-rdf-builder((), ())
};
declare function local:get-rdf-builder(
$prefix-map as map:map?)
as function(item(), item(), item()) as sem:triple
{
local:get-rdf-builder($prefix-map, ())
};
=======
Does it work for you? (I compiled the above code in my mind, so there
may be typos).
Kind regards,
Ghislain
On Wed, Aug 12, 2015 at 11:34 AM, Tyagi, Devesh <[email protected]> wrote:
> Hi Ghislain,
>
> On adding the square brackets, Marklogic generates an exception
>
> Unexpected token syntax error, unexpected Lbrack_, expecting Rpar_
>
> Regards,
> Devesh
>
> ________________________________________
> From: [email protected]
> <[email protected]> on behalf of Ghislain Fourny
> <[email protected]>
> Sent: Wednesday, August 12, 2015 1:08 PM
> To: MarkLogic Developer Discussion
> Subject: Re: [MarkLogic Dev General] Confusing behavior of '?' cardinality
> in arguments
>
>
> 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
> "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