This page was generated
August  8,  2011
2:23  AM
XQuery Built-In and Modules Function Reference

Built-In: Extension - Documents, Directories, Properties, and Locks Functions

The Documents, Directories, Properties, and Locks functions are XQuery built-in extension functions that get information from documents, directories, properties, and locks from MarkLogic Server. All of these are stored as fragments in a database.

Function Summary
xdmp:collection-locks Returns locks of documents in a collection.
xdmp:collection-properties Returns a sequence of properties documents, one for each document in the specified collection(s) that has a corresponding properties document.
xdmp:directory Returns the documents in a directory.
xdmp:directory-locks Returns locks of documents in a directory.
xdmp:directory-properties Returns a sequence of properties documents, one for each document in the specified directory that has a corresponding properties document.
xdmp:document-get-properties Returns the property values for a document's property.
xdmp:document-get-quality Returns the quality of the specified document if the document exists.
xdmp:document-locks Returns the locks for one or more documents or directories.
xdmp:document-properties Returns a sequence of properties documents, one for each of the specified documents that has a corresponding properties document.
Function Detail
xdmp:collection-locks(
[$uri as xs:string*]
)  as   document-node()*
Summary:

Returns locks of documents in a collection.

Parameters:
$uri (optional): The input URI.

Example:
  for $d in xdmp:collection-locks(
                     ("http://example.com/col1/",
                      "http://example.com/col2/"))
  return xdmp:node-uri($d)
  => http://example.com/bar.xml 
     http://example.com/baz.xml

xdmp:collection-properties(
[$uri as xs:string*]
)  as   document-node()*
Summary:

Returns a sequence of properties documents, one for each document in the specified collection(s) that has a corresponding properties document.

Parameters:
$uri (optional): The URI(s) of the collection(s).

Example:
  xquery version "0.9-ml"
  declare namespace cpf="http://marklogic.com/cpf"

  for $d in xdmp:collection-properties(
                   ("http://example.com/col1/",
                    "http://example.com/col2/"))
  where $d/property::cpf:error
  return xdmp:node-uri($d)

  => A list of document URIs of documents that have a 
        cpf:error property in their corresponding properties 
	documents.  For example:

      http://example.com/bar.xml http://example.com/baz.xml

xdmp:directory(
$uri as xs:string*,
[$depth as xs:string?]
)  as   document-node()*
Summary:

Returns the documents in a directory.

Parameters:
$uri : The URI of the directory. Typically, directory URIs end with a forward slash (/).
$depth (optional): "1" for immediate children, "infinity" for all. If not supplied, depth is "1".

Example:
  for $d in xdmp:directory("http://example.com/foo/","1")
  return xdmp:node-uri($d)
  => http://example.com/foo/bar.xml 
     http://example.com/foo/baz.xml

xdmp:directory-locks(
$uri as xs:string*,
[$depth as xs:string?]
)  as   document-node()*
Summary:

Returns locks of documents in a directory.

Parameters:
$uri : The URI of the directory. Typically, directory URIs end with a forward slash (/).
$depth (optional): "1" for immediate children, "infinity" for all. If not supplied, depth is "1".

Example:
  for $d in xdmp:directory-locks("http://example.com/foo/","1")
  return xdmp:node-uri($d)
  => http://example.com/foo/bar.xml 
     http://example.com/foo/baz.xml

xdmp:directory-properties(
$uri as xs:string,
[$depth as xs:string?]
)  as   document-node()*
Summary:

Returns a sequence of properties documents, one for each document in the specified directory that has a corresponding properties document.

Parameters:
$uri : The URI of the directory. Typically, directory URIs end with a forward slash (/).
$depth (optional): "1" for immediate children, "infinity" for all children. If not supplied, depth is "1".

Example:
  xdmp:directory-properties("http://example.com/dir/","1")
  => <prop:properties 
            xmlns:prop="http://marklogic.com/xdmp/property">
         <prop:directory/>
     </prop:properties>
   

The properties document returned has one directory element, indicating that there is a single directory that is an immediate child of the specified directory.


xdmp:document-get-properties(
$uri as xs:string,
$property as xs:QName
)  as   element()*
Summary:

Returns the property values for a document's property.

Parameters:
$uri : The document URI.
$property : The property name. This is the QName of the top-level property element in the specified properties document.

Example:
  xdmp:document-get-properties(
         "http://example.com/foo.xml",
         fn:QName("http://examples.com/","priority"))
   => <priority xmlns="http://examples.com/">5</priority>

xdmp:document-get-quality(
$uri as xs:string
)  as   xs:integer?
Summary:

Returns the quality of the specified document if the document exists. Otherwise, returns the empty sequence.

Parameters:
$uri : The URI of the document in question.

Example:
  xdmp:document-get-quality("example.xml")
  => 10

xdmp:document-locks(
[$uri as xs:string*]
)  as   document-node()*
Summary:

Returns the locks for one or more documents or directories. Returns the locks for all documents and directories in the database if no parameter is given.

Parameters:
$uri (optional): A document URI.

Example:
  xdmp:document-locks("example.xml")
  => <lock:lock>
          <lock:active-locks>
            <lock:active-lock>
              <lock:lock-type>write</lock:lockt-ype>
              <lock:lock-scope>exclusive</lock:lock-scope>
              <lock:depth>infinity</lock:depth>
              <lock:owner>
                http://example.com/~user
              </lock:owner>
              <lock:timeout>5000</lock:timeout>
              <lock:lock-token>
                  http://marklogic.com/xdmp/locks/e71d4fae
              </lock:lock-token>
              <lock:timestamp>5234768</lock:timestamp>
              <sec:user-id>52378234768</sec:user-id>
            </lock:active-lock>
          </lock:active-locks>
        </lock:lock>

xdmp:document-properties(
[$uri as xs:string*]
)  as   document-node()*
Summary:

Returns a sequence of properties documents, one for each of the specified documents that has a corresponding properties document. If no documents are specified, returns a sequence of properties documents for all documents in the database that have a corresponding properties document.

Parameters:
$uri (optional): A sequence of document URIs.

Example:
  xdmp:document-properties()
    => 
    <prop:properties 
          xmlns:prop="http://marklogic.com/xdmp/property">
    Property Node1
    </prop:properties>
    <prop:properties 
          xmlns:prop="http://marklogic.com/xdmp/property">
    Property Node2
    </prop:properties>
    <prop:properties 
          xmlns:prop="http://marklogic.com/xdmp/property">
    Property NodeN
    </prop:properties>