1 //------------------------------------------------------------------------------
2 // <copyright file="ValueOfAction.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;
15 internal class ValueOfAction : CompiledAction {
16 private const int ResultStored = 2;
18 private int selectKey = Compiler.InvalidQueryKey;
19 private bool disableOutputEscaping;
21 private static Action s_BuiltInRule = new BuiltInRuleTextAction();
23 internal static Action BuiltInRule() {
24 Debug.Assert(s_BuiltInRule != null);
28 internal override void Compile(Compiler compiler) {
29 CompileAttributes(compiler);
30 CheckRequiredAttribute(compiler, selectKey != Compiler.InvalidQueryKey, "select");
34 internal override bool CompileAttribute(Compiler compiler) {
35 string name = compiler.Input.LocalName;
36 string value = compiler.Input.Value;
38 if (Ref.Equal(name, compiler.Atoms.Select)) {
39 this.selectKey = compiler.AddQuery(value);
41 else if (Ref.Equal(name, compiler.Atoms.DisableOutputEscaping)) {
42 this.disableOutputEscaping = compiler.GetYesNo(value);
51 internal override void Execute(Processor processor, ActionFrame frame) {
52 Debug.Assert(processor != null && frame != null);
54 switch (frame.State) {
56 Debug.Assert(frame != null);
57 Debug.Assert(frame.NodeSet != null);
59 string value = processor.ValueOf(frame, this.selectKey);
61 if (processor.TextEvent(value, disableOutputEscaping)) {
65 frame.StoredOutput = value;
66 frame.State = ResultStored;
71 Debug.Assert(frame.StoredOutput != null);
72 processor.TextEvent(frame.StoredOutput);
77 Debug.Fail("Invalid ValueOfAction execution state");
83 internal class BuiltInRuleTextAction : Action {
84 private const int ResultStored = 2;
85 internal override void Execute(Processor processor, ActionFrame frame) {
86 Debug.Assert(processor != null && frame != null);
88 switch (frame.State) {
90 Debug.Assert(frame != null);
91 Debug.Assert(frame.NodeSet != null);
93 string value = processor.ValueOf(frame.NodeSet.Current);
95 if (processor.TextEvent(value, /*disableOutputEscaping:*/false)) {
99 frame.StoredOutput = value;
100 frame.State = ResultStored;
105 Debug.Assert(frame.StoredOutput != null);
106 processor.TextEvent(frame.StoredOutput);
111 Debug.Fail("Invalid BuiltInRuleTextAction execution state");