model->GetInstanceDocument(NS_LITERAL_STRING(""),
model->GetInstanceDocument(EmptyString(),
nsXFormsSetValueElement::HandleAction(nsIDOMEvent* aEvent,                                      nsIXFormsActionElement *aParentAction){  if (!mElement)    return NS_OK;    nsCOMPtr<nsIDOMNode> dommodel = nsXFormsUtils::GetModel(mElement);    if (!dommodel)    return NS_OK;  nsAutoString value;  mElement->GetAttribute(NS_LITERAL_STRING("value"), value);  if (!value.IsEmpty()) {    nsCOMPtr<nsIXFormsModelElement> model(do_QueryInterface(dommodel));    if (!model)      return NS_OK;    // Get the instance data and evaluate the xpath expression.    // XXXfixme when xpath extensions are implemented (instance())    nsCOMPtr<nsIDOMDocument> instanceDoc;    model->GetInstanceDocument(NS_LITERAL_STRING(""),                               getter_AddRefs(instanceDoc));    if (!instanceDoc)      return NS_OK;    nsCOMPtr<nsIDOMElement> docElement;    instanceDoc->GetDocumentElement(getter_AddRefs(docElement));    nsCOMPtr<nsIDOMXPathResult> xpResult =      nsXFormsUtils::EvaluateXPath(value, docElement, mElement,                                   nsIDOMXPathResult::STRING_TYPE);    if (!xpResult)      return NS_OK;    xpResult->GetStringValue(value);  }  else {    nsCOMPtr<nsIDOM3Node> n3(do_QueryInterface(mElement));    n3->GetTextContent(value);  }  nsCOMPtr<nsIDOMNode> model;  nsCOMPtr<nsIDOMElement> bindElement;  nsCOMPtr<nsIDOMXPathResult> result =    nsXFormsUtils:: EvaluateNodeBinding(mElement,                                        nsXFormsUtils::ELEMENT_WITH_MODEL_ATTR,                                        NS_LITERAL_STRING("ref"),                                        EmptyString(),                                        nsIDOMXPathResult::FIRST_ORDERED_NODE_TYPE,                                        getter_AddRefs(model),                                        getter_AddRefs(bindElement));  if (!result)    return NS_OK;  nsCOMPtr<nsIDOMNode> singleNode;  result->GetSingleNodeValue(getter_AddRefs(singleNode));  if (!singleNode)    return NS_OK;  PRUint16 nodeType = 0;  singleNode->GetNodeType(&nodeType);  switch (nodeType) {    case nsIDOMNode::ATTRIBUTE_NODE:    case nsIDOMNode::TEXT_NODE:      singleNode->SetNodeValue(value);      break;    case nsIDOMNode::ELEMENT_NODE:        nsCOMPtr<nsIDOM3Node> node = do_QueryInterface(singleNode);        NS_ASSERTION(node, "DOM Nodes must support DOM3 interfaces");        node->SetTextContent(value);        break;  }    //XXX Mark the node changed    if (aParentAction) {    aParentAction->SetRecalculate(dommodel, PR_TRUE);    aParentAction->SetRevalidate(dommodel, PR_TRUE);    aParentAction->SetRefresh(dommodel, PR_TRUE);  }  else {    nsXFormsUtils::DispatchEvent(dommodel, eEvent_Recalculate);    nsXFormsUtils::DispatchEvent(dommodel, eEvent_Revalidate);    nsXFormsUtils::DispatchEvent(dommodel, eEvent_Refresh);  }  return NS_OK;}