nsCOMPtr<nsIDOMElement> targElem(do_QueryInterface(*aTarget)); if (targElem) targElem->RemoveAttribute(NS_LITERAL_STRING("id"));
nsXFormsRepeatElement::CloneNode(nsIDOMNode  *aSrc,                                 nsIDOMNode **aTarget){  NS_ENSURE_ARG(aSrc);  NS_ENSURE_ARG_POINTER(aTarget);  // Clone aSrc  nsresult rv;  rv = aSrc->CloneNode(PR_FALSE, aTarget);  NS_ENSURE_SUCCESS(rv, rv);  // Check whether we have cloned a repeat  if (nsXFormsUtils::IsXFormsElement(aSrc, NS_LITERAL_STRING("repeat"))) {    nsCOMPtr<nsIXFormsRepeatElement> repSource = do_QueryInterface(aSrc);    NS_ENSURE_STATE(repSource);    nsCOMPtr<nsIXFormsRepeatElement> repClone = do_QueryInterface(*aTarget);    NS_ENSURE_STATE(repClone);    // Find top-most parent of these repeats    nsCOMPtr<nsIXFormsRepeatElement> parent = repSource;    nsCOMPtr<nsIXFormsRepeatElement> temp;    rv = parent->GetParent(getter_AddRefs(temp));    NS_ENSURE_SUCCESS(rv, rv);    while (temp) {      temp.swap(parent);      rv = parent->GetParent(getter_AddRefs(temp));      NS_ENSURE_SUCCESS(rv, rv);    }    // Set parent and level on clone    PRUint32 level;    repSource->GetLevel(&level);    repClone->SetLevel(level + 1);    repClone->SetParent(parent);    // Inform parent of new status, if it does not know already    PRBool isParent;    parent->GetIsParent(&isParent);    if (!isParent) {      rv = parent->SetCurrentRepeat(repClone, 1);      NS_ENSURE_SUCCESS(rv, rv);      parent->SetIsParent(PR_TRUE);    }  }  // Clone children of aSrc  nsCOMPtr<nsIDOMNode> tmp;  nsCOMPtr<nsIDOMNodeList> childNodes;  aSrc->GetChildNodes(getter_AddRefs(childNodes));  PRUint32 count = 0;  if (childNodes)    childNodes->GetLength(&count);  for (PRUint32 i = 0; i < count; ++i) {    nsCOMPtr<nsIDOMNode> child;    childNodes->Item(i, getter_AddRefs(child));        if (child) {      nsCOMPtr<nsIDOMNode> clone;      CloneNode(child, getter_AddRefs(clone));      if (clone) {        rv = (*aTarget)->AppendChild(clone, getter_AddRefs(tmp));        NS_ENSURE_SUCCESS(rv, rv);      }    }  }  return NS_OK;}