Updates referencesource to .NET 4.7
[mono-project.git] / mcs / class / referencesource / System.Data.SqlXml / System / Xml / Xsl / XsltOld / ChooseAction.cs
blob85cc21906ab94fa43fdece25e4f30bbbb0d4cc9f
1 //------------------------------------------------------------------------------
2 // <copyright file="ChooseAction.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
4 // </copyright>
5 // <owner current="true" primary="true">Microsoft</owner>
6 //------------------------------------------------------------------------------
8 namespace System.Xml.Xsl.XsltOld {
9 using Res = System.Xml.Utils.Res;
10 using System;
11 using System.Diagnostics;
12 using System.Xml;
13 using System.Xml.XPath;
15 internal class ChooseAction : ContainerAction {
16 internal override void Compile(Compiler compiler) {
17 CompileAttributes(compiler);
19 if (compiler.Recurse()) {
20 CompileConditions(compiler);
21 compiler.ToParent();
25 private void CompileConditions(Compiler compiler) {
26 NavigatorInput input = compiler.Input;
27 bool when = false;
28 bool otherwise = false;
30 do {
31 switch (input.NodeType) {
32 case XPathNodeType.Element:
33 compiler.PushNamespaceScope();
34 string nspace = input.NamespaceURI;
35 string name = input.LocalName;
37 if (Ref.Equal(nspace, input.Atoms.UriXsl)) {
38 IfAction action = null;
39 if (Ref.Equal(name, input.Atoms.When)) {
40 if (otherwise) {
41 throw XsltException.Create(Res.Xslt_WhenAfterOtherwise);
43 action = compiler.CreateIfAction(IfAction.ConditionType.ConditionWhen);
44 when = true;
46 else if (Ref.Equal(name, input.Atoms.Otherwise)) {
47 if (otherwise) {
48 throw XsltException.Create(Res.Xslt_DupOtherwise);
50 action = compiler.CreateIfAction(IfAction.ConditionType.ConditionOtherwise);
51 otherwise = true;
53 else {
54 throw compiler.UnexpectedKeyword();
56 AddAction(action);
58 else {
59 throw compiler.UnexpectedKeyword();
61 compiler.PopScope();
62 break;
64 case XPathNodeType.Comment:
65 case XPathNodeType.ProcessingInstruction:
66 case XPathNodeType.Whitespace:
67 case XPathNodeType.SignificantWhitespace:
68 break;
70 default:
71 throw XsltException.Create(Res.Xslt_InvalidContents, "choose");
74 while (compiler.Advance());
75 if (! when) {
76 throw XsltException.Create(Res.Xslt_NoWhen);