xquery version "1.0-ml";
(:
https://developer.marklogic.com/recipe/move-a-document/
:)
declare function local:renameFile($uri as xs:string, $new as xs:string) {
xdmp:log($uri || " => " || $new),
let $lock := ($uri, $new) ! xdmp:lock-for-update(.)
let $prop-ns := fn:namespace-uri-from-QName(xs:QName("prop:properties"))
let $properties :=
xdmp:document-properties($uri)/node()/node()
[ fn:namespace-uri(.) ne $prop-ns ]
return (
xdmp:document-insert(
$new,
fn:doc($uri),
xdmp:document-get-permissions($uri),
xdmp:document-get-collections($uri)
),
xdmp:document-delete($uri),
xdmp:document-set-properties($new, $properties)
)
};
for $uri as xs:string in cts:uri-match("directory-in-marklogic/*.xml")
let $new as xs:string := "/" || $uri
return
local:renameFile($uri, $new)
Export this post to PDF document