GetLocalNamespaces() public static method

Return chain of namespace nodes. If specified node has no local namespaces, then 0 will be returned. Otherwise, the first node in the chain is guaranteed to be a local namespace (its parent is this node). Subsequent nodes may not have the same node as parent, so the caller will need to test the parent in order to terminate a search that processes only local namespaces.
public static GetLocalNamespaces ( XPathNode pageElem, int idxElem, XPathNode &pageNmsp ) : int
pageElem XPathNode
idxElem int
pageNmsp XPathNode
return int
        /// <summary>
        /// Position the navigator on the namespace within the specified scope.  If no matching namespace
        /// can be found, return false.
        /// </summary>
        public override bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope)
        {
            XPathNode[] page;
            int         idx;

            if (namespaceScope == XPathNamespaceScope.Local)
            {
                // Get local namespaces only
                idx = XPathNodeHelper.GetLocalNamespaces(_pageCurrent, _idxCurrent, out page);
            }
            else
            {
                // Get all in-scope namespaces
                idx = XPathNodeHelper.GetInScopeNamespaces(_pageCurrent, _idxCurrent, out page);
            }

            while (idx != 0)
            {
                // Don't include the xmlns:xml namespace node if scope is ExcludeXml
                if (namespaceScope != XPathNamespaceScope.ExcludeXml || !page[idx].IsXmlNamespaceNode)
                {
                    _pageParent  = _pageCurrent;
                    _idxParent   = _idxCurrent;
                    _pageCurrent = page;
                    _idxCurrent  = idx;
                    return(true);
                }

                // Skip past xmlns:xml
                idx = page[idx].GetSibling(out page);
            }

            return(false);
        }
Esempio n. 2
0
        public override bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope)
        {
            XPathNode[] nodeArray;
            int         sibling;

            if (namespaceScope == XPathNamespaceScope.Local)
            {
                sibling = XPathNodeHelper.GetLocalNamespaces(this.pageCurrent, this.idxCurrent, out nodeArray);
            }
            else
            {
                sibling = XPathNodeHelper.GetInScopeNamespaces(this.pageCurrent, this.idxCurrent, out nodeArray);
            }
            while (sibling != 0)
            {
                if ((namespaceScope != XPathNamespaceScope.ExcludeXml) || !nodeArray[sibling].IsXmlNamespaceNode)
                {
                    this.pageParent  = this.pageCurrent;
                    this.idxParent   = this.idxCurrent;
                    this.pageCurrent = nodeArray;
                    this.idxCurrent  = sibling;
                    return(true);
                }
                sibling = nodeArray[sibling].GetSibling(out nodeArray);
            }
            return(false);
        }