Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XsltOutput.cs
Go to the documentation of this file.
2using System.Text;
3
5
6internal sealed class XsltOutput : CompiledAction
7{
8 internal enum OutputMethod
9 {
10 Xml,
11 Html,
12 Text,
13 Other,
15 }
16
18
19 private int _methodSId = int.MaxValue;
20
22
23 private int _encodingSId = int.MaxValue;
24
25 private string _version;
26
27 private int _versionSId = int.MaxValue;
28
29 private bool _omitXmlDecl;
30
31 private int _omitXmlDeclSId = int.MaxValue;
32
33 private bool _standalone;
34
35 private int _standaloneSId = int.MaxValue;
36
37 private string _doctypePublic;
38
39 private int _doctypePublicSId = int.MaxValue;
40
41 private string _doctypeSystem;
42
43 private int _doctypeSystemSId = int.MaxValue;
44
45 private bool _indent;
46
47 private int _indentSId = int.MaxValue;
48
49 private string _mediaType = "text/html";
50
51 private int _mediaTypeSId = int.MaxValue;
52
54
56
58
59 internal bool HasStandalone => _standaloneSId != int.MaxValue;
60
61 internal bool Standalone => _standalone;
62
63 internal string DoctypePublic => _doctypePublic;
64
65 internal string DoctypeSystem => _doctypeSystem;
66
68
69 internal bool Indent => _indent;
70
72
73 internal string MediaType => _mediaType;
74
76 {
77 XsltOutput xsltOutput = (XsltOutput)MemberwiseClone();
79 if (method == OutputMethod.Html && _indentSId == int.MaxValue)
80 {
81 xsltOutput._indent = true;
82 }
83 return xsltOutput;
84 }
85
86 internal override void Compile(Compiler compiler)
87 {
90 }
91
92 internal override bool CompileAttribute(Compiler compiler)
93 {
94 string localName = compiler.Input.LocalName;
95 string value = compiler.Input.Value;
96 if (Ref.Equal(localName, compiler.Atoms.Method))
97 {
98 if (compiler.Stylesheetid <= _methodSId)
99 {
101 _methodSId = compiler.Stylesheetid;
102 if (_indentSId == int.MaxValue)
103 {
104 _indent = _method == OutputMethod.Html;
105 }
106 }
107 }
108 else if (Ref.Equal(localName, compiler.Atoms.Version))
109 {
110 if (compiler.Stylesheetid <= _versionSId)
111 {
112 _version = value;
113 _versionSId = compiler.Stylesheetid;
114 }
115 }
116 else if (Ref.Equal(localName, compiler.Atoms.Encoding))
117 {
118 if (compiler.Stylesheetid <= _encodingSId)
119 {
120 try
121 {
123 _encodingSId = compiler.Stylesheetid;
124 }
126 {
127 }
128 catch (ArgumentException)
129 {
130 }
131 }
132 }
133 else if (Ref.Equal(localName, compiler.Atoms.OmitXmlDeclaration))
134 {
135 if (compiler.Stylesheetid <= _omitXmlDeclSId)
136 {
137 _omitXmlDecl = compiler.GetYesNo(value);
138 _omitXmlDeclSId = compiler.Stylesheetid;
139 }
140 }
141 else if (Ref.Equal(localName, compiler.Atoms.Standalone))
142 {
143 if (compiler.Stylesheetid <= _standaloneSId)
144 {
145 _standalone = compiler.GetYesNo(value);
146 _standaloneSId = compiler.Stylesheetid;
147 }
148 }
149 else if (Ref.Equal(localName, compiler.Atoms.DocTypePublic))
150 {
151 if (compiler.Stylesheetid <= _doctypePublicSId)
152 {
154 _doctypePublicSId = compiler.Stylesheetid;
155 }
156 }
157 else if (Ref.Equal(localName, compiler.Atoms.DocTypeSystem))
158 {
159 if (compiler.Stylesheetid <= _doctypeSystemSId)
160 {
162 _doctypeSystemSId = compiler.Stylesheetid;
163 }
164 }
165 else if (Ref.Equal(localName, compiler.Atoms.Indent))
166 {
167 if (compiler.Stylesheetid <= _indentSId)
168 {
169 _indent = compiler.GetYesNo(value);
170 _indentSId = compiler.Stylesheetid;
171 }
172 }
173 else if (Ref.Equal(localName, compiler.Atoms.MediaType))
174 {
175 if (compiler.Stylesheetid <= _mediaTypeSId)
176 {
178 _mediaTypeSId = compiler.Stylesheetid;
179 }
180 }
181 else
182 {
183 if (!Ref.Equal(localName, compiler.Atoms.CDataSectionElements))
184 {
185 return false;
186 }
187 string[] array = XmlConvert.SplitString(value);
188 if (_cdataElements == null)
189 {
190 _cdataElements = new Hashtable(array.Length);
191 }
192 for (int i = 0; i < array.Length; i++)
193 {
194 XmlQualifiedName xmlQualifiedName = compiler.CreateXmlQName(array[i]);
196 }
197 }
198 return true;
199 }
200
201 internal override void Execute(Processor processor, ActionFrame frame)
202 {
203 }
204
206 {
208 if (xmlQualifiedName.Namespace.Length != 0)
209 {
210 return OutputMethod.Other;
211 }
212 switch (xmlQualifiedName.Name)
213 {
214 case "xml":
215 return OutputMethod.Xml;
216 case "html":
217 return OutputMethod.Html;
218 case "text":
219 return OutputMethod.Text;
220 default:
221 if (compiler.ForwardCompatibility)
222 {
223 return OutputMethod.Unknown;
224 }
226 }
227 }
228}
static string Xslt_InvalidAttrValue
Definition SR.cs:1884
Definition SR.cs:7
static Encoding UTF8
Definition Encoding.cs:526
static Encoding GetEncoding(int codepage)
Definition Encoding.cs:593
static bool Equal(string strA, string strB)
Definition Ref.cs:5
static string[] SplitString(string value)
static XsltException Create(string res, params string[] args)
void CompileAttributes(Compiler compiler)
static OutputMethod ParseOutputMethod(string value, Compiler compiler)
override bool CompileAttribute(Compiler compiler)
Definition XsltOutput.cs:92
override void Execute(Processor processor, ActionFrame frame)
override void Compile(Compiler compiler)
Definition XsltOutput.cs:86
XsltOutput CreateDerivedOutput(OutputMethod method)
Definition XsltOutput.cs:75