Skip to content

Instantly share code, notes, and snippets.

@ableasdale
Created December 11, 2020 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ableasdale/450cd159db4c4c12c122c84bb38d35cf to your computer and use it in GitHub Desktop.
Save ableasdale/450cd159db4c4c12c122c84bb38d35cf to your computer and use it in GitHub Desktop.
MarkLogic: Remove a problem directory fragment in an event where you encounter XDMP-DBDUPURI issues
xquery version "1.0-ml";
(:
A Utility module to allow the deletion of a directory fragment in a given forest in the event of
an XDMP-DBDUPURI exception.
:)
let $doc := "/" (: URI for the conflicting directory that is causing an XDMP-DBDUPURI to be reported in 2 forests :)
let $forest-name := "forest_00" (: The name of the forest from which the problem directory fragment should be removed :)
let $query :=
'xquery version "1.0-ml";
declare variable $URI as xs:string external;
xdmp:node-delete(xdmp:document-properties($URI))'
let $options := <options xmlns="xdmp:eval"><database>{xdmp:forest($forest-name)}</database></options>
return xdmp:eval($query,(xs:QName("URI"),$doc),$options)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment