[XForms] NPOTDB Fix empty default namespace submission problem. Bug 445285, r=doronr+olli

git-svn-id: svn://10.0.0.236/trunk@253440 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
aaronr%us.ibm.com 2008-08-07 20:27:45 +00:00
parent 950e9e3c4d
commit 7c60c37ecf

View File

@ -1390,18 +1390,18 @@ nsXFormsSubmissionElement::AddNameSpaces(
attrName.Append(localName);
aTarget->SetAttributeNS(kXMLNSNameSpaceURI, attrName, value);
}
} else if (!value.IsEmpty()) {
} else if (!aPrefixHash ||
aPrefixHash->Get(NS_LITERAL_STRING("#default"), nsnull)) {
// only serialize the default namespace declaration if
// includenamespaceprefixes is declared and it includes '#default'
// or if we haven't already serialized it (none of the child elements
// used it)
PRBool hasDefaultNSAttr;
aTarget->HasAttributeNS(kXMLNSNameSpaceURI,
NS_LITERAL_STRING("xmlns"), &hasDefaultNSAttr);
if (!hasDefaultNSAttr) {
aTarget->GetNamespaceURI(nsURI);
if (!nsURI.IsEmpty()) {
// if aTarget default namespace uri isn't empty and it hasn't
// default namespace attribute then we should add it.
aTarget->SetAttributeNS(kXMLNSNameSpaceURI, localName, value);
}
aTarget->SetAttributeNS(kXMLNSNameSpaceURI, localName, value);
}
}
}
@ -1514,19 +1514,6 @@ nsXFormsSubmissionElement::CreateSubmissionDoc(nsIDOMNode *aRoot,
submDoc->GetDocumentElement(getter_AddRefs(submDocElm));
NS_ENSURE_STATE(submDocElm);
// if submission document has empty default namespace attribute and if
// @includenamespaceprefixes attribute doesn't contain "#default" value then
// we should remove default namespace attribute (see the specs 11.3).
nsAutoString XMLNSAttrValue;
submDocElm->GetAttributeNS(kXMLNSNameSpaceURI, NS_LITERAL_STRING("xmlns"),
XMLNSAttrValue);
if (XMLNSAttrValue.IsEmpty() && (!prefixHash ||
!prefixHash->Get(NS_LITERAL_STRING("#default"), nsnull))) {
submDocElm->RemoveAttributeNS(kXMLNSNameSpaceURI,
NS_LITERAL_STRING("xmlns"));
}
// handle namespaces on the root element of the instance document
nsCOMPtr<nsIDOMElement> instDocElm;
instDoc->GetDocumentElement(getter_AddRefs(instDocElm));