Create the Documents and Add Permissions
- Last Updated: April 14, 2026
- 2 minute read
- MarkLogic Server
- Version 10.0
- Documentation
Using the MarkLogic Server Query Console, add a document for each combination of permissions in the following table:
Document |
Permissions (Role, Capability) |
Users with Access |
|---|---|---|
|
( ( ( ( ( ( ( ( |
Don |
|
( ( ( ( |
Don and Ellen |
|
( ( |
All users |
|
( ( ( ( ( |
Frank, Don, Ellen |
|
( ( ( ( |
Ellen, Hannah |
-
You can use XQuery code similar to the following example to insert the sample documents into a database of your choice. This code adds a document with a URI of
doc1.xml, containing one<a>element and a set of five permissions.<a name="UUID-57cfc4c5-104a-6508-f978-6a3513780b2e_id8791b684-f7c2-4ff8-b9c4-9049fd94cac0" id="UUID-57cfc4c5-104a-6508-f978-6a3513780b2e_id8791b684-f7c2-4ff8-b9c4-9049fd94cac0"/>xquery version "1.0-ml"; declare namespace html = "http://www.w3.org/1999/xhtml"; xdmp:document-insert( "/doc1.xml", <a>This is document 1.</a>, (xdmp:permission("can-read", "read"), xdmp:permission("can-read", "update"), xdmp:permission("US", "read"), xdmp:permission("US", "update"), xdmp:permission("Executive", "read"), xdmp:permission("Executive", "update"), xdmp:permission("top-secret", "read"), xdmp:permission("top-secret", "update")))
The `doc1.xml` document can only be read by `Don` because the permissions designate all three compartments and `Don` is the only user with a role in all three of the necessary compartmented roles `Executive`, `US`, and `top-secret`, plus the basic `can-read` role.
2. Create the rest of the sample documents changing the sample code as needed. You need to change the document URI and the text to correspond to `doc2.xml`, `doc3.xml`, `doc4.xml`, and `doc5.xml` and modify the permissions for each document as suggested in the table in [Create the Documents and Add Permissions](create-the-documents-and-add-permissions.html "Create the Documents and Add Permissions").