Loading TOC...

MarkLogic 9 Product Documentation
dls:document-purge

dls:document-purge(
   $uri as xs:string,
   $delete as xs:boolean,
   $retain-history as xs:boolean
) as xs:string*

Summary

This function deletes all numbered versions of the specified managed document and its referenced documents, as specified by the retention policies set by dls:retention-rule . The document versions are deleted if they have no retention rule causing them to be kept and if they are not included by documents that cannot yet be deleted. If $delete is false, the document's versions are not actually deleted and instead a list of the documents that would have been deleted is returned.

If you set $retain-history to true, you can use xdmp:document-properties to view the deleted document's properties fragment in the database.

Parameters
uri The URI of the document to be purged.
delete Determines whether or not to delete the documents. Set to true to remove the documents or false to list which documents would have been deleted.
retain-history Determines whether to retain the deleted document's property fragment in the database. Set to true to retain the property fragment, or false to delete.

Required Privileges

The dls-user role is required to run this function, or the privilege:
http://marklogic.com/xdmp/privileges/dls-user

Example

  xquery version "1.0-ml";

  import module namespace dls = "http://marklogic.com/xdmp/dls" 
      at "/MarkLogic/dls.xqy";

  dls:document-purge("/foo/bar/baz.xml", fn:false(), fn:true())

  (: Returns the versions of the 'baz.xml' document and its referenced 
     documents, as specified by the retention policy. :)   
    

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