
xdmp:directory-create( $uri as xs:string, [$permissions as element(sec:permission)*], [$collections as xs:string*], [$quality as xs:int?], [$forest-ids as xs:unsignedLong*], [$options as (element()|map:map)?] ) as empty-sequence()
Creates a directory. If security is enabled, the document permissions and collections are set to the given parameters, if supplied. Otherwise, the current user's default permissions and/or collections are applied. If the beginning of the document URI is protected, the user must have access to that URI privilege. If the directory URI does not end with a '/' one is added. If the directory already exists, then an XDMP-DIREXISTS exception is thrown.
xdmp:directory-create("http://marklogic.com/a/",
(xdmp:permission("development", "update"),
xdmp:permission("qa", "read")),
"http://marklogic.com/directories")
=> Creates a directory named "http://marklogic.com/a/",
which has the parent directory "http://marklogic.com/".
The directory is created with the specified permissions,
and is added to the "http://marklogic.com/directories"
collection.
xdmp:directory-create("/dir/myDirectory/")
=> Creates a directory named "/dir/myDirectory/",
which has the parent directory "/dir/", which
in turn has parent directory "/". If
directory creation is set to automatic in
the database configuration, this example creates
all three directories ("/", "/dir/", and
"/dir/myDirectory/").
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.