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; } }
internal override void Execute(Processor processor, ActionFrame frame) { Debug.Assert(processor != null && frame != null); while (processor.CanContinue) { switch (frame.State) { case Initialized: if (Processor.IsRoot(frame.Node)) { processor.PushActionFrame(frame); frame.State = ChildrenOnly; break; } if (processor.CopyBeginEvent(frame.Node, this.empty) == false) { // This event wasn't processed break; } frame.State = NamespaceCopy; continue; case NamespaceCopy: frame.State = ContentsCopy; if (frame.Node.NodeType == XPathNodeType.Element) { processor.PushActionFrame(CopyNamespacesAction.GetAction(), frame.NodeSet); break; } continue; case ContentsCopy: if (frame.Node.NodeType == XPathNodeType.Element && !this.empty) { //Debug.Assert(frame.Node.HasValue == false); processor.PushActionFrame(frame); frame.State = ProcessChildren; break; } else { if (processor.CopyTextEvent(frame.Node)) { frame.State = ProcessChildren; continue; } else { // This event wasn't processed break; } } case ProcessChildren: if (processor.CopyEndEvent(frame.Node)) { frame.Finished(); } break; case ChildrenOnly: frame.Finished(); break; default: Debug.Fail("Invalid CopyAction execution state"); break; } break; } }