Beispiel #1
0
        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 !, _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 && !_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;
                        }
                    }
Beispiel #2
0
        internal override void Execute(Processor processor, ActionFrame frame)
        {
            Debug.Assert(processor != null && frame != null);
            while (processor.CanContinue)
            {
                switch (frame.State)
                {
                case Initialized:
                    if (frame.NextNode(processor))
                    {
                        frame.State = BeginEvent;
                        goto case BeginEvent;
                    }
                    else
                    {
                        frame.Finished();
                        break;
                    }

                case BeginEvent:
                    Debug.Assert(frame.State == BeginEvent);

                    if (SendBeginEvent(processor, frame.Node) == false)
                    {
                        // This one wasn't output
                        break;
                    }
                    frame.State = Contents;
                    continue;

                case Contents:
                    Debug.Assert(frame.State == Contents);
                    XPathNodeType nodeType = frame.Node.NodeType;

                    if (nodeType == XPathNodeType.Element || nodeType == XPathNodeType.Root)
                    {
                        processor.PushActionFrame(CopyNamespacesAction.GetAction(), frame.NodeSet);
                        frame.State = Namespaces;
                        break;
                    }

                    if (SendTextEvent(processor, frame.Node) == false)
                    {
                        // This one wasn't output
                        break;
                    }
                    frame.State = EndEvent;
                    continue;

                case Namespaces:
                    processor.PushActionFrame(CopyAttributesAction.GetAction(), frame.NodeSet);
                    frame.State = Attributes;
                    break;

                case Attributes:
                    if (frame.Node.HasChildren)
                    {
                        processor.PushActionFrame(GetAction(), frame.Node.SelectChildren(XPathNodeType.All));
                        frame.State = Subtree;
                        break;
                    }
                    frame.State = EndEvent;
                    goto case EndEvent;

                case Subtree:
                    //frame.Node.MoveToParent();
                    frame.State = EndEvent;
                    continue;

                case EndEvent:
                    Debug.Assert(frame.State == EndEvent);

                    if (SendEndEvent(processor, frame.Node) == false)
                    {
                        // This one wasn't output
                        break;
                    }

                    frame.State = Initialized;
                    continue;
                }

                break;
            }
        }