aKid->SetDocument(doc, PR_FALSE);
aKid->SetDocument(doc, PR_TRUE);
RDFElementImpl::InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify){    nsresult rv;    if (NS_FAILED(rv = EnsureContentsGenerated()))        return rv;    NS_PRECONDITION(nsnull != aKid, "null ptr");    if (! mChildren) {        if (NS_FAILED(NS_NewISupportsArray(&mChildren)))            return NS_ERROR_OUT_OF_MEMORY;    }    PRBool insertOk = mChildren->InsertElementAt(aKid, aIndex);/* XXX fix up void array api to use nsresult's*/    if (insertOk) {        NS_ADDREF(aKid);        aKid->SetParent(this);        //nsRange::OwnerChildInserted(this, aIndex);        nsIDocument* doc = mDocument;        if (nsnull != doc) {            aKid->SetDocument(doc, PR_FALSE);            if (aNotify) {                doc->ContentInserted(this, aKid, aIndex);            }        }    }    return NS_OK;}