Collection root = broker.openCollection(TestConstants.TEST_COLLECTION_URI, Lock.READ_LOCK);
assertNotNull(root);
DocumentImpl doc = root.getDocument(broker, XmldbURI.create("test.xml"));
assertNotNull(doc);
Serializer serializer = broker.getSerializer();
serializer.reset();
File tempFile = File.createTempFile("eXist", ".xml");
Writer writer = new OutputStreamWriter(new FileOutputStream(tempFile), "UTF-8");
serializer.serialize(doc, writer);
tempFile.delete();
// XQuery xquery = broker.getXQueryService();
// DocumentSet docs = broker.getAllXMLResources(new DefaultDocumentSet());
// Sequence result = xquery.execute("//key/@id/string()", docs.docsToNodeSet(), AccessContext.TEST);
// assertEquals(KEY_COUNT, result.getItemCount());