MarkLogic Server 11.0 Product Documentation
xdmp:parse-permission

xdmp:parse-permission(
   $perm as xs:string,
   [$output-kind as xs:string]
) as element()|map:map

Summary

Returns a permission element in the security namespace corresponding to the element or object given. This function is in particular useful for converting XQuery-style permissions (element) in JSON-style (object) permissions.

Parameters
perm A permission element or object (output of xdmp:permission())
output-kind The output format. Allowed values: "element" or "object". The default format is "element" (an XML element). When you set this parameter to "object", this function returns a map:map, suitable for inclusion in the options parameter of some builtins. See the Usage Notes for details.

Usage Notes

This function can return either an XML element or a map:map, depending on the output-kind parameter value. Use the map:map form in contexts where you need to embed a permissions object in a map:map that is interchangeable with a JSON object. For example, functions such as xdmp:document-insert and xdmp:document-load enable you to pass either an XML element or a map:map as their options parameters. You would use the "object" form to pass permissions in as part of a map:map options value, and the "element" form to pass permissions in as part of an XML options value.

Example

xquery version "1.0-ml"; 
let $permission-as-object:=xdmp:permission("admin","read","object")
return xdmp:parse-permission($permission-as-object,"element)
 =><sec:permission>
          <sec:capability>read</sec:capability>
          <sec:role-id>8487823278258687528</sec:role-id>Yeah
       </sec:permission>
Powered by MarkLogic Server | Terms of Use | Privacy Policy