try { checkTree(1); } catch(EXistException e) { throw new DOMException( DOMException.INVALID_MODIFICATION_ERR, "max. document size exceeded"); } children++; Node node = appendChild(childGid, lastNode, child, true);
	public Node appendChild(Node child) throws DOMException {		DocumentImpl prevDoc = new DocumentImpl(ownerDocument);		Node node = null;		if (children == 0)			node = appendChild(firstChildID(), this, child, true);		else {			long last = lastChildID();			node =				appendChild(					last + 1,					(NodeImpl) ownerDocument.getNode(last),					child,					true);		}		ownerDocument.broker.update(this);		ownerDocument.broker.reindex(prevDoc, ownerDocument, null);		try {			ownerDocument.broker.saveCollection(ownerDocument.getCollection());		} catch (PermissionDeniedException e) {			throw new DOMException(DOMException.INVALID_ACCESS_ERR, e.getMessage());		}		return child;	}