XQuery/Changing Permissions on Collections and Resources

Motivation
You want to change permissions on a set of collections and resources.

Method
There are two functions we will use:

For collections: and for resources:

The $perm is a decimal number.

As of 1.5 you can use the function xmldb:string-to-permissions("rwurwu---") to get this decimal number.

Sample to get decimal values for guest permissions
Returns the following

Recursive Script to Remove All Guest Permissions
Warning, this breaks several features. You must run many functions as non-guest.