MarkLogic 9 Product Documentation
dls:document-insert-and-manage

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

Summary

This function inserts a document into the database and places the document under management.

Parameters
uri The URI of the document.
deep Specifies whether to manage this document as well as any documents for which this document has XInclude references to. Specify true to manage all XInclude references or false to not manage any included documents. The default is false.
doc The contents of the document (root node).
annotation Any comments you want to add to the properties.
permissions Security permission elements corresponding to the permissions for the 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, the current user's default permissions are applied. The default value used for $permissions can be obtained by calling xdmp:default-permissions . A document that is created by a non-admin user (that is, by any user who does not have the admin role) must have at least one update permission, otherwise the creation will throw an XDMP-MUSTHAVEUPDATE exception.
collections The collection URIs for collections to which this document belongs. If not supplied, the document is added to the current user's default collections. For each collection that is protected, the user must have permissions to update that collection or have the any-collection privilege. For each unprotected collection, the user must have the unprotected-collections privilege. The default value used for $collections can be obtained by calling xdmp:default-collections .
quality The quality of this 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 this document is inserted. If the document already exists in the database and if $forest-ids is not specified, it will remain in its existing 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 $forest-ids to include one or more forests that allow updates, otherwise an exception is thrown.

Example

  xquery version "1.0-ml"; 

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

  let $contents :=   
    <BOOK>
      <TITLE>Baz Goes to the Disco</TITLE>
      <CHAPTER1>
         <TITLE>Baz Wakes Up to James Brown and Feels Funky</TITLE>
      </CHAPTER1>
    </BOOK> 

   return
      dls:document-insert-and-manage(
         "/foo/bar/baz.xml",
         fn:true(),
         $contents) 

   (: Inserts 'baz.xml' into the database and places the document under management. :)
   
Powered by MarkLogic Server | Terms of Use | Privacy Policy