doc.setIndexListener(listener);
doc.getMetadata().setIndexListener(listener);
    public long process(Txn transaction) throws PermissionDeniedException, LockException,            EXistException, XPathException {        NodeList children = content;        if (children.getLength() == 0) return 0;        int modificationCount = 0;        try {            StoredNode[] ql = selectAndLock();            DocumentImpl doc = null;            DocumentSet modifiedDocs = new DocumentSet();            NodeImpl node;            NodeImpl parent;            IndexListener listener = new IndexListener(ql);            NotificationService notifier = broker.getBrokerPool().getNotificationService();            String newName = children.item(0).getNodeValue();            for (int i = 0; i < ql.length; i++) {                node = ql[i];                doc = (DocumentImpl) node.getOwnerDocument();                if (!doc.getPermissions().validate(broker.getUser(),                        Permission.UPDATE))                        throw new PermissionDeniedException(                                "permission denied to update document");                doc.setIndexListener(listener);                modifiedDocs.add(doc);                parent = (NodeImpl) node.getParentNode();                switch (node.getNodeType()) {                    case Node.ELEMENT_NODE:                        ElementImpl newElem = new ElementImpl((ElementImpl) node);                        newElem.setNodeName(new QName(newName, "", null));                        parent.updateChild(transaction, node, newElem);                        modificationCount++;                        break;                    case Node.ATTRIBUTE_NODE:                        AttrImpl newAttr = new AttrImpl((AttrImpl) node);                        newAttr.setNodeName(new QName(newName, "", null));                        parent.updateChild(transaction, node, newAttr);                        modificationCount++;                        break;                    default:                        throw new EXistException("unsupported node-type");                }                doc.clearIndexListener();                doc.setLastModified(System.currentTimeMillis());                broker.storeDocument(transaction, doc);                notifier.notifyUpdate(doc, UpdateListener.UPDATE);            }            checkFragmentation(transaction, modifiedDocs);        } finally {            unlockDocuments();        }        return modificationCount;    }