Пример #1
0
        public Element NormalizeNamespaces()
        {
            var declarations = new List <String>();

            for (int i = 0; i < _attributes.Length; i++)
            {
                var attr = _attributes[i];

                if (attr.Prefix == Namespaces.Declaration && IsValidNamespaceDeclaration(attr.LocalName, attr.NodeValue))
                {
                    declarations.Add(attr.NodeValue);
                }
            }

            if (_ns != null)
            {
                if ((_prefix != null || !IsDefaultNamespace(_ns)) && (_prefix == null || LookupNamespaceURI(_prefix) != _ns))
                {
                    SetAttributeNS(Namespaces.XmlNS, Namespaces.DeclarationFor(_prefix), _ns);
                }
            }
            else if (LocalName != null)
            {
                //TODO
            }

            for (int i = 0; i < _attributes.Length; i++)
            {
                //TODO
                //http://www.w3.org/TR/DOM-Level-3-Core/namespaces-algorithms.html#isDefaultNamespaceAlgo
            }

            for (int i = 0; i < _children.Length; i++)
            {
                var child = _children[i] as Element;

                if (child != null)
                {
                    child.NormalizeNamespaces();
                }
            }

            return(this);
        }