Name test6 = nf.create(Name.NS_DEFAULT_URI, "test6");
OutputStream out = resource.getOutputStream();
try {
List<PrivilegeDefinition> defs = new ArrayList<PrivilegeDefinition>();
defs.add(new PrivilegeDefinitionImpl(test, false, createNameSet(test2, test3)));
defs.add(new PrivilegeDefinitionImpl(test2, true, Collections.singleton(test4)));
defs.add(new PrivilegeDefinitionImpl(test3, true, Collections.singleton(test5)));
defs.add(new PrivilegeDefinitionImpl(test4, true, Collections.<Name>emptySet()));
defs.add(new PrivilegeDefinitionImpl(test5, true, Collections.<Name>emptySet()));
// the equivalent definition to 'test'
defs.add(new PrivilegeDefinitionImpl(test6, false, createNameSet(test2, test5)));
PrivilegeDefinitionWriter pdw = new PrivilegeDefinitionWriter("text/xml");
pdw.writeDefinitions(out, defs.toArray(new PrivilegeDefinition[defs.size()]), Collections.<String, String>emptyMap());
new PrivilegeRegistry(superuser.getWorkspace().getNamespaceRegistry(), fs);