System.Xml.Xsl.Runtime.XmlQueryOutput.CopyNamespaces C# (CSharp) Method

CopyNamespaces() private method

Copy all namespaces of the specified type (in-scope, exclude-xml, local) in document order to output.
private CopyNamespaces ( XPathNavigator navigator, XPathNamespaceScope nsScope ) : void
navigator System.Xml.XPath.XPathNavigator
nsScope XPathNamespaceScope
return void
        private void CopyNamespaces(XPathNavigator navigator, XPathNamespaceScope nsScope) {
            Debug.Assert(navigator.NodeType == XPathNodeType.Element, "Only elements have namespaces to copy");

            // Default namespace undeclaration isn't included in navigator's namespace list, so add it now
            if (navigator.NamespaceURI.Length == 0) {
                Debug.Assert(navigator.LocalName.Length != 0, "xmlns:foo='' isn't allowed");
                WriteNamespaceDeclarationUnchecked(string.Empty, string.Empty);
            }

            // Since the namespace list is arranged in reverse-document order, recursively reverse it.
            if (navigator.MoveToFirstNamespace(nsScope)) {
                CopyNamespacesHelper(navigator, nsScope);
                navigator.MoveToParent();
            }
        }