1 //------------------------------------------------------------------------------
2 // <copyright file="ContainerAction.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.Globalization;
15 using System.Xml.XPath;
16 using System.Xml.Xsl.Runtime;
17 using MS.Internal.Xml.XPath;
18 using System.Collections;
19 using System.Runtime.Versioning;
21 internal class NamespaceInfo {
22 internal String prefix;
23 internal String nameSpace;
24 internal int stylesheetId;
26 internal NamespaceInfo(String prefix, String nameSpace, int stylesheetId) {
28 this.nameSpace = nameSpace;
29 this.stylesheetId = stylesheetId;
33 internal class ContainerAction : CompiledAction {
34 internal ArrayList containedActions;
35 internal CopyCodeAction lastCopyCodeAction; // non null if last action is CopyCodeAction;
37 private int maxid = 0;
39 // Local execution states
40 protected const int ProcessingChildren = 1;
42 internal override void Compile(Compiler compiler) {
43 throw new NotImplementedException();
46 internal void CompileStylesheetAttributes(Compiler compiler) {
47 NavigatorInput input = compiler.Input;
48 string element = input.LocalName;
49 string badAttribute = null;
50 string version = null;
52 if (input.MoveToFirstAttribute()) {
54 string nspace = input.NamespaceURI;
55 string name = input.LocalName;
57 if (nspace.Length != 0) continue;
59 if (Ref.Equal(name, input.Atoms.Version)) {
60 version = input.Value;
61 if (1 <= XmlConvert.ToXPathDouble(version)) {
62 compiler.ForwardCompatibility = (version != "1.0");
65 // XmlConvert.ToXPathDouble(version) an be NaN!
66 if (! compiler.ForwardCompatibility) {
67 throw XsltException.Create(Res.Xslt_InvalidAttrValue, "version", version);
71 else if (Ref.Equal(name, input.Atoms.ExtensionElementPrefixes)) {
72 compiler.InsertExtensionNamespace(input.Value);
74 else if (Ref.Equal(name, input.Atoms.ExcludeResultPrefixes)) {
75 compiler.InsertExcludedNamespace(input.Value);
77 else if (Ref.Equal(name, input.Atoms.Id)) {
81 // We can have version atribute later. For now remember this attribute and continue
85 while( input.MoveToNextAttribute());
89 if (version == null) {
90 throw XsltException.Create(Res.Xslt_MissingAttribute, "version");
93 if (badAttribute != null && ! compiler.ForwardCompatibility) {
94 throw XsltException.Create(Res.Xslt_InvalidAttribute, badAttribute, element);
98 internal void CompileSingleTemplate(Compiler compiler) {
99 NavigatorInput input = compiler.Input;
102 // find mandatory version attribute and launch compilation of single template
105 string version = null;
107 if (input.MoveToFirstAttribute()) {
109 string nspace = input.NamespaceURI;
110 string name = input.LocalName;
112 if (Ref.Equal(nspace, input.Atoms.UriXsl) &&
113 Ref.Equal(name, input.Atoms.Version)) {
114 version = input.Value;
117 while(input.MoveToNextAttribute());
121 if (version == null) {
122 if (Ref.Equal(input.LocalName, input.Atoms.Stylesheet) &&
123 input.NamespaceURI == XmlReservedNs.NsWdXsl) {
124 throw XsltException.Create(Res.Xslt_WdXslNamespace);
126 throw XsltException.Create(Res.Xslt_WrongStylesheetElement);
129 compiler.AddTemplate(compiler.CreateSingleTemplateAction());
133 * CompileTopLevelElements
135 protected void CompileDocument(Compiler compiler, bool inInclude) {
136 NavigatorInput input = compiler.Input;
139 while (input.NodeType != XPathNodeType.Element) {
140 if (! compiler.Advance()) {
141 throw XsltException.Create(Res.Xslt_WrongStylesheetElement);
145 Debug.Assert(compiler.Input.NodeType == XPathNodeType.Element);
146 if (Ref.Equal(input.NamespaceURI, input.Atoms.UriXsl)) {
148 ! Ref.Equal(input.LocalName, input.Atoms.Stylesheet) &&
149 ! Ref.Equal(input.LocalName, input.Atoms.Transform)
151 throw XsltException.Create(Res.Xslt_WrongStylesheetElement);
153 compiler.PushNamespaceScope();
154 CompileStylesheetAttributes(compiler);
155 CompileTopLevelElements(compiler);
157 CompileImports(compiler);
162 compiler.PushLiteralScope();
163 CompileSingleTemplate(compiler);
169 internal Stylesheet CompileImport(Compiler compiler, Uri uri, int id) {
170 NavigatorInput input = compiler.ResolveDocument(uri);
171 compiler.PushInputDocument(input);
174 compiler.PushStylesheet(new Stylesheet());
175 compiler.Stylesheetid = id;
176 CompileDocument(compiler, /*inInclude*/ false);
178 catch (XsltCompileException) {
181 catch (Exception e) {
182 throw new XsltCompileException(e, input.BaseURI, input.LineNumber, input.LinePosition);
185 compiler.PopInputDocument();
187 return compiler.PopStylesheet();
190 private void CompileImports(Compiler compiler) {
191 ArrayList imports = compiler.CompiledStylesheet.Imports;
192 // We can't reverce imports order. Template lookup relyes on it after compilation
193 int saveStylesheetId = compiler.Stylesheetid;
194 for (int i = imports.Count - 1; 0 <= i; i --) { // Imports should be compiled in reverse order
195 Uri uri = imports[i] as Uri;
196 Debug.Assert(uri != null);
197 imports[i] = CompileImport(compiler, uri, ++ this.maxid);
199 compiler.Stylesheetid = saveStylesheetId;
202 // SxS: This method does not take any resource name and does not expose any resources to the caller.
203 // It's OK to suppress the SxS warning.
204 [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
205 [ResourceExposure(ResourceScope.None)]
206 void CompileInclude(Compiler compiler) {
207 Uri uri = compiler.ResolveUri(compiler.GetSingleAttribute(compiler.Input.Atoms.Href));
208 string resolved = uri.ToString();
209 if (compiler.IsCircularReference(resolved)) {
210 throw XsltException.Create(Res.Xslt_CircularInclude, resolved);
213 NavigatorInput input = compiler.ResolveDocument(uri);
214 compiler.PushInputDocument(input);
217 CompileDocument(compiler, /*inInclude*/ true);
219 catch (XsltCompileException) {
222 catch (Exception e) {
223 throw new XsltCompileException(e, input.BaseURI, input.LineNumber, input.LinePosition);
226 compiler.PopInputDocument();
228 CheckEmpty(compiler);
231 internal void CompileNamespaceAlias(Compiler compiler) {
232 NavigatorInput input = compiler.Input;
233 string element = input.LocalName;
234 string namespace1 = null, namespace2 = null;
235 string prefix1 = null , prefix2 = null;
236 if (input.MoveToFirstAttribute()) {
238 string nspace = input.NamespaceURI;
239 string name = input.LocalName;
241 if (nspace.Length != 0) continue;
243 if (Ref.Equal(name,input.Atoms.StylesheetPrefix)) {
244 prefix1 = input.Value;
245 namespace1 = compiler.GetNsAlias(ref prefix1);
247 else if (Ref.Equal(name,input.Atoms.ResultPrefix)){
248 prefix2 = input.Value;
249 namespace2 = compiler.GetNsAlias(ref prefix2);
252 if (! compiler.ForwardCompatibility) {
253 throw XsltException.Create(Res.Xslt_InvalidAttribute, name, element);
257 while(input.MoveToNextAttribute());
261 CheckRequiredAttribute(compiler, namespace1, "stylesheet-prefix");
262 CheckRequiredAttribute(compiler, namespace2, "result-prefix" );
263 CheckEmpty(compiler);
265 //String[] resultarray = { prefix2, namespace2 };
266 compiler.AddNamespaceAlias( namespace1, new NamespaceInfo(prefix2, namespace2, compiler.Stylesheetid));
269 internal void CompileKey(Compiler compiler){
270 NavigatorInput input = compiler.Input;
271 string element = input.LocalName;
272 int MatchKey = Compiler.InvalidQueryKey;
273 int UseKey = Compiler.InvalidQueryKey;
275 XmlQualifiedName Name = null;
276 if (input.MoveToFirstAttribute()) {
278 string nspace = input.NamespaceURI;
279 string name = input.LocalName;
280 string value = input.Value;
282 if (nspace.Length != 0) continue;
284 if (Ref.Equal(name, input.Atoms.Name)) {
285 Name = compiler.CreateXPathQName(value);
287 else if (Ref.Equal(name, input.Atoms.Match)) {
288 MatchKey = compiler.AddQuery(value, /*allowVars:*/false, /*allowKey*/false, /*pattern*/true);
290 else if (Ref.Equal(name, input.Atoms.Use)) {
291 UseKey = compiler.AddQuery(value, /*allowVars:*/false, /*allowKey*/false, /*pattern*/false);
294 if (! compiler.ForwardCompatibility) {
295 throw XsltException.Create(Res.Xslt_InvalidAttribute, name, element);
299 while(input.MoveToNextAttribute());
303 CheckRequiredAttribute(compiler, MatchKey != Compiler.InvalidQueryKey, "match");
304 CheckRequiredAttribute(compiler, UseKey != Compiler.InvalidQueryKey, "use" );
305 CheckRequiredAttribute(compiler, Name != null , "name" );
306 // It is a breaking change to check for emptiness, SQLBUDT 324364
307 //CheckEmpty(compiler);
309 compiler.InsertKey(Name, MatchKey, UseKey);
312 protected void CompileDecimalFormat(Compiler compiler){
313 NumberFormatInfo info = new NumberFormatInfo();
314 DecimalFormat format = new DecimalFormat(info, '#', '0', ';');
315 XmlQualifiedName Name = null;
316 NavigatorInput input = compiler.Input;
317 if (input.MoveToFirstAttribute()) {
319 if (input.Prefix.Length != 0) continue;
321 string name = input.LocalName;
322 string value = input.Value;
324 if (Ref.Equal(name, input.Atoms.Name)) {
325 Name = compiler.CreateXPathQName(value);
327 else if (Ref.Equal(name, input.Atoms.DecimalSeparator)) {
328 info.NumberDecimalSeparator = value;
330 else if (Ref.Equal(name, input.Atoms.GroupingSeparator)) {
331 info.NumberGroupSeparator = value;
333 else if (Ref.Equal(name, input.Atoms.Infinity)) {
334 info.PositiveInfinitySymbol = value;
336 else if (Ref.Equal(name, input.Atoms.MinusSign)) {
337 info.NegativeSign = value;
339 else if (Ref.Equal(name, input.Atoms.NaN)) {
340 info.NaNSymbol = value;
342 else if (Ref.Equal(name, input.Atoms.Percent)) {
343 info.PercentSymbol = value;
345 else if (Ref.Equal(name, input.Atoms.PerMille)) {
346 info.PerMilleSymbol = value;
348 else if (Ref.Equal(name, input.Atoms.Digit)) {
349 if (CheckAttribute(value.Length == 1, compiler)) {
350 format.digit = value[0];
353 else if (Ref.Equal(name, input.Atoms.ZeroDigit)) {
354 if (CheckAttribute(value.Length == 1, compiler)) {
355 format.zeroDigit = value[0];
358 else if (Ref.Equal(name, input.Atoms.PatternSeparator)) {
359 if (CheckAttribute(value.Length == 1, compiler)) {
360 format.patternSeparator = value[0];
364 while(input.MoveToNextAttribute());
367 info.NegativeInfinitySymbol = String.Concat(info.NegativeSign, info.PositiveInfinitySymbol);
369 Name = new XmlQualifiedName();
371 compiler.AddDecimalFormat(Name, format);
372 CheckEmpty(compiler);
375 internal bool CheckAttribute(bool valid, Compiler compiler) {
377 if (! compiler.ForwardCompatibility) {
378 throw XsltException.Create(Res.Xslt_InvalidAttrValue, compiler.Input.LocalName, compiler.Input.Value);
385 protected void CompileSpace(Compiler compiler, bool preserve){
386 String value = compiler.GetSingleAttribute(compiler.Input.Atoms.Elements);
387 String[] elements = XmlConvert.SplitString(value);
388 for (int i = 0; i < elements.Length; i++){
389 double defaultPriority = NameTest(elements[i]);
390 compiler.CompiledStylesheet.AddSpace(compiler, elements[i], defaultPriority, preserve);
392 CheckEmpty(compiler);
395 double NameTest(String name) {
399 int idx = name.Length - 2;
400 if (0 <= idx && name[idx] == ':' && name[idx + 1] == '*') {
401 if (! PrefixQName.ValidatePrefix(name.Substring(0, idx))) {
402 throw XsltException.Create(Res.Xslt_InvalidAttrValue, "elements", name);
407 string prefix, localname;
408 PrefixQName.ParseQualifiedName(name, out prefix, out localname);
413 // SxS: This method does not take any resource name and does not expose any resources to the caller.
414 // It's OK to suppress the SxS warning.
415 [ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
416 [ResourceExposure(ResourceScope.None)]
417 protected void CompileTopLevelElements(Compiler compiler) {
418 // Navigator positioned at parent root, need to move to child and then back
419 if (compiler.Recurse() == false) {
423 NavigatorInput input = compiler.Input;
424 bool notFirstElement = false;
426 switch (input.NodeType) {
427 case XPathNodeType.Element:
428 string name = input.LocalName;
429 string nspace = input.NamespaceURI;
431 if (Ref.Equal(nspace, input.Atoms.UriXsl)) {
432 if (Ref.Equal(name, input.Atoms.Import)) {
433 if (notFirstElement) {
434 throw XsltException.Create(Res.Xslt_NotFirstImport);
436 // We should compile imports in reverse order after all toplevel elements.
437 // remember it now and return to it in CompileImpoorts();
438 Uri uri = compiler.ResolveUri(compiler.GetSingleAttribute(compiler.Input.Atoms.Href));
439 string resolved = uri.ToString();
440 if (compiler.IsCircularReference(resolved)) {
441 throw XsltException.Create(Res.Xslt_CircularInclude, resolved);
443 compiler.CompiledStylesheet.Imports.Add(uri);
444 CheckEmpty(compiler);
446 else if (Ref.Equal(name, input.Atoms.Include)) {
447 notFirstElement = true;
448 CompileInclude(compiler);
451 notFirstElement = true;
452 compiler.PushNamespaceScope();
453 if (Ref.Equal(name, input.Atoms.StripSpace)) {
454 CompileSpace(compiler, false);
456 else if (Ref.Equal(name, input.Atoms.PreserveSpace)) {
457 CompileSpace(compiler, true);
459 else if (Ref.Equal(name, input.Atoms.Output)) {
460 CompileOutput(compiler);
462 else if (Ref.Equal(name, input.Atoms.Key)) {
463 CompileKey(compiler);
465 else if (Ref.Equal(name, input.Atoms.DecimalFormat)) {
466 CompileDecimalFormat(compiler);
468 else if (Ref.Equal(name, input.Atoms.NamespaceAlias)) {
469 CompileNamespaceAlias(compiler);
471 else if (Ref.Equal(name, input.Atoms.AttributeSet)) {
472 compiler.AddAttributeSet(compiler.CreateAttributeSetAction());
474 else if (Ref.Equal(name, input.Atoms.Variable)) {
475 VariableAction action = compiler.CreateVariableAction(VariableType.GlobalVariable);
476 if (action != null) {
480 else if (Ref.Equal(name, input.Atoms.Param)) {
481 VariableAction action = compiler.CreateVariableAction(VariableType.GlobalParameter);
482 if (action != null) {
486 else if (Ref.Equal(name, input.Atoms.Template)) {
487 compiler.AddTemplate(compiler.CreateTemplateAction());
490 if (!compiler.ForwardCompatibility) {
491 throw compiler.UnexpectedKeyword();
497 #if !DISABLE_XSLT_SCRIPT
498 else if (nspace == input.Atoms.UrnMsxsl && name == input.Atoms.Script) {
503 if (nspace.Length == 0) {
504 throw XsltException.Create(Res.Xslt_NullNsAtTopLevel, input.Name);
506 // Ignoring non-recognized namespace per XSLT spec 2.2
510 case XPathNodeType.ProcessingInstruction:
511 case XPathNodeType.Comment:
512 case XPathNodeType.Whitespace:
513 case XPathNodeType.SignificantWhitespace:
517 throw XsltException.Create(Res.Xslt_InvalidContents, "stylesheet");
520 while (compiler.Advance());
525 protected void CompileTemplate(Compiler compiler) {
527 CompileOnceTemplate(compiler);
529 while (compiler.Advance());
532 protected void CompileOnceTemplate(Compiler compiler) {
533 NavigatorInput input = compiler.Input;
535 if (input.NodeType == XPathNodeType.Element) {
536 string nspace = input.NamespaceURI;
538 if (Ref.Equal(nspace, input.Atoms.UriXsl)) {
539 compiler.PushNamespaceScope();
540 CompileInstruction(compiler);
544 compiler.PushLiteralScope();
545 compiler.InsertExtensionNamespace();
546 if (compiler.IsExtensionNamespace(nspace)) {
547 AddAction(compiler.CreateNewInstructionAction());
550 CompileLiteral(compiler);
556 CompileLiteral(compiler);
560 void CompileInstruction(Compiler compiler) {
561 NavigatorInput input = compiler.Input;
562 CompiledAction action = null;
564 Debug.Assert(Ref.Equal(input.NamespaceURI, input.Atoms.UriXsl));
566 string name = input.LocalName;
568 if (Ref.Equal(name, input.Atoms.ApplyImports)) {
569 action = compiler.CreateApplyImportsAction();
571 else if (Ref.Equal(name, input.Atoms.ApplyTemplates)) {
572 action = compiler.CreateApplyTemplatesAction();
574 else if (Ref.Equal(name, input.Atoms.Attribute)) {
575 action = compiler.CreateAttributeAction();
577 else if (Ref.Equal(name, input.Atoms.CallTemplate)) {
578 action = compiler.CreateCallTemplateAction();
580 else if (Ref.Equal(name, input.Atoms.Choose)) {
581 action = compiler.CreateChooseAction();
583 else if (Ref.Equal(name, input.Atoms.Comment)) {
584 action = compiler.CreateCommentAction();
586 else if (Ref.Equal(name, input.Atoms.Copy)) {
587 action = compiler.CreateCopyAction();
589 else if (Ref.Equal(name, input.Atoms.CopyOf)) {
590 action = compiler.CreateCopyOfAction();
592 else if (Ref.Equal(name, input.Atoms.Element)) {
593 action = compiler.CreateElementAction();
595 else if (Ref.Equal(name, input.Atoms.Fallback)) {
598 else if (Ref.Equal(name, input.Atoms.ForEach)) {
599 action = compiler.CreateForEachAction();
601 else if (Ref.Equal(name, input.Atoms.If)) {
602 action = compiler.CreateIfAction(IfAction.ConditionType.ConditionIf);
604 else if (Ref.Equal(name, input.Atoms.Message)) {
605 action = compiler.CreateMessageAction();
607 else if (Ref.Equal(name, input.Atoms.Number)) {
608 action = compiler.CreateNumberAction();
610 else if (Ref.Equal(name, input.Atoms.ProcessingInstruction)) {
611 action = compiler.CreateProcessingInstructionAction();
613 else if (Ref.Equal(name, input.Atoms.Text)) {
614 action = compiler.CreateTextAction();
616 else if (Ref.Equal(name, input.Atoms.ValueOf)) {
617 action = compiler.CreateValueOfAction();
619 else if (Ref.Equal(name, input.Atoms.Variable)) {
620 action = compiler.CreateVariableAction(VariableType.LocalVariable);
623 if (compiler.ForwardCompatibility)
624 action = compiler.CreateNewInstructionAction();
626 throw compiler.UnexpectedKeyword();
629 Debug.Assert(action != null);
634 void CompileLiteral(Compiler compiler) {
635 NavigatorInput input = compiler.Input;
637 switch (input.NodeType) {
638 case XPathNodeType.Element:
639 this.AddEvent(compiler.CreateBeginEvent());
640 CompileLiteralAttributesAndNamespaces(compiler);
642 if (compiler.Recurse()) {
643 CompileTemplate(compiler);
647 this.AddEvent(new EndEvent(XPathNodeType.Element));
650 case XPathNodeType.Text:
651 case XPathNodeType.SignificantWhitespace:
652 this.AddEvent(compiler.CreateTextEvent());
654 case XPathNodeType.Whitespace:
655 case XPathNodeType.ProcessingInstruction:
656 case XPathNodeType.Comment:
660 Debug.Assert(false, "Unexpected node type.");
665 void CompileLiteralAttributesAndNamespaces(Compiler compiler) {
666 NavigatorInput input = compiler.Input;
668 if (input.Navigator.MoveToAttribute("use-attribute-sets", input.Atoms.UriXsl)) {
669 AddAction(compiler.CreateUseAttributeSetsAction());
670 input.Navigator.MoveToParent();
672 compiler.InsertExcludedNamespace();
674 if (input.MoveToFirstNamespace()) {
676 string uri = input.Value;
678 if (uri == XmlReservedNs.NsXslt) {
682 compiler.IsExcludedNamespace(uri) ||
683 compiler.IsExtensionNamespace(uri) ||
684 compiler.IsNamespaceAlias(uri)
688 this.AddEvent(new NamespaceEvent(input));
690 while (input.MoveToNextNamespace());
694 if (input.MoveToFirstAttribute()) {
697 // Skip everything from Xslt namespace
698 if (Ref.Equal(input.NamespaceURI, input.Atoms.UriXsl)) {
702 // Add attribute events
703 this.AddEvent (compiler.CreateBeginEvent());
704 this.AddEvents(compiler.CompileAvt(input.Value));
705 this.AddEvent (new EndEvent(XPathNodeType.Attribute));
707 while (input.MoveToNextAttribute());
712 void CompileOutput(Compiler compiler) {
713 Debug.Assert((object) this == (object) compiler.RootAction);
714 compiler.RootAction.Output.Compile(compiler);
717 internal void AddAction(Action action) {
718 if (this.containedActions == null) {
719 this.containedActions = new ArrayList();
721 this.containedActions.Add(action);
722 lastCopyCodeAction = null;
725 private void EnsureCopyCodeAction() {
726 if(lastCopyCodeAction == null) {
727 CopyCodeAction copyCode = new CopyCodeAction();
729 lastCopyCodeAction = copyCode;
733 protected void AddEvent(Event copyEvent) {
734 EnsureCopyCodeAction();
735 lastCopyCodeAction.AddEvent(copyEvent);
738 protected void AddEvents(ArrayList copyEvents) {
739 EnsureCopyCodeAction();
740 lastCopyCodeAction.AddEvents(copyEvents);
743 #if !DISABLE_XSLT_SCRIPT
744 private void AddScript(Compiler compiler) {
745 NavigatorInput input = compiler.Input;
747 ScriptingLanguage lang = ScriptingLanguage.JScript;
748 string implementsNamespace = null;
749 if (input.MoveToFirstAttribute()) {
751 if (input.LocalName == input.Atoms.Language) {
752 string langName = input.Value;
754 String.Compare(langName, "jscript" , StringComparison.OrdinalIgnoreCase) == 0 ||
755 String.Compare(langName, "javascript", StringComparison.OrdinalIgnoreCase) == 0
757 lang = ScriptingLanguage.JScript;
759 String.Compare(langName, "c#" , StringComparison.OrdinalIgnoreCase) == 0 ||
760 String.Compare(langName, "csharp", StringComparison.OrdinalIgnoreCase) == 0
762 lang = ScriptingLanguage.CSharp;
764 #if !FEATURE_PAL // visualbasic
766 String.Compare(langName, "vb" , StringComparison.OrdinalIgnoreCase) == 0 ||
767 String.Compare(langName, "visualbasic", StringComparison.OrdinalIgnoreCase) == 0
769 lang = ScriptingLanguage.VisualBasic;
771 #endif // !FEATURE_PAL
773 throw XsltException.Create(Res.Xslt_ScriptInvalidLanguage, langName);
776 else if (input.LocalName == input.Atoms.ImplementsPrefix) {
777 if(! PrefixQName.ValidatePrefix(input.Value)) {
778 throw XsltException.Create(Res.Xslt_InvalidAttrValue, input.LocalName, input.Value);
780 implementsNamespace = compiler.ResolveXmlNamespace(input.Value);
783 while (input.MoveToNextAttribute());
786 if (implementsNamespace == null) {
787 throw XsltException.Create(Res.Xslt_MissingAttribute, input.Atoms.ImplementsPrefix);
789 if (!input.Recurse() || input.NodeType != XPathNodeType.Text) {
790 throw XsltException.Create(Res.Xslt_ScriptEmpty);
792 compiler.AddScript(input.Value, lang, implementsNamespace, input.BaseURI, input.LineNumber);
797 internal override void Execute(Processor processor, ActionFrame frame) {
798 Debug.Assert(processor != null && frame != null);
800 switch (frame.State) {
802 if (this.containedActions != null && this.containedActions.Count > 0) {
803 processor.PushActionFrame(frame);
804 frame.State = ProcessingChildren;
809 break; // Allow children to run
811 case ProcessingChildren:
816 Debug.Fail("Invalid Container action execution state");
821 internal Action GetAction(int actionIndex) {
822 Debug.Assert(actionIndex == 0 || this.containedActions != null);
824 if (this.containedActions != null && actionIndex < this.containedActions.Count) {
825 return (Action) this.containedActions[actionIndex];
832 internal void CheckDuplicateParams(XmlQualifiedName name) {
833 if (this.containedActions != null) {
834 foreach(CompiledAction action in this.containedActions) {
835 WithParamAction param = action as WithParamAction;
836 if (param != null && param.Name == name) {
837 throw XsltException.Create(Res.Xslt_DuplicateWithParam, name.ToString());
843 internal override void ReplaceNamespaceAlias(Compiler compiler){
844 if (this.containedActions == null) {
847 int count = this.containedActions.Count;
848 for(int i= 0; i < this.containedActions.Count; i++) {
849 ((Action)this.containedActions[i]).ReplaceNamespaceAlias(compiler);