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));				Sequence contentSeq = value.eval(contextSequence);		if (contentSeq.getLength() == 0)			throw new XPathException(getASTNode(), Messages.getMessage(Error.UPDATE_EMPTY_CONTENT));		contentSeq = deepCopy(contentSeq);		try {            NodeImpl ql[] = selectAndLock(inSeq.toNodeSet());            IndexListener listener = new IndexListener(ql);            NodeImpl node;            Item temp;            TextImpl text;            AttrImpl attribute;            ElementImpl 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();                doc.setIndexListener(listener);                modifiedDocs.add(doc);                collection = doc.getCollection();                if (!doc.getPermissions().validate(context.getUser(),                        Permission.UPDATE))                        throw new PermissionDeniedException(                                "permission to update document denied");                if (prevCollection != null && collection != prevCollection)                        doc.getBroker().saveCollection(prevCollection);                parent = (ElementImpl) node.getParentNode();                switch (node.getNodeType()) {                    case Node.ELEMENT_NODE:                        temp = contentSeq.itemAt(0);						if (!Type.subTypeOf(temp.getType(), Type.NODE))							throw new XPathException(getASTNode(),									Messages.getMessage(Error.UPDATE_REPLACE_ELEM_TYPE,											Type.getTypeName(temp.getType())));                        parent.replaceChild(((NodeValue)temp).getNode(), node);                        break;                    case Node.TEXT_NODE:                         text = new TextImpl(contentSeq.getStringValue());                        text.setOwnerDocument(doc);                        parent.updateChild(node, text);                        break;                    case Node.ATTRIBUTE_NODE:                        AttrImpl attr = (AttrImpl) node;                        attribute = new AttrImpl(attr.getQName(), contentSeq.getStringValue());                        attribute.setOwnerDocument(doc);                        parent.updateChild(node, attribute);                        break;                    default:                        throw new EXistException("unsupported node-type");                }                doc.setLastModified(System.currentTimeMillis());                prevCollection = collection;            }            if (doc != null) doc.getBroker().saveCollection(collection);            checkFragmentation(modifiedDocs);        } catch (LockException e) {			// TODO Auto-generated catch block			e.printStackTrace();		} catch (PermissionDeniedException e) {			// TODO Auto-generated catch block			e.printStackTrace();		} catch (XPathException e) {			// TODO Auto-generated catch block			e.printStackTrace();		} catch (EXistException e) {			// TODO Auto-generated catch block			e.printStackTrace();		} finally {            unlockDocuments();        }		return Sequence.EMPTY_SEQUENCE;	}