Note also that xdmp:spawn does not run the module,
it simply schedules it to be run, at some time in the
future, on the Task Server.  It does not wait for the
module to run.

   So your "Files Loaded" string is produced immediately
(xdmp:spawn always returns immediately), not after the
"load.xqy" module has loaded the file.  That's why you
saw the message, but as Danny pointed out, the module
was erroring out because you didn't pass it the required
external variable.

   You probably want to use xdmp:invoke, rather than
xdmp:spawn.  That will give you the behavior that you
seem to be expecting.

On Sep 15, 2008, at 11:25 AM, Danny Sokolsky wrote:

Hi,

It looks like you are not passing anything into your call to xdmp:spawn. You need to pass in the external variable $x along with its value (that you are getting from your FLOWR). Note that it is not the same as the $x from your load.xqy module, as those two modules run in different contexts.

Something like:

xdmp:spawn(“loadFile.xqy”,  (xs:QName(“x”), $x))

-Danny

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] ] On Behalf Of Vijayasekar Palaniswamy
Sent: Monday, September 15, 2008 7:33 AM
To: General Mark Logic Developer Discussion
Subject: [MarkLogic Dev General] Fileuploading using spawn

Hello,

This is the code, I am using to upload files. It gives output message as "Files Uploaded" but i didn't see any files uploaded into ML db.
Any correction in the code?

(: load.xqy :)

let $contentdir := "C:\sam2"
return (
for $x in xdmp:filesystem-directory($contentdir)//dir:pathname/text()
   [ends-with(lower-case(.), ".xml")]

return (

try {
  xdmp:spawn("loadFile.xqy"), "Files Uploaded"
}
catch ($err) {
  $err
}
)
)

(: loadFile.xqy :)

define variable $x as xs:string external
define variable $contentDir as xs:string {"C:\sam2"}

xdmp:document-load($x,
  <options xmlns="xdmp:document-load">
    <uri>{fn:concat("/sam/mcd/",
fn:substring-after($x, fn:concat($contentDir, "\")))}</uri>
    <repair>full</repair>
            <forests>
         <forest>{xdmp:forest("test")}</forest>
    </forests>
            <encoding>ISO-8859-1</encoding>
  </options>)


--
Regards,

Vijayasekar. P,
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

---
Ron Hitchens [EMAIL PROTECTED]  650-655-2351




_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to