Let me complete the palet of alternatives. The xdmp:save is a simple approach. 
It for instance doesn't allow creation of directories. It is possible though to 
batch things a bit and let MarkLogic Server wrap each batch in a zip using 
xdmp:create-zip. I have recently done a quick export using the following code:

let $export-base := 'c:\temp\myexport-part-'
let $count := count(doc())
let $part-size := 1000
let $nrparts := xs:integer(ceiling($count div $part-size))

let $partcounts :=
    for $partnr in (1 to $nrparts)

    let $start := ($part-size * ($partnr - 1)) + 1
    let $end := $part-size * $partnr

    let $docs := doc()[$start to $end]

    let $save :=
        xdmp:save(concat($export-base, $partnr, '.zip'),
            xdmp:zip-create(
                <parts xmlns="xdmp:zip">{
                    for $doc in $docs
                    let $uri := base-uri($doc)
                    return
                        <part>{$uri}</part>
                }</parts>,
                $docs
            )
        )
    return
        count($docs)

return (
    concat('Succesfully exported ', $count, ' files in ', $nrparts, ' parts (', 
sum($partcounts), ' partitems)'),
    xdmp:query-meters()/*:elapsed-time/text()
)

Use xdmp:spawn to dispatch the export batches to the task server and to let 
them run in background.

Kind regards,
Geert

>


Drs. G.P.H. Josten
Consultant


http://www.daidalos.nl/
Daidalos BV
Source of Innovation
Hoekeindsehof 1-4
2665 JZ Bleiswijk
Tel.: +31 (0) 10 850 1200
Fax: +31 (0) 10 850 1199
http://www.daidalos.nl/
KvK 27164984
De informatie - verzonden in of met dit emailbericht - 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: [email protected]
> [mailto:[email protected]] On Behalf Of
> Laurens van den Oever
> Sent: donderdag 6 augustus 2009 16:56
> To: General Mark Logic Developer Discussion
> Subject: Re: [MarkLogic Dev General] Export of XML from Marklogic
>
> Hi Gerald,
>
> I have used xdmp:save for that purpose. For a small database
> you can iterate over all your files but eventually your query
> will timeout. In my case I just split the collection in a few batches.
>
> I would be interested in a pattern to run this type of query
> as a sequence of transactions.
> Maybe someone else can comment on that?
>
> Best regards,
>
> Laurens van den Oever
> Xopus BV
>
> http://xopus.com <http://xopus.com/>  +31 70 4452345 KvK 27301795
>
> 2009/8/6 Goldsmith, Gerald CAR <[email protected]>
>
>
>       Greetings,
>
>       Would anyone be so kind as to inform me how I might
> export XML content from Marklogic to an XML file? If
> possible, I would like to export all of the content to XML files.
>
>       Thanks.
>
>       Best Regards,
>
>
>
>       Gerald Goldsmith
>
>
>
>       Software Applications Engineer
>
>       CAD Architect   Carrier Corporation
>
>       9300 Harris Corners Parkway
>
>       Suite 200
>
>       Charlotte, NC 28269
>
>       704.494.2552
>
>
>       Everything should be made as simple as possible, but
> not simpler.  -  Albert Einstein
>
>
>
>
>
>       _______________________________________________
>       General mailing list
>       [email protected]
>       http://xqzone.com/mailman/listinfo/general
>
>
>
>
>

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

Reply via email to