Re: [MarkLogic Dev General] how to save multiple documents to file system.

2018-05-10 Thread Damon Feldman
Hi,

I believe you are saving both docs to the file-system with two separate calls. 
I suggest when staring (and even generally) to include the XQuery header:

  declare option xdmp:mapping "false";.

Which will not treat a sequence as an instruction to call a function multiple 
times. That’s what you have now. The comma makes a sequence and then you pass 
that to xdmp:save() which writes *one item* to the file-system. So it loops 
automatically using the “mapping” option and saves twice. Both are saved at the 
same file-name, so you just get one.

But you probably want to save the data into the database. That function is 
xdmp:document-insert($uri, $doc-or-rootNode).l And I suspect you want create a 
new URI in MarkLogic based on the ID or URL attribute.

So try:



xquery version "1.0-ml";
declare namespace html = "http://www.w3.org/1999/xhtml;;
let $docs := (
http://dbfeed.ured/EN0001; mimetype="text/html" last-modified="NA" 
pagerank="NA">




,
http://dbfeed.ured/SP0002; mimetype="text/html" last-modified="NA" 
pagerank="NA">





)

for $d in $docs
let $uri := "/" || substring-after($d/@url, "http://;)
return xdmp:document-insert($uri, $d)


From: general-bounces-dev-marklogic <general-boun...@developer.marklogic.com> 
on behalf of Ly CafeSua <thich...@gmail.com>
Reply-To: MarkLogic Discussion <general@developer.marklogic.com>
Date: Thursday, May 10, 2018 at 1:42 PM
To: MarkLogic Discussion <general@developer.marklogic.com>
Subject: [MarkLogic Dev General] how to save multiple documents to file system.

Hello all,

I am new to Marklogic and would like to learn how to save document nodes to 
server.  I have a sample code but it always save a last record has "SP0002".  
How can I save both records.  Thanks in advance.



xquery version "1.0-ml";
declare namespace html = "http://www.w3.org/1999/xhtml;;
let $doc := (
 http://dbfeed.ured/EN0001; mimetype="text/html" 
last-modified="NA" pagerank="NA">
 
  
  
 
  ,
  http://dbfeed.ured/SP0002; mimetype="text/html" 
last-modified="NA" pagerank="NA">
  
 
 
   
  
  )

return xdmp:save("/output/mdr/xml/data2016.xml",$doc)
___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general


[MarkLogic Dev General] how to save multiple documents to file system.

2018-05-10 Thread Ly CafeSua
Hello all,

I am new to Marklogic and would like to learn how to save document nodes to
server.  I have a sample code but it always save a
last record has "SP0002".  How can I save both records.  Thanks in advance.



xquery version "1.0-ml";
declare namespace html = "http://www.w3.org/1999/xhtml;;
let $doc := (
 http://dbfeed.ured/EN0001; mimetype="text/html"
last-modified="NA" pagerank="NA">
 
  
  
 
  ,
  http://dbfeed.ured/SP0002; mimetype="text/html"
last-modified="NA" pagerank="NA">
  
 
 
   
  
  )

return xdmp:save("/output/mdr/xml/data2016.xml",$doc)
___
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general