try {
// get each result
ResourceIterator ri = resources.getIterator();
while (ri.hasMoreResources()) {
XMLResource res = (XMLResource)ri.nextResource();
// get the result's document name (the query result just contains content as selected by the xpath query)
String id = res.getDocumentId();
log.trace("Query matched document: " + IdToName(id));
Document policyDoc = m_policyReader.readPolicy(((String)m_collection.getResource(id).getContent()).getBytes("UTF-8"));
documents.put(IdToName(id), handleDocument(policyDoc, policyFinder));