Skip to main content

Administrating MarkLogic Server

Properties and URIs of Directories

A directory is stored as a properties document in a MarkLogic Server database. Like a document, a directory has a URI, but the URI must end in a forward slash (/). Use the xdmp:document-properties("uri_name") function to retrieve the properties document for a URI, or xdmp:document-properties() to retrieve all of the properties documents in the database.

Properties are in the http://marklogic.com/xdmp/property namespace. When you create a directory (either automatically or manually), the system creates a properties document in the database with a child element named directory. For example, if you have a directory in your database with a URI /myCompany/marketing/, the following query return the following results:

xdmp:document-properties("/myServer/Marketing/")
=>
<prop:properties xmlns:prop="http://marklogic.com/xdmp/property">
   <prop:directory/>
</prop:properties>

The properties document returned does not contain the URI of the directory, but just an empty element (prop:directory) indicating the existence of a directory.

xdmp:document-properties() returns the properties documents for all documents in the database. Whenever there is a directory element in the properties document, there is a directory in the database, and calling xdmp:node-uri() on that element returns the URI of the directory. For example, the following query returns the URIs for all of the directories in a database:

declare namespace prop="http://marklogic.com/xdmp/property"
for $x in xdmp:document-properties()/prop:properties/prop:directory
return <directory-uri>{xdmp:node-uri($x)}</directory-uri>

Note

It is possible to create a document with a URI that ends in a forward slash (/). To avoid confusion with directory URIs, the best practice is to avoid creating documents with URIs that end in a forward slash.