if(doc.getResourceType() == DocumentImpl.BINARY_FILE) collection.removeBinaryResource(txn, broker, doc); else collection.removeDocument(txn, broker, docName);
if(doc.getResourceType() == DocumentImpl.BINARY_FILE) collection.removeBinaryResource(txn, broker, doc); else collection.removeXMLResource(txn, broker, docName);
    public boolean removeDocument(java.lang.String sessionId, java.lang.String path) throws java.rmi.RemoteException {		Session session = getSession(sessionId);		DBBroker broker = null;        TransactionManager transact = pool.getTransactionManager();        Txn txn = transact.beginTransaction();		try {			broker = pool.get(session.getUser());            //TODO : use dedicated function in XmldbURI			int p = path.lastIndexOf("/");			if (p == Constants.STRING_NOT_FOUND || p == path.length() - 1) {                transact.abort(txn);				throw new EXistException("Illegal document path");            }			String collectionName = path.substring(0, p);			String docName = path.substring(p + 1);			Collection collection = broker.getCollection(collectionName);			if (collection == null) {                transact.abort(txn);				throw new EXistException(					"Collection " + collectionName + " not found");            }			DocumentImpl doc = collection.getDocument(broker, docName);			if(doc == null)				throw new EXistException("Document " + docName + " not found");            			if(doc.getResourceType() == DocumentImpl.BINARY_FILE)				collection.removeBinaryResource(txn, broker, doc);			else				collection.removeDocument(txn, broker, docName);//??				collection.removeXMLResource(txn, broker, docName);                        transact.commit(txn);			return true;		} catch (Exception e) {            transact.abort(txn);			LOG.debug(e.getMessage(), e);			throw new RemoteException(e.getMessage(), e);		} finally {			pool.release(broker);		}	}