Skip to content

Instantly share code, notes, and snippets.

@ableasdale
Created June 27, 2014 09:43
Show Gist options
  • Save ableasdale/1a787158e98ec554ea0d to your computer and use it in GitHub Desktop.
Save ableasdale/1a787158e98ec554ea0d to your computer and use it in GitHub Desktop.
MarkLogic/XQuery : Generate an HTML page for all roles all associated privileges with that role
xquery version "1.0-ml";
import module namespace sec="http://marklogic.com/xdmp/security" at
"/MarkLogic/security.xqy";
(xdmp:set-response-content-type("text/html; charset=utf-8"),
'<!DOCTYPE html>',
element html {
element head {
element title {"Role / Privilege mappings for security database version: ", xs:string(//sec:version)}
},
element body {
let $role-names :=
for $i in //sec:role
order by $i/sec:role-name
return $i/sec:role-name
return
for $j in $role-names
return
(
element h2 {xs:string($j)},
element ul {
for $k in sec:role-privileges($j)
order by $k/sec:privilege-name
return element li {xs:string($k/sec:privilege-name)}
}
)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment