protected XmlAttributeNode AddXmlnsAttribute(Namespace ns)
{
if (!ns.Prefix.IsEmpty && ns.Uri.IsEmpty)
XmlExceptionHelper.ThrowEmptyNamespace(this);
// Some prefixes can only be bound to a particular namespace
if (ns.Prefix.IsXml && ns.Uri != xmlNamespace)
{
XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.Format(SR.XmlSpecificBindingPrefix, "xml", xmlNamespace)));
}
else if (ns.Prefix.IsXmlns && ns.Uri != xmlnsNamespace)
{
XmlExceptionHelper.ThrowXmlException(this, new XmlException(SR.Format(SR.XmlSpecificBindingPrefix, "xmlns", xmlnsNamespace)));
}
_nsMgr.Register(ns);
XmlAttributeNode attributeNode = AddAttribute(QNameType.Xmlns, false);
attributeNode.Namespace = ns;
attributeNode.AttributeText.Namespace = ns;
return attributeNode;
}