nsCOMPtr<nsIDOMNode> model;
nsCOMPtr<nsIModelElementPrivate> modelPriv;
nsXFormsSetValueElement::HandleAction(nsIDOMEvent* aEvent,                                      nsIXFormsActionElement *aParentAction){  if (!mElement)    return NS_OK;    nsCOMPtr<nsIDOMNode> model;  nsCOMPtr<nsIDOMXPathResult> result;  nsresult rv =    nsXFormsUtils:: EvaluateNodeBinding(mElement,                                        nsXFormsUtils::ELEMENT_WITH_MODEL_ATTR,                                        NS_LITERAL_STRING("ref"),                                        EmptyString(),                                        nsIDOMXPathResult::FIRST_ORDERED_NODE_TYPE,                                        getter_AddRefs(model),                                        getter_AddRefs(result));  NS_ENSURE_SUCCESS(rv, rv);  nsCOMPtr<nsIModelElementPrivate> modelPriv = do_QueryInterface(model);  if (!result | !modelPriv)    return NS_OK;  nsCOMPtr<nsIDOMNode> singleNode;  result->GetSingleNodeValue(getter_AddRefs(singleNode));  if (!singleNode)    return NS_OK;  nsAutoString value;  nsAutoString valueAttr;  mElement->GetAttribute(NS_LITERAL_STRING("value"), valueAttr);  if(!valueAttr.IsEmpty()) {    // According to the XForms Errata, the context node for the XPath expression    //   stored in @value should be the node that setvalue is bound to.    nsCOMPtr<nsIDOMXPathResult> xpResult =      nsXFormsUtils::EvaluateXPath(valueAttr, singleNode, mElement,                                   nsIDOMXPathResult::STRING_TYPE);    if (!xpResult)      return NS_OK;    xpResult->GetStringValue(value);  }  else {    nsCOMPtr<nsIDOM3Node> n3(do_QueryInterface(mElement));    n3->GetTextContent(value);  }  nsXFormsMDGEngine* MDG;  modelPriv->GetMDG(&MDG);  if (!MDG)    return NS_ERROR_FAILURE;  PRBool changed;  rv = MDG->SetNodeValue(singleNode, value, PR_TRUE, &changed);  NS_ENSURE_SUCCESS(rv, rv);  if (changed) {    if (aParentAction) {      aParentAction->SetRecalculate(model, PR_TRUE);      aParentAction->SetRevalidate(model, PR_TRUE);      aParentAction->SetRefresh(model, PR_TRUE);    } else {      nsXFormsUtils::DispatchEvent(model, eEvent_Recalculate);      nsXFormsUtils::DispatchEvent(model, eEvent_Revalidate);      nsXFormsUtils::DispatchEvent(model, eEvent_Refresh);    }  }  return NS_OK;}