Ok, I think I might have come up with something:

 

This xquery will copy the a full directory and the properties of the
directory and the documents underneath to another directory. Can anyone
tell me if I'm going down the right path?

 

(: buffer 2 :)

let $baseUri := "/urn:project-domain-model:result-set/"

let $userId := "punnooser- project "

let $oldResultId := 37567

let $newResultId := 37570

let $oldDirectoryUri := fn:concat($baseUri, $userId,"/",
$oldResultId,"/")

let $newDirectoryUri := fn:concat($baseUri, $userId,"/",
$newResultId,"/")

 

(:Create directory:)

let $createDir := xdmp:directory-create($newDirectoryUri,
xdmp:default-permissions(), $newDirectoryUri)

 

(:Load directory properties:)

let $props := xdmp:document-properties($oldDirectoryUri)

let $propsDirIns := xdmp:document-set-properties($newDirectoryUri,
$props/*/*)

 

for $d in xdmp:directory($oldDirectoryUri)

let $uri := xdmp:node-uri($d)

let $propsDoc := xdmp:document-properties($uri)

let $newDocUri := fn:replace($uri, $oldDirectoryUri, $newDirectoryUri)

 

(:Load documents and properties:)

let $ins := xdmp:document-insert($newDocUri, $d,
xdmp:default-permissions(), $newDirectoryUri)

let $propsIns := xdmp:document-set-properties($newDocUri, $propsDoc/*/*)

 

return $newDocUri

 

Roshan Punnoose

Phone: 301-497-6039

________________________________

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Punnoose,
Roshan
Sent: Thursday, September 20, 2007 9:21 AM
To: General Mark Logic Developer Discussion
Subject: RE: [MarkLogic Dev General] Re: General Digest, Vol 39, Issue 8

 

Is there an example of the XQuery that I could write to perform a copy
of a directory?

 

Roshan Punnoose

Phone: 301-497-6039

________________________________

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Kelly
Stirman
Sent: Wednesday, September 19, 2007 3:58 PM
To: general@developer.marklogic.com
Subject: [MarkLogic Dev General] Re: General Digest, Vol 39, Issue 8

 

I think that, if the directory isn't too large, it will work via webDAV
as well as a simple directory rename or rename + cut and paste the
directory.

It is also possible to write this in XQuery.

Kelly

----- Original Message -----
From: [EMAIL PROTECTED]
<[EMAIL PROTECTED]>
To: general@developer.marklogic.com <general@developer.marklogic.com>
Sent: Wed Sep 19 12:00:02 2007
Subject: General Digest, Vol 39, Issue 8

Send General mailing list submissions to
        general@developer.marklogic.com

To subscribe or unsubscribe via the World Wide Web, visit
        http://xqzone.com/mailman/listinfo/general
or, via email, send a message with subject or body 'help' to
        [EMAIL PROTECTED]

You can reach the person managing the list at
        [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of General digest..."


Today's Topics:

   1. Copy directory and properties (Punnoose, Roshan)
   2. Re: Copy directory and properties (Michael Blakeley)


----------------------------------------------------------------------

Message: 1
Date: Wed, 19 Sep 2007 14:04:32 -0400
From: "Punnoose, Roshan" <[EMAIL PROTECTED]>
Subject: [MarkLogic Dev General] Copy directory and properties
To: <general@developer.marklogic.com>
Message-ID:
        <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="us-ascii"

Skipped content of type multipart/alternative-------------- next part
--------------
A non-text attachment was scrubbed...
Name: Punnoose, Roshan.vcf
Type: text/x-vcard
Size: 179 bytes
Desc: Punnoose, Roshan.vcf
Url : 
http://xqzone.marklogic.com/pipermail/general/attachments/20070919/34c5b
7d1/PunnooseRoshan-0001.vcf

------------------------------

Message: 2
Date: Wed, 19 Sep 2007 11:51:20 -0700
From: Michael Blakeley <[EMAIL PROTECTED]>
Subject: Re: [MarkLogic Dev General] Copy directory and properties
To: General Mark Logic Developer Discussion
        <general@developer.marklogic.com>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="utf-8"

You could probably do that using XQSync, or you could certainly use
corb. Both are at http://developer.marklogic.com/code/

-- Mike

Punnoose, Roshan wrote:
> Is it possible to copy all the contents of a directory and properties
> and save it as another directory?
>
> 
>
> Roshan Punnoose
>
> Phone: 301-497-6039
>
> 
>
>
>
>
>
------------------------------------------------------------------------
>
> _______________________________________________
> General mailing list
> General@developer.marklogic.com
> http://xqzone.com/mailman/listinfo/general

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 4532 bytes
Desc: S/MIME Cryptographic Signature
Url : 
http://xqzone.marklogic.com/pipermail/general/attachments/20070919/54ff7
9e9/smime-0001.bin

------------------------------

_______________________________________________
General mailing list
General@developer.marklogic.com
http://xqzone.com/mailman/listinfo/general


End of General Digest, Vol 39, Issue 8
**************************************

BEGIN:VCARD
VERSION:2.1
N:Punnoose;Roshan
FN:Punnoose, Roshan
ADR;WORK:;2115
LABEL;WORK:2115
EMAIL;PREF;INTERNET:[EMAIL PROTECTED]
REV:20050413T183207Z
END:VCARD
_______________________________________________
General mailing list
General@developer.marklogic.com
http://xqzone.com/mailman/listinfo/general

Reply via email to