1 //------------------------------------------------------------------------------
2 // <copyright file="CompiledAction.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 abstract class CompiledAction : Action {
16 internal abstract void Compile(Compiler compiler);
18 internal virtual bool CompileAttribute(Compiler compiler) {
22 public void CompileAttributes(Compiler compiler) {
23 NavigatorInput input = compiler.Input;
24 string element = input.LocalName;
26 if (input.MoveToFirstAttribute()) {
28 if (input.NamespaceURI.Length != 0) continue;
31 if (CompileAttribute(compiler) == false) {
32 throw XsltException.Create(Res.Xslt_InvalidAttribute, input.LocalName, element);
35 if (! compiler.ForwardCompatibility) {
39 // In ForwardCompatibility mode we ignoreing all unknown or incorrect attributes
40 // If it's mandatory attribute we'l notice it absents later.
44 while (input.MoveToNextAttribute());
49 // For perf reason we precalculating AVTs at compile time.
50 // If we can do this we set original AVT to null
51 internal static string PrecalculateAvt(ref Avt avt) {
53 if(avt != null && avt.IsConstant) {
54 result = avt.Evaluate(null, null);
60 public void CheckEmpty(Compiler compiler) {
61 // Really EMPTY means no content at all, but the sake of compatibility with MSXML we allow whitespaces
62 string elementName = compiler.Input.Name;
63 if (compiler.Recurse()) {
65 // Note: <![CDATA[ ]]> will be reported as XPathNodeType.Text
66 XPathNodeType nodeType = compiler.Input.NodeType;
68 nodeType != XPathNodeType.Whitespace &&
69 nodeType != XPathNodeType.Comment &&
70 nodeType != XPathNodeType.ProcessingInstruction
72 throw XsltException.Create(Res.Xslt_NotEmptyContents, elementName);
75 while (compiler.Advance());
80 public void CheckRequiredAttribute(Compiler compiler, object attrValue, string attrName) {
81 CheckRequiredAttribute(compiler, attrValue != null, attrName);
84 public void CheckRequiredAttribute(Compiler compiler, bool attr, string attrName) {
86 throw XsltException.Create(Res.Xslt_MissingAttribute, attrName);