NodeImpl node = (NodeImpl)doc.getFirstChild();
NodeImpl node = (NodeImpl)document.getFirstChild();
	public void removeDocument(String docName, boolean freeDocId) throws PermissionDeniedException {		if (readOnly)			throw new PermissionDeniedException(DATABASE_IS_READ_ONLY);		try {			if (!docName.startsWith("/"))				docName = '/' + docName;			final DocumentImpl doc = (DocumentImpl) getDocument(docName);			if (doc == null) {                if (LOG.isDebugEnabled()) {                    LOG.debug("removeDocument(String) - end - document "                        + docName                        + " not found");                }				return;			}            if (LOG.isInfoEnabled()) {                LOG.info("removeDocument() - "                    + "removing document "                    + doc.getDocId()                    + " ...");            }			elementIndex.dropIndex(doc);			textEngine.dropIndex(doc);            if (LOG.isDebugEnabled()) {                LOG.debug("removeDocument() - removing dom");            }			new DOMTransaction(this, domDb) {				public Object start() {				    NodeImpl node = (NodeImpl)doc.getFirstChild();					domDb.removeAll(node.getInternalAddress());					return null;				}			}			.run();						NodeRef ref = new NodeRef(doc.getDocId());			final IndexQuery idx = new IndexQuery(IndexQuery.TRUNC_RIGHT, ref);			new DOMTransaction(this, domDb) {				public Object start() {					try {						domDb.remove(idx, null);						domDb.flush();					} catch (BTreeException e) {                        LOG.warn("start() - " + "error while removing doc", e);					} catch (DBException e) {                        LOG.warn("start() - " + "error while removing doc", e);					} catch (IOException e) {                        LOG.warn("start() - " + "error while removing doc", e);					} catch (TerminatedException e) {                        LOG.warn("method terminated", e);                    }					return null;				}			}			.run();			if(freeDocId)			    freeDocument(doc.getDocId());		} catch (ReadOnlyException e) {            LOG.warn("removeDocument(String) - " + DATABASE_IS_READ_ONLY);		}	}