attribute = new AttrImpl(attr.getQName(), temp.getNodeValue());
if (children.getLength() != 0) { temp = children.item(0); attribute = new AttrImpl(attr.getQName(), temp.getNodeValue()); } else { result = 1; attribute = new AttrImpl(attr.getQName(), ""); }
	public long process() throws PermissionDeniedException, EXistException, XPathException {		NodeImpl[] qr = select(docs);		NodeList children = content.getChildNodes();		if (qr == null || children.getLength() == 0)			return 0;		IndexListener listener = new IndexListener(qr);		NodeImpl node;		Node temp;		TextImpl text;		AttrImpl attribute;		ElementImpl parent;		DocumentImpl doc = null;		Collection collection = null, prevCollection = null;		for (int i = 0; i < qr.length; i++) {			node = qr[i];			doc = (DocumentImpl) node.getOwnerDocument();			doc.setIndexListener(listener);			collection = doc.getCollection();			if (!doc.getPermissions().validate(broker.getUser(), Permission.UPDATE))				throw new PermissionDeniedException("permission to update document denied");			if(prevCollection != null && collection != prevCollection)				doc.getBroker().saveCollection(prevCollection);			switch (node.getNodeType()) {				case Node.ELEMENT_NODE :					((ElementImpl) node).update(children);					break;				case Node.TEXT_NODE :					parent = (ElementImpl)node.getParentNode();					temp = children.item(0);					text = new TextImpl(temp.getNodeValue());					text.setOwnerDocument(doc);					parent.updateChild(node, text);					break;				case Node.ATTRIBUTE_NODE :					parent = (ElementImpl)node.getParentNode();					temp = children.item(0);					AttrImpl attr = (AttrImpl)node;					attribute = 						new AttrImpl(attr.getQName(), temp.getNodeValue());					attribute.setOwnerDocument(doc);					parent.updateChild(node, attribute);					break;				default :					throw new EXistException("unsupported node-type");			}			prevCollection = collection;			doc.setLastModified(System.currentTimeMillis());		}		if(doc != null)			doc.getBroker().saveCollection(collection);		return children.getLength();	}