Document doc = broker.getDocument(resource);
DocumentImpl doc = (DocumentImpl)broker.getDocument(resource);
	public int xupdateResource(User user, String resource, String xupdate)			throws SAXException, LockException, PermissionDeniedException, EXistException,			XPathException {		DBBroker broker = null;		try {			broker = brokerPool.get(user);			Document doc = broker.getDocument(resource);			if (doc == null)				throw new EXistException("document " + resource + " not found");			DocumentSet docs = new DocumentSet();			docs.add(doc);			XUpdateProcessor processor = new XUpdateProcessor(broker, docs);			Modification modifications[] = processor.parse(new InputSource(					new StringReader(xupdate)));			long mods = 0;			for (int i = 0; i < modifications.length; i++) {				mods += modifications[i].process();				broker.flush();			}			return (int) mods;		} catch (ParserConfigurationException e) {			throw new EXistException(e.getMessage());		} catch (IOException e) {			throw new EXistException(e.getMessage());		} finally {			brokerPool.release(broker);		}	}