*/
public Resource getMembersAsResource() throws XMLDBException {
// This impl works but it would be nice if we just got the result set from
// the server in this format instead of having to build it. Right now it's
// pretty innefficient
Document doc = new DocumentImpl();
Element set = doc.createElementNS(RESOURCE_SET_NS, "xapi:resourceSet");
set.setAttributeNS(RESOURCE_SET_NS, "xapi:collectionURI",
"xmldb:xindice://" + ((XindiceCollection) collection).getCanonicalName());
set.setAttribute("xmlns:xapi", RESOURCE_SET_NS);
doc.appendChild(set);
int i = 0;
while (i < resources.size()) {
XMLResource res = (XMLResource) resources.get(i);
Element resource = doc.createElementNS(RESOURCE_SET_NS,
"xapi:resource");
resource.setAttributeNS(RESOURCE_SET_NS, "xapi:documentID",
res.getDocumentId());
resource.appendChild(doc.importNode(
((Document) res.getContentAsDOM()).getDocumentElement(), true));
set.appendChild(resource);
i++;