Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
AttributeAction.cs
Go to the documentation of this file.
2
4
6{
7 private Avt _nameAvt;
8
9 private Avt _nsAvt;
10
12
13 private string _name;
14
15 private string _nsUri;
16
18
19 private static PrefixQName CreateAttributeQName(string name, string nsUri, InputScopeManager manager)
20 {
21 if (name == "xmlns")
22 {
23 return null;
24 }
25 if (nsUri == "http://www.w3.org/2000/xmlns/")
26 {
28 }
30 prefixQName.SetQName(name);
31 prefixQName.Namespace = ((nsUri != null) ? nsUri : manager.ResolveXPathNamespace(prefixQName.Prefix));
32 if (prefixQName.Prefix.StartsWith("xml", StringComparison.Ordinal))
33 {
34 if (prefixQName.Prefix.Length == 3)
35 {
36 if (!(prefixQName.Namespace == "http://www.w3.org/XML/1998/namespace") || (!(prefixQName.Name == "lang") && !(prefixQName.Name == "space")))
37 {
38 prefixQName.ClearPrefix();
39 }
40 }
41 else if (prefixQName.Prefix == "xmlns")
42 {
43 if (prefixQName.Namespace == "http://www.w3.org/2000/xmlns/")
44 {
46 }
47 prefixQName.ClearPrefix();
48 }
49 }
50 return prefixQName;
51 }
52
53 internal override void Compile(Compiler compiler)
54 {
59 if (_nameAvt == null && _nsAvt == null)
60 {
61 if (_name != "xmlns")
62 {
63 _qname = CreateAttributeQName(_name, _nsUri, compiler.CloneScopeManager());
64 }
65 }
66 else
67 {
68 _manager = compiler.CloneScopeManager();
69 }
70 if (compiler.Recurse())
71 {
73 compiler.ToParent();
74 }
75 }
76
77 internal override bool CompileAttribute(Compiler compiler)
78 {
79 string localName = compiler.Input.LocalName;
80 string value = compiler.Input.Value;
81 if (Ref.Equal(localName, compiler.Atoms.Name))
82 {
84 }
85 else
86 {
87 if (!Ref.Equal(localName, compiler.Atoms.Namespace))
88 {
89 return false;
90 }
92 }
93 return true;
94 }
95
96 internal override void Execute(Processor processor, ActionFrame frame)
97 {
98 switch (frame.State)
99 {
100 case 0:
101 if (_qname != null)
102 {
104 }
105 else
106 {
108 if (frame.CalulatedName == null)
109 {
110 frame.Finished();
111 break;
112 }
113 }
114 goto case 2;
115 case 2:
116 {
118 if (!processor.BeginEvent(XPathNodeType.Attribute, calulatedName.Prefix, calulatedName.Name, calulatedName.Namespace, empty: false))
119 {
120 frame.State = 2;
121 break;
122 }
123 processor.PushActionFrame(frame);
124 frame.State = 1;
125 break;
126 }
127 case 1:
128 if (!processor.EndEvent(XPathNodeType.Attribute))
129 {
130 frame.State = 1;
131 }
132 else
133 {
134 frame.Finished();
135 }
136 break;
137 }
138 }
139}
static string Xslt_ReservedNS
Definition SR.cs:1958
static string Xslt_InvalidPrefix
Definition SR.cs:1926
Definition SR.cs:7
static bool Equal(string strA, string strB)
Definition Ref.cs:5
static XsltException Create(string res, params string[] args)
override void Execute(Processor processor, ActionFrame frame)
override void Compile(Compiler compiler)
override bool CompileAttribute(Compiler compiler)
static PrefixQName CreateAttributeQName(string name, string nsUri, InputScopeManager manager)
string Evaluate(Processor processor, ActionFrame frame)
Definition Avt.cs:37
static Avt CompileAvt(Compiler compiler, string avtText)
Definition Avt.cs:52
void CompileAttributes(Compiler compiler)
void CheckRequiredAttribute(Compiler compiler, object attrValue, string attrName)
static string PrecalculateAvt(ref Avt avt)