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); }
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); } } } Debug.WriteLine("Template not found"); 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); }
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 = 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 = processor.StartQuery(startNode, Compiler.DescendantKey); do { 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; } }while (sel.MoveNext()); if (!hitFrom) { result = 0; } } else { // without 'from' we startting from the root startNode.MoveToRoot(); XPathNodeIterator sel = processor.StartQuery(startNode, Compiler.DescendantKey); // and count root node by itself do { if (MatchCountKey(processor, frame.Node, sel.Current)) { result++; } if (sel.Current.IsSamePosition(endNode)) { break; } }while (sel.MoveNext()); } return(result); }
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; }
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 = 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 = processor.StartQuery(startNode, Compiler.DescendantKey); do { 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; } }while (sel.MoveNext()); if(! hitFrom) { result = 0; } } else { // without 'from' we startting from the root startNode.MoveToRoot(); XPathNodeIterator sel = processor.StartQuery(startNode, Compiler.DescendantKey); // and count root node by itself do { if (MatchCountKey(processor, frame.Node, sel.Current)) { result ++; } if (sel.Current.IsSamePosition(endNode)) { break; } }while (sel.MoveNext()); } return result; }
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; }
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; } } } Debug.WriteLine("Template not found"); return null; }