1 //------------------------------------------------------------------------------
2 // <copyright file="ChooseAction.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 ChooseAction
: ContainerAction
{
16 internal override void Compile(Compiler compiler
) {
17 CompileAttributes(compiler
);
19 if (compiler
.Recurse()) {
20 CompileConditions(compiler
);
25 private void CompileConditions(Compiler compiler
) {
26 NavigatorInput input
= compiler
.Input
;
28 bool otherwise
= false;
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
)) {
41 throw XsltException
.Create(Res
.Xslt_WhenAfterOtherwise
);
43 action
= compiler
.CreateIfAction(IfAction
.ConditionType
.ConditionWhen
);
46 else if (Ref
.Equal(name
, input
.Atoms
.Otherwise
)) {
48 throw XsltException
.Create(Res
.Xslt_DupOtherwise
);
50 action
= compiler
.CreateIfAction(IfAction
.ConditionType
.ConditionOtherwise
);
54 throw compiler
.UnexpectedKeyword();
59 throw compiler
.UnexpectedKeyword();
64 case XPathNodeType
.Comment
:
65 case XPathNodeType
.ProcessingInstruction
:
66 case XPathNodeType
.Whitespace
:
67 case XPathNodeType
.SignificantWhitespace
:
71 throw XsltException
.Create(Res
.Xslt_InvalidContents
, "choose");
74 while (compiler
.Advance());
76 throw XsltException
.Create(Res
.Xslt_NoWhen
);