Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ApplyTemplatesAction.cs
Go to the documentation of this file.
2
4
6{
7 private int _selectKey = -1;
8
10
12
14 {
15 return s_BuiltInRule;
16 }
17
19 {
20 if (!(mode == null) && !mode.IsEmpty)
21 {
22 return new ApplyTemplatesAction(mode);
23 }
24 return BuiltInRule();
25 }
26
28 {
29 }
30
32 {
33 _mode = mode;
34 }
35
36 internal override void Compile(Compiler compiler)
37 {
40 }
41
42 internal override bool CompileAttribute(Compiler compiler)
43 {
44 string localName = compiler.Input.LocalName;
45 string value = compiler.Input.Value;
46 if (Ref.Equal(localName, compiler.Atoms.Select))
47 {
48 _selectKey = compiler.AddQuery(value);
49 }
50 else
51 {
52 if (!Ref.Equal(localName, compiler.Atoms.Mode))
53 {
54 return false;
55 }
56 if (compiler.AllowBuiltInMode && value == "*")
57 {
59 }
60 else
61 {
62 _mode = compiler.CreateXPathQName(value);
63 }
64 }
65 return true;
66 }
67
69 {
71 if (!compiler.Recurse())
72 {
73 return;
74 }
75 do
76 {
77 switch (input.NodeType)
78 {
79 case XPathNodeType.Element:
80 {
81 compiler.PushNamespaceScope();
83 string localName = input.LocalName;
84 if (Ref.Equal(namespaceURI, input.Atoms.UriXsl))
85 {
86 if (Ref.Equal(localName, input.Atoms.Sort))
87 {
88 AddAction(compiler.CreateSortAction());
89 }
90 else
91 {
92 if (!Ref.Equal(localName, input.Atoms.WithParam))
93 {
94 throw compiler.UnexpectedKeyword();
95 }
96 WithParamAction withParamAction = compiler.CreateWithParamAction();
99 }
100 compiler.PopScope();
101 break;
102 }
103 throw compiler.UnexpectedKeyword();
104 }
105 default:
106 throw XsltException.Create(System.SR.Xslt_InvalidContents, "apply-templates");
107 case XPathNodeType.SignificantWhitespace:
108 case XPathNodeType.Whitespace:
109 case XPathNodeType.ProcessingInstruction:
110 case XPathNodeType.Comment:
111 break;
112 }
113 }
114 while (compiler.Advance());
115 compiler.ToParent();
116 }
117
118 internal override void Execute(Processor processor, ActionFrame frame)
119 {
120 switch (frame.State)
121 {
122 default:
123 return;
124 case 0:
125 processor.ResetParams();
126 processor.InitSortArray();
127 if (containedActions != null && containedActions.Count > 0)
128 {
129 processor.PushActionFrame(frame);
130 frame.State = 2;
131 return;
132 }
133 goto case 2;
134 case 2:
135 if (_selectKey == -1)
136 {
137 if (!frame.Node.HasChildren)
138 {
139 frame.Finished();
140 return;
141 }
143 }
144 else
145 {
146 frame.InitNewNodeSet(processor.StartQuery(frame.NodeSet, _selectKey));
147 }
148 if (processor.SortArray.Count != 0)
149 {
150 frame.SortNewNodeSet(processor, processor.SortArray);
151 }
152 frame.State = 3;
153 goto case 3;
154 case 3:
155 if (frame.NewNextNode(processor))
156 {
157 frame.State = 4;
158 break;
159 }
160 frame.Finished();
161 return;
162 case 4:
163 break;
164 case 5:
165 frame.State = 3;
166 goto case 3;
167 case 1:
168 return;
169 }
170 processor.PushTemplateLookup(frame.NewNodeSet, _mode, null);
171 frame.State = 5;
172 }
173}
static string Xslt_InvalidContents
Definition SR.cs:2076
Definition SR.cs:7
static bool Equal(string strA, string strB)
Definition Ref.cs:5
virtual XPathNodeIterator SelectChildren(XPathNodeType type)
static XsltException Create(string res, params string[] args)
void SortNewNodeSet(Processor proc, ArrayList sortarray)
bool NewNextNode(Processor proc)
void InitNewNodeSet(XPathNodeIterator nodeSet)
override bool CompileAttribute(Compiler compiler)
override void Execute(Processor processor, ActionFrame frame)
static ApplyTemplatesAction BuiltInRule(XmlQualifiedName mode)
static readonly ApplyTemplatesAction s_BuiltInRule
void CompileAttributes(Compiler compiler)
static XmlQualifiedName BuiltInMode
Definition Compiler.cs:81
void CheckDuplicateParams(XmlQualifiedName name)