e.printStackTrace();
throw new XPathException(getASTNode(), e.getMessage(), e);
	public Sequence eval(Sequence contextSequence, Item contextItem)			throws XPathException {		if (contextItem != null)			contextSequence = contextItem.toSequence();		Sequence inSeq = select.eval(contextSequence);		if (inSeq.getLength() == 0)			return Sequence.EMPTY_SEQUENCE;		if (!Type.subTypeOf(inSeq.getItemType(), Type.NODE))			throw new XPathException(getASTNode(), Messages.getMessage(Error.UPDATE_SELECT_TYPE));		try {            NodeImpl[] ql = selectAndLock(inSeq.toNodeSet());            IndexListener listener = new IndexListener(ql);            NodeImpl node;            Node parent;            DocumentImpl doc = null;            Collection collection = null, prevCollection = null;            DocumentSet modifiedDocs = new DocumentSet();            for (int i = 0; i < ql.length; i++) {                node = ql[i];                doc = (DocumentImpl) node.getOwnerDocument();                if (!doc.getPermissions().validate(context.getUser(),                        Permission.UPDATE))                        throw new PermissionDeniedException(                                "permission to remove document denied");                collection = doc.getCollection();                if (prevCollection != null && collection != prevCollection)                        context.getBroker().saveCollection(prevCollection);                doc.setIndexListener(listener);                modifiedDocs.add(doc);                parent = node.getParentNode();                if (parent.getNodeType() != Node.ELEMENT_NODE) {                    LOG.debug("parent = " + parent.getNodeType() + "; " + parent.getNodeName());                    throw new XPathException(getASTNode(),                            "you cannot remove the document element. Use update "                                    + "instead");                } else                    parent.removeChild(node);                doc.clearIndexListener();                doc.setLastModified(System.currentTimeMillis());                prevCollection = collection;            }            if (doc != null) context.getBroker().saveCollection(collection);            checkFragmentation(modifiedDocs);        } catch (EXistException e) {			// TODO Auto-generated catch block			e.printStackTrace();		} catch (PermissionDeniedException e) {			// TODO Auto-generated catch block			e.printStackTrace();		} catch (LockException e) {			// TODO Auto-generated catch block			e.printStackTrace();		} catch (XPathException e) {			// TODO Auto-generated catch block			e.printStackTrace();		} finally {            unlockDocuments();        }		return Sequence.EMPTY_SEQUENCE;	}