GetInScopeNamespaces() public static method

Return chain of in-scope namespace nodes for nodes of type Element. Nodes in the chain might not have this element as their parent. Since the xmlns:xml namespace node is always in scope, this method will never return 0 if the specified node is an element.
public static GetInScopeNamespaces ( XPathNode pageElem, int idxElem, XPathNode &pageNmsp ) : int
pageElem XPathNode
idxElem int
pageNmsp XPathNode
return int
Beispiel #1
0
        /// <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);
        }
Beispiel #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);
        }