Loading TOC...

MarkLogic Server 11.0 Product Documentation
xdmp:document-delete

xdmp:document-delete(
   $uri as xs:string,
   [$options as (element()|map:map)?]
) as empty-sequence()

Summary

Deletes a document from the database.

Parameters
uri The URI of the document to be deleted.
options Options with which to customize this operation. You can specify options in either an XML options element in the "xdmp:document-delete" namespace, or as a map:map. The options names below are XML element localnames. When using a map, replace the hyphens with camel casing. For example, "an-option" becomes "anOption" when used as a map:map key. This function supports the following options:
if-not-exists
Action if no document exists with the URI. Valid values are "error" and "allow". Default value is "error". An XDMP-DOCNOTFOUND exception is thrown if the document does not exist when "error" is specified or this option is left unspecified.

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.

Example

xdmp:document-delete("example.xml")

Example

(: Enable deletion of a non-existent document without error, using
 : options expressed as an XML options node. :)
xdmp:document-delete("example.xml",
  <options xmlns="xdmp:document-delete">
    <if-not-exists>allow</if-not-exists>
  </options>)

Example

(: Enable deletion of a non-existent document without error, using
 : options expressed as map:map. :)
xdmp:document-delete("example.xml",
                     map:map() => map:with("ifNotExists", "allow"))

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