Exemple #1
0
		internal virtual void RemoveNamespace(Rhino.Xmlimpl.XmlNode.Namespace @namespace)
		{
			Rhino.Xmlimpl.XmlNode.Namespace current = GetNodeNamespace();
			//    Do not remove in-use namespace
			if (@namespace.Is(current))
			{
				return;
			}
			XmlNamedNodeMap attrs = this.dom.Attributes;
			for (int i = 0; i < attrs.Count; i++)
			{
				Rhino.Xmlimpl.XmlNode attr = Rhino.Xmlimpl.XmlNode.CreateImpl(attrs.Item(i));
				if (@namespace.Is(attr.GetNodeNamespace()))
				{
					return;
				}
			}
			//    TODO    I must confess I am not sure I understand the spec fully.  See ECMA357 13.4.4.31
			string existingPrefix = GetExistingPrefixFor(@namespace);
			if (existingPrefix != null)
			{
				if (@namespace.IsUnspecifiedPrefix())
				{
					//    we should remove any namespace with this URI from scope; we do this by declaring a namespace with the same
					//    prefix as the existing prefix and setting its URI to the default namespace
					DeclareNamespace(existingPrefix, GetDefaultNamespace().GetUri());
				}
				else
				{
					if (existingPrefix.Equals(@namespace.GetPrefix()))
					{
						DeclareNamespace(existingPrefix, GetDefaultNamespace().GetUri());
					}
				}
			}
		}