nsCOMPtr<nsIDOMElement> newElement (do_QueryInterface(newNode)); if (newElement) { nsAutoString type ("type"); nsAutoString cite ("cite"); newElement->SetAttribute(type, cite); }
NS_IMETHODIMP nsHTMLEditor::PasteAsCitedQuotation(const nsString& aCitation){  nsAutoEditBatch beginBatching(this);  // get selection  nsCOMPtr<nsIDOMSelection> selection;  nsresult res = GetSelection(getter_AddRefs(selection));  if (NS_FAILED(res)) return res;  if (!selection) return NS_ERROR_NULL_POINTER;  // give rules a chance to handle or cancel  nsTextRulesInfo ruleInfo(nsHTMLEditRules::kInsertElement);  PRBool cancel, handled;  res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);  if (NS_FAILED(res)) return res;  if (cancel) return NS_OK; // rules canceled the operation  if (!handled)  {    nsCOMPtr<nsIDOMNode> newNode;    nsAutoString tag("blockquote");    res = DeleteSelectionAndCreateNode(tag, getter_AddRefs(newNode));    if (NS_FAILED(res)) return res;    if (!newNode) return NS_ERROR_NULL_POINTER;    // Try to set type=cite.  Ignore it if this fails.    nsCOMPtr<nsIDOMElement> newElement (do_QueryInterface(newNode));    if (newElement)    {      nsAutoString type ("type");      nsAutoString cite ("cite");      newElement->SetAttribute(type, cite);    }    // Set the selection to the underneath the node we just inserted:    res = selection->Collapse(newNode, 0);    if (NS_FAILED(res))    {#ifdef DEBUG_akkana      printf("Couldn't collapse");#endif      // XXX: error result:  should res be returned here?    }    res = Paste();  }  return res;}