Hi Andreas,

I think I found the related bug. It is listed for next patch release, but it 
has a lower priority, so could get pushed back. It did report another 
workaround if that helps:

xquery version "1.0-ml";
declare variable $param as xs:string external;
declare variable $param2 := $param;

declare function local:func() {
    xdmp:log("value: " || $param2)
};

xdmp:spawn-function(function() { local:func() })

Haven’t tested myself, and not sure if it is of any help to you..

Cheers,
Geert

From: 
<[email protected]<mailto:[email protected]>>
 on behalf of Andreas Hubmer 
<[email protected]<mailto:[email protected]>>
Reply-To: MarkLogic Developer Discussion 
<[email protected]<mailto:[email protected]>>
Date: Monday, June 20, 2016 at 3:52 PM
To: MarkLogic Developer Discussion 
<[email protected]<mailto:[email protected]>>
Subject: Re: [MarkLogic Dev General] XDMP-EXTVAR with xdmp:spawn-function and 
external variables

Hi,

Can you tell me when the bug described below will be fixed?
We've stumbled upon it again (in the latest MarkLogic version)...

Thanks,
Andreas


2015-12-15 0:07 GMT+01:00 Danny Sokolsky 
<[email protected]<mailto:[email protected]>>:
Yes, this is a bug.  We are already tracking it internally, but it is not yet 
fixed.

Thanks,
-Danny

From:[email protected]<mailto:[email protected]>
 
[mailto:[email protected]<mailto:[email protected]>]
 On Behalf Of Andreas Hubmer
Sent: Monday, December 14, 2015 8:45 AM
To: MarkLogic Developer Discussion
Subject: [MarkLogic Dev General] XDMP-EXTVAR with xdmp:spawn-function and 
external variables

Hi,

It seems that I've found a bug concerning spawned functions and external 
variables.

In a module with an external variable I spawn a function. The spawned function 
calls another function which fails with XDMP-EXTVAR when accessing the external 
variable.
Here is a small example (main.xqy):
xquery version "1.0-ml";
declare variable $param as xs:string external;

declare function local:func() {
    xdmp:log("value: " || $param)
};

xdmp:spawn-function(function() { local:func() })


I call main.xqy using the following snippet:
xquery version "1.0-ml";
xdmp:invoke("main.xqy", (xs:QName("param"), "foo"))

This leads to the following error:

XDMP-EXTVAR: (err:XPDY0002) declare variable $param as xs:string external;  -- 
Undefined external variable fn:QName("","param")
I've also found out that accessing the external variable directly in the 
spawned function works. Working version of main.xqy:
xquery version "1.0-ml";
declare variable $param as xs:string external;

xdmp:spawn-function(function() { xdmp:log("value: " || $param) })

Regards,
Andreas

--
Andreas Hubmer
IT Consultant


_______________________________________________
General mailing list
[email protected]<mailto:[email protected]>
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general




--
Andreas Hubmer
Senior IT Consultant

EBCONT enterprise technologies GmbH
Millennium Tower
Handelskai 94-96
A-1200 Vienna

OUR TEAM IS YOUR SUCCESS

UID-Nr. ATU68135644
HG St.Pölten - FN 399978 d
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to