1 //------------------------------------------------------------------------------
2 // <copyright file="CopyAction.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 // <owner current="true" primary="true">Microsoft</owner>
6 //------------------------------------------------------------------------------
8 namespace System.Xml.Xsl.XsltOld {
9 using Res = System.Xml.Utils.Res;
11 using System.Diagnostics;
13 using System.Xml.XPath;
14 using MS.Internal.Xml.XPath;
16 internal class CopyAction : ContainerAction {
17 // Local execution states
18 private const int CopyText = 4;
19 private const int NamespaceCopy = 5;
21 private const int ContentsCopy = 6;
22 private const int ProcessChildren = 7;
23 private const int ChildrenOnly = 8;
25 private string useAttributeSets;
28 internal override void Compile(Compiler compiler) {
29 CompileAttributes(compiler);
31 if (compiler.Recurse()) {
32 CompileTemplate(compiler);
35 if (this.containedActions == null)
40 internal override bool CompileAttribute(Compiler compiler) {
41 string name = compiler.Input.LocalName;
42 string value = compiler.Input.Value;
43 if (Ref.Equal(name, compiler.Atoms.UseAttributeSets)) {
44 this.useAttributeSets = value;
45 AddAction(compiler.CreateUseAttributeSetsAction());
53 internal override void Execute(Processor processor, ActionFrame frame) {
54 Debug.Assert(processor != null && frame != null);
56 while (processor.CanContinue) {
57 switch (frame.State) {
59 if (Processor.IsRoot(frame.Node)) {
60 processor.PushActionFrame(frame);
61 frame.State = ChildrenOnly;
65 if (processor.CopyBeginEvent(frame.Node, this.empty) == false) {
66 // This event wasn't processed
69 frame.State = NamespaceCopy;
73 frame.State = ContentsCopy;
74 if ( frame.Node.NodeType == XPathNodeType.Element ) {
75 processor.PushActionFrame(CopyNamespacesAction.GetAction(), frame.NodeSet);
80 if (frame.Node.NodeType == XPathNodeType.Element && !this.empty) {
81 //Debug.Assert(frame.Node.HasValue == false);
82 processor.PushActionFrame(frame);
83 frame.State = ProcessChildren;
87 if (processor.CopyTextEvent(frame.Node)) {
88 frame.State = ProcessChildren;
92 // This event wasn't processed
98 if (processor.CopyEndEvent(frame.Node)) {
108 Debug.Fail("Invalid CopyAction execution state");