Loading TOC...

MarkLogic Server 11.0 Product Documentation
dls:document-update

dls:document-update(
   $uri as xs:string,
   $doc as node(),
   $annotation as item()*,
   $retain-history as xs:boolean,
   [$permissions as item()*],
   [$collections as xs:string*],
   [$quality as xs:integer?],
   [$forest-ids as xs:unsignedLong*]
) as xs:string*

Summary

This function updates the managed document at the specified URI with the specified contents. This function does an implicit dls:document-purge and returns the URI of any version of the document purged as the result of the established retention policy.

This function must be called in a separate transaction from the dls:document-checkout and dls:document-checkin functions.

You must first check out the document with dls:document-checkout before you can update, otherwise an exception is thrown. If the document does not exist, then an exception is thrown.

Parameters
uri The URI of the document.
doc The new contents of the document.
annotation Any comments you want to add to the new versions of the documents.
retain-history Determines whether or not to retain the document's properties fragment in the database. Set to true to retain the original document's properties in order to track when the document was updated and by whom. Otherwise, set to false.
permissions The permissions to be set on the updated document. When run in an XQuery context, the permissions are a sequence of XML elements (sec:permission). When importing this module into a Server-Side JavaScript context, the permissions are an array of Objects. If not supplied, then the existing permissions set for the document remain.
collections The collection URIs for the collections to which the updated document is to belong. If not supplied, then the existing collections set for the document remain.
quality Specifies the quality of the updated document. A positive value increases the relevance score of the document in text search functions. The converse is true for a negative value. The default value is 0.
forest-ids Specifies the ID of the forest in which the updated document is inserted. If this parameter is not specified, the updated document will remain in the original document's forest. If no such forest exists or if no such forest is attached to the context database, an error is raised. If multiple forests are specified, the document is inserted into one of the specified forests. If the document exists and the forest in which it is stored is set to delete-only, then you must set this parameter to include one or more forests that allow updates, otherwise an exception is thrown.

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";

  let $bazbook :=  
  <BOOK>
    <TITLE>Baz Goes to the Disco</TITLE>
    <CHAPTER1>
      <TITLE>Baz Wakes Up</TITLE>
      <PARA>
        Baz woke up this afternoon to the sound of James Brown.  Soon
        Baz was feeling a little funky, so he put on his cleanest
        propeller hat and headed out in search of a Disco.
      </PARA>
    </CHAPTER1>
  </BOOK> 
      
  return
    dls:document-update(
	"/foo/bar/baz.xml",
	$bazbook,
	"Changed the title from Baz Feelin' Funky",
	fn:true())
  
  (: Updates the contents of 'baz.xml'. :)
   

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