Matches() приватный Метод

private Matches ( XPathNavigator context, int key ) : bool
context XPathNavigator
key int
Результат bool
Пример #1
0
 internal bool PreserveWhiteSpace(Processor proc, XPathNavigator node)
 {
     // last one should win. I.E. We starting from the end. I.E. Lowest priority should go first
     if (_whitespaceList != null)
     {
         for (int i = _whitespaceList.Count - 1; 0 <= i; i--)
         {
             WhitespaceElement elem = (WhitespaceElement)_whitespaceList[i];
             if (proc.Matches(node, elem.Key))
             {
                 return(elem.PreserveSpace);
             }
         }
     }
     if (_imports != null)
     {
         for (int importIndex = _imports.Count - 1; importIndex >= 0; importIndex--)
         {
             Stylesheet stylesheet = (Stylesheet)_imports[importIndex];
             if (!stylesheet.PreserveWhiteSpace(proc, node))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
 private bool MatchCountKey(Processor processor, XPathNavigator contextNode, XPathNavigator nav)
 {
     if (_countKey != Compiler.InvalidQueryKey)
     {
         return(processor.Matches(nav, _countKey));
     }
     if (contextNode.Name == nav.Name && BasicNodeType(contextNode.NodeType) == BasicNodeType(nav.NodeType))
     {
         return(true);
     }
     return(false);
 }
 private bool moveToCount(XPathNavigator nav, Processor processor, XPathNavigator contextNode)
 {
     do
     {
         if (_fromKey != Compiler.InvalidQueryKey && processor.Matches(nav, _fromKey))
         {
             return(false);
         }
         if (MatchCountKey(processor, contextNode, nav))
         {
             return(true);
         }
     } while (nav.MoveToParent());
     return(false);
 }
 // check 'from' condition:
 // if 'from' exist it has to be ancestor-or-self for the nav
 private bool checkFrom(Processor processor, XPathNavigator nav)
 {
     if (_fromKey == Compiler.InvalidQueryKey)
     {
         return(true);
     }
     do
     {
         if (processor.Matches(nav, _fromKey))
         {
             return(true);
         }
     } while (nav.MoveToParent());
     return(false);
 }
Пример #5
0
        internal TemplateAction FindTemplate(Processor processor, XPathNavigator navigator) {
            if (this.templates == null) {
                return null;
            }

            Debug.Assert(this.templates != null);
            for (int templateIndex = this.templates.Count - 1; templateIndex >= 0 ; templateIndex --) {
                TemplateAction action = (TemplateAction) this.templates[templateIndex];
                int matchKey = action.MatchKey;

                if (matchKey != Compiler.InvalidQueryKey) {
                    if (processor.Matches(navigator, matchKey)) {
                        return action;
                    }
                }
            }

            return null;
        }
Пример #6
0
        internal TemplateAction?FindTemplate(Processor processor, XPathNavigator navigator)
        {
            if (this.templates == null)
            {
                return(null);
            }

            Debug.Assert(this.templates != null);
            for (int templateIndex = this.templates.Count - 1; templateIndex >= 0; templateIndex--)
            {
                TemplateAction action   = (TemplateAction)this.templates[templateIndex] !;
                int            matchKey = action.MatchKey;

                if (matchKey != Compiler.InvalidQueryKey)
                {
                    if (processor.Matches(navigator, matchKey))
                    {
                        return(action);
                    }
                }
            }

            return(null);
        }
 private bool MatchCountKey(Processor processor, XPathNavigator contextNode, XPathNavigator nav){
     if (this.countKey != Compiler.InvalidQueryKey) {
         return processor.Matches(nav, this.countKey);
     }
     if (contextNode.Name == nav.Name && BasicNodeType(contextNode.NodeType) == BasicNodeType(nav.NodeType)) {
         return true;
     }
     return false;
 }
 private bool moveToCount(XPathNavigator nav, Processor processor, XPathNavigator contextNode) {
     do {
         if (this.fromKey != Compiler.InvalidQueryKey && processor.Matches(nav, this.fromKey)) {
             return false;
         }
         if (MatchCountKey(processor, contextNode, nav)) {
             return true;
         }
     }while (nav.MoveToParent());
     return false;
 }
 // check 'from' condition:
 // if 'from' exist it has to be ancestor-or-self for the nav
 private bool checkFrom(Processor processor, XPathNavigator nav) {
     if(this.fromKey == Compiler.InvalidQueryKey) {
         return true;
     }
     do {
         if (processor.Matches(nav, this.fromKey)) {
             return true;
         }
     }while (nav.MoveToParent());
     return false;
 }
Пример #10
0
        private int numberAny(Processor processor, ActionFrame frame) {
            int result = 0;
            // Our current point will be our end point in this search
            XPathNavigator endNode = frame.Node;
            if(endNode.NodeType == XPathNodeType.Attribute || endNode.NodeType == XPathNodeType.Namespace) {
                endNode = endNode.Clone();
                endNode.MoveToParent();
            }
            XPathNavigator startNode = endNode.Clone();

            if(this.fromKey != Compiler.InvalidQueryKey) {
                bool hitFrom = false;
                // First try to find start by traversing up. This gives the best candidate or we hit root
                do{
                    if(processor.Matches(startNode, this.fromKey)) {
                        hitFrom = true;
                        break;
                    }
                }while(startNode.MoveToParent());

                Debug.Assert(
                    processor.Matches(startNode, this.fromKey) ||   // we hit 'from' or
                    startNode.NodeType == XPathNodeType.Root        // we are at root
                );

                // from this point (matched parent | root) create descendent quiery:
                // we have to reset 'result' on each 'from' node, because this point can' be not last from point;
                XPathNodeIterator  sel = startNode.SelectDescendants(XPathNodeType.All, /*matchSelf:*/ true);
                while (sel.MoveNext()) {
                    if(processor.Matches(sel.Current, this.fromKey)) {
                        hitFrom = true;
                        result = 0;
                    }
                    else if(MatchCountKey(processor, frame.Node, sel.Current)) {
                        result ++;
                    }
                    if(sel.Current.IsSamePosition(endNode)) {
                        break;
                    }
                }
                if(! hitFrom) {
                    result = 0;
                }
            }
            else {
                // without 'from' we startting from the root
                startNode.MoveToRoot();
                XPathNodeIterator  sel = startNode.SelectDescendants(XPathNodeType.All, /*matchSelf:*/ true);
                // and count root node by itself
                while (sel.MoveNext()) {
                    if (MatchCountKey(processor, frame.Node, sel.Current)) {
                        result ++;
                    }
                    if (sel.Current.IsSamePosition(endNode)) {
                        break;
                    }
                }
            }
            return result;
        }
        private int numberAny(Processor processor, ActionFrame frame)
        {
            int result = 0;
            // Our current point will be our end point in this search
            XPathNavigator endNode = frame.Node;

            if (endNode.NodeType == XPathNodeType.Attribute || endNode.NodeType == XPathNodeType.Namespace)
            {
                endNode = endNode.Clone();
                endNode.MoveToParent();
            }
            XPathNavigator startNode = endNode.Clone();

            if (_fromKey != Compiler.InvalidQueryKey)
            {
                bool hitFrom = false;
                // First try to find start by traversing up. This gives the best candidate or we hit root
                do
                {
                    if (processor.Matches(startNode, _fromKey))
                    {
                        hitFrom = true;
                        break;
                    }
                } while (startNode.MoveToParent());

                Debug.Assert(
                    processor.Matches(startNode, _fromKey) ||   // we hit 'from' or
                    startNode.NodeType == XPathNodeType.Root    // we are at root
                    );

                // from this point (matched parent | root) create descendent quiery:
                // we have to reset 'result' on each 'from' node, because this point can' be not last from point;
                XPathNodeIterator sel = startNode.SelectDescendants(XPathNodeType.All, /*matchSelf:*/ true);
                while (sel.MoveNext())
                {
                    if (processor.Matches(sel.Current, _fromKey))
                    {
                        hitFrom = true;
                        result  = 0;
                    }
                    else if (MatchCountKey(processor, frame.Node, sel.Current))
                    {
                        result++;
                    }
                    if (sel.Current.IsSamePosition(endNode))
                    {
                        break;
                    }
                }
                if (!hitFrom)
                {
                    result = 0;
                }
            }
            else
            {
                // without 'from' we startting from the root
                startNode.MoveToRoot();
                XPathNodeIterator sel = startNode.SelectDescendants(XPathNodeType.All, /*matchSelf:*/ true);
                // and count root node by itself
                while (sel.MoveNext())
                {
                    if (MatchCountKey(processor, frame.Node, sel.Current))
                    {
                        result++;
                    }
                    if (sel.Current.IsSamePosition(endNode))
                    {
                        break;
                    }
                }
            }
            return(result);
        }
Пример #12
0
 internal bool PreserveWhiteSpace(Processor proc, XPathNavigator node){
     // last one should win. I.E. We starting from the end. I.E. Lowest priority should go first
     if (this.whitespaceList != null) {
         for (int i = this.whitespaceList.Count - 1; 0 <= i; i --) {
             WhitespaceElement elem = (WhitespaceElement) this.whitespaceList[i];
             if (proc.Matches(node, elem.Key)) {
                 return elem.PreserveSpace;
             }
         }
     }
     if (this.imports != null) {
         for (int importIndex = this.imports.Count - 1; importIndex >= 0; importIndex --) {
             Stylesheet stylesheet = (Stylesheet) this.imports[importIndex];
             if (! stylesheet.PreserveWhiteSpace(proc, node))
                 return false;
         }
     }
     return true;
 }