Loading TOC...


   $uri as xs:string
) as empty-sequence()


Deletes a document from the database.

$uri The URI of the document to be deleted.

Usage Notes

The xdmp:document-delete function deletes a document and all of its properties, except, when directory-creation is set to automatic or manual-enforced, the directory property; it does not delete a directory with the same URI as the document being deleted unless directory-creation is set to manual. To delete a directory, use the xdmp:directory-delete function.

If a document does not exist at the specified URI, xdmp:document-delete throws an error.



Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.


The commenting feature on this page is enabled by a third party. Comments posted to this page are publicly visible.
  • How should i delete a document in memory to avoid conflicting updates with xdmp:document-insert ? temporal:document-delete will be used for some other purpose.
    • Please explain your problem in more detail. and It will be better if you post your question on stack overflow.
  • Jim: why base-uri() instead of document-uri()?
  • to loop through a directory and delete file each you can do something like; for $f in xdmp:directory('/somedirectory/') let $uri := fn:base-uri($f) return xdmp:document-delete($uri)  
  • Corb is a good utility for doing batch deletes http://developer.marklogic.com/code/corb.