Hi Devesh,

XQuery specification allows lazy evaluation, and MarkLogic makes heavy use of 
that. Just don’t put the call to your init function in a declare variable, but 
simply call it before the local:test. Something like:

let $init := local:initialize-variables()
return
local:test()

Cheers,
Geert

From: 
<[email protected]<mailto:[email protected]>>
 on behalf of "Tyagi, Devesh" <[email protected]<mailto:[email protected]>>
Reply-To: MarkLogic Developer Discussion 
<[email protected]<mailto:[email protected]>>
Date: Monday, July 27, 2015 at 9:55 AM
To: "[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Subject: [MarkLogic Dev General] XQuery evaluation


Hi,


I have the following piece of code in XQuery:


declare variable $triple-predicate-prefix := "http://www.bsi.org/predicates/";;

declare variable $triple-predicate-suffix-hasTaxonomyName := "hasTaxonomyName";


declare variable $triple-predicates-map := map:map();

declare variable $initialize-variables-caller := local:initialize-variables();


declare function local:initialize-variables(){

let $_ := 
map:put($triple-predicates-map,$triple-predicate-suffix-hasTaxonomyName,fn:concat($triple-predicate-prefix,$triple-predicate-suffix-hasTaxonomyName))

return ()

};


declare local:test(){

map:get($triple-predicates-map,$triple-predicate-suffix-hasTaxonomyName)

};


local:test()


This returns me and empty sequence. The map doesn't get initialized. It would 
be helpful if someone could point me towards the reason and solution behind it.


Thanks and 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."
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to