System.Xml.Xsl.XsltOld.Processor.IsRoot C# (CSharp) Method

IsRoot() static private method

static private IsRoot ( XPathNavigator navigator ) : bool
navigator XPathNavigator
return bool
        internal static bool IsRoot(XPathNavigator navigator) {
            Debug.Assert(navigator != null);

            if (navigator.NodeType == XPathNodeType.Root) {
                return true;
            }
            else if (navigator.NodeType == XPathNodeType.Element) {
                XPathNavigator clone = navigator.Clone();
                clone.MoveToRoot();
                return clone.IsSamePosition(navigator);
            }
            else {
                return false;
            }
        }

Usage Example

示例#1
0
        internal override void Execute(Processor processor, ActionFrame frame)
        {
            Debug.Assert(processor != null && frame != null);

            switch (frame.State)
            {
            case Initialized:
                frame.AllocateVariables(variableCount);
                XPathNavigator root = processor.Document.Clone();
                root.MoveToRoot();
                frame.InitNodeSet(new XPathSingletonIterator(root));

                if (this.containedActions != null && this.containedActions.Count > 0)
                {
                    processor.PushActionFrame(frame);
                }
                frame.State = QueryInitialized;
                break;

            case QueryInitialized:
                Debug.Assert(frame.State == QueryInitialized);
                frame.NextNode(processor);
                Debug.Assert(Processor.IsRoot(frame.Node));
                if (processor.Debugger != null)
                {
                    // this is like apply-templates, but we don't have it on stack.
                    // Pop the stack, otherwise last instruction will be on it.
                    processor.PopDebuggerStack();
                }
                processor.PushTemplateLookup(frame.NodeSet, /*mode:*/ null, /*importsOf:*/ null);

                frame.State = RootProcessed;
                break;

            case RootProcessed:
                Debug.Assert(frame.State == RootProcessed);
                frame.Finished();
                break;

            default:
                Debug.Fail("Invalid RootAction execution state");
                break;
            }
        }
All Usage Examples Of System.Xml.Xsl.XsltOld.Processor::IsRoot