You can also explicitly disable function mapping by including the following 
declaration:

declare option xdmp:mapping "false";

This way, you can still get all of the goodies available in 1.0-ml and only 
disable this specific bit of functionality.  I have gotten into the habit of 
including this declaration in all of my modules as I have gotten in trouble 
with this on numerous times ... I suspect others have as well.  I'm not really 
sure why MarkLogic made the default behavior true in 1.0-ml (as it seems to 
cause so much confusion and trouble) but I suspect there was a good reason.

Darin.


-----Original Message-----
From: general-boun...@developer.marklogic.com on behalf of Geert Josten
Sent: Sat 4/3/2010 4:54 AM
To: General Mark Logic Developer Discussion
Subject: RE: [MarkLogic Dev General] Unexpected behavior
 
If it is too confusing you can also just put xquery version "1.0" on the top of 
your query, which turns function mapping off as well. But then you will have to 
do without goodies like try-catch and such..

;-)

>


drs. G.P.H. (Geert) Josten
Consultant


Daidalos BV
Hoekeindsehof 1-4
2665 JZ Bleiswijk

T +31 (0)10 850 1200
F +31 (0)10 850 1199

mailto:geert.jos...@daidalos.nl
http://www.daidalos.nl/

KvK 27164984

P Please consider the environment before printing this mail.
De informatie - verzonden in of met dit e-mailbericht - is afkomstig van 
Daidalos BV en is uitsluitend bestemd voor de geadresseerde. Indien u dit 
bericht onbedoeld hebt ontvangen, verzoeken wij u het te verwijderen. Aan dit 
bericht kunnen geen rechten worden ontleend.

> From: general-boun...@developer.marklogic.com
> [mailto:general-boun...@developer.marklogic.com] On Behalf Of
> Danny Sokolsky
> Sent: zaterdag 3 april 2010 2:38
> To: General Mark Logic Developer Discussion
> Subject: RE: [MarkLogic Dev General] Unexpected behavior
>
> Right.  And the other point I was trying to make is that if
> the function takes a zero-or-one parameter, such as
> "xs:string?", then it is valid to pass in the empty sequence
> and function mapping will not happen on that parameter.  Here
> is an example:
>
> xquery version "1.0-ml";
>
> declare function local:will-map($x as xs:string) {  $x,
> "function will-map was run"
> };
>
> declare function local:no-map($x as xs:string?) {  $x,
> "function no-map was run"
> };
>
> "function will-map with empty sequence arg:
> ",
> local:will-map(()),
> "function no-map with empty sequence arg:
> ",
> local:no-map(())
>
> =>
> function will-map with empty sequence arg:
>
> function no-map with empty sequence arg:
>
> function no-map was run
>
> Clear as mud?
> -Danny
>
> -----Original Message-----
> From: general-boun...@developer.marklogic.com
> [mailto:general-boun...@developer.marklogic.com] On Behalf Of
> Micah Dubinko
> Sent: Friday, April 02, 2010 5:07 PM
> To: General Mark Logic Developer Discussion
> Subject: Re: [MarkLogic Dev General] Unexpected behavior
>
> Close. :-)
>
> On Apr 2, 2010, at 4:15 PM, spig wrote:
>
> > So, let me make sure I understand.
> >
> > When I declare a function with any number of parameters, if
> one of those parameters requires a singleton, and I pass in
> an empty sequence, the function will not likely be called if
> function mapping is on. This makes sense to me now.
>
> With function mapping enabled, if a function takes a
> singleton argument, and you pass in a sequence, your function
> will be called n times, where n is the length of the
> sequence. This is true even when n is 0.
>
>
> >
> > And, by similar logic, it will not throw an error because
> the function requires a singleton parameter, and I have
> provided one, albeit the empty sequence. And, since the empty
> sequence is a valid singleton (is that true) it will not
> throw an error because the parameters are valid.
>
> Actually, empty sequence is never a valid instance of a
> singleton type. In cases like these the error fails to throw
> not because the parameter is valid, but because the function
> itself never gets called.
>
> This is easy to get mixed up. I still do at times. -m
>
>
> _______________________________________________
> General mailing list
> General@developer.marklogic.com
> http://xqzone.com/mailman/listinfo/general
> _______________________________________________
> General mailing list
> General@developer.marklogic.com
> http://xqzone.com/mailman/listinfo/general
>
_______________________________________________
General mailing list
General@developer.marklogic.com
http://xqzone.com/mailman/listinfo/general

<<winmail.dat>>

_______________________________________________
General mailing list
General@developer.marklogic.com
http://xqzone.com/mailman/listinfo/general

Reply via email to