Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XsltOutput.cs
Go to the documentation of this file.
1
using
System.Collections
;
2
using
System.Text
;
3
4
namespace
System.Xml.Xsl.XsltOld
;
5
6
internal
sealed
class
XsltOutput
:
CompiledAction
7
{
8
internal
enum
OutputMethod
9
{
10
Xml
,
11
Html
,
12
Text
,
13
Other
,
14
Unknown
15
}
16
17
private
OutputMethod
_method
=
OutputMethod
.Unknown;
18
19
private
int
_methodSId
=
int
.MaxValue;
20
21
private
Encoding
_encoding
=
Encoding
.
UTF8
;
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
53
private
Hashtable
_cdataElements
;
54
55
internal
OutputMethod
Method
=>
_method
;
56
57
internal
bool
OmitXmlDeclaration
=>
_omitXmlDecl
;
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
67
internal
Hashtable
CDataElements
=>
_cdataElements
;
68
69
internal
bool
Indent
=>
_indent
;
70
71
internal
Encoding
Encoding
=>
_encoding
;
72
73
internal
string
MediaType
=>
_mediaType
;
74
75
internal
XsltOutput
CreateDerivedOutput
(
OutputMethod
method
)
76
{
77
XsltOutput
xsltOutput
= (
XsltOutput
)MemberwiseClone();
78
xsltOutput._method
=
method
;
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
{
88
CompileAttributes
(
compiler
);
89
CheckEmpty
(
compiler
);
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
{
100
_method
=
ParseOutputMethod
(
value
,
compiler
);
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
{
122
_encoding
=
Encoding
.
GetEncoding
(
value
);
123
_encodingSId
=
compiler
.Stylesheetid;
124
}
125
catch
(
NotSupportedException
)
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
{
153
_doctypePublic
=
value
;
154
_doctypePublicSId
=
compiler
.Stylesheetid;
155
}
156
}
157
else
if
(
Ref
.
Equal
(localName,
compiler
.Atoms.DocTypeSystem))
158
{
159
if
(
compiler
.Stylesheetid <=
_doctypeSystemSId
)
160
{
161
_doctypeSystem
=
value
;
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
{
177
_mediaType
=
value
;
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]);
195
_cdataElements
[
xmlQualifiedName
] =
xmlQualifiedName
;
196
}
197
}
198
return
true
;
199
}
200
201
internal
override
void
Execute
(
Processor
processor
,
ActionFrame
frame)
202
{
203
}
204
205
private
static
OutputMethod
ParseOutputMethod
(
string
value
,
Compiler
compiler
)
206
{
207
XmlQualifiedName
xmlQualifiedName
=
compiler
.CreateXPathQName(
value
);
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
}
225
throw
XsltException
.
Create
(
System
.
SR
.
Xslt_InvalidAttrValue
,
"method"
,
value
);
226
}
227
}
228
}
System.ArgumentException
Definition
ArgumentException.cs:9
System.Collections.Hashtable
Definition
Hashtable.cs:13
System.NotSupportedException
Definition
NotSupportedException.cs:9
System.SR.Xslt_InvalidAttrValue
static string Xslt_InvalidAttrValue
Definition
SR.cs:1884
System.SR
Definition
SR.cs:7
System.Text.Encoding.UTF8
static Encoding UTF8
Definition
Encoding.cs:526
System.Text.Encoding.GetEncoding
static Encoding GetEncoding(int codepage)
Definition
Encoding.cs:593
System.Text.Encoding
Definition
Encoding.cs:15
System.Xml.Ref.Equal
static bool Equal(string strA, string strB)
Definition
Ref.cs:5
System.Xml.Ref
Definition
Ref.cs:4
System.Xml.XmlConvert.SplitString
static string[] SplitString(string value)
Definition
XmlConvert.cs:1228
System.Xml.XmlConvert
Definition
XmlConvert.cs:11
System.Xml.XmlQualifiedName
Definition
XmlQualifiedName.cs:6
System.Xml.Xsl.XsltException.Create
static XsltException Create(string res, params string[] args)
Definition
XsltException.cs:87
System.Xml.Xsl.XsltException
Definition
XsltException.cs:12
System.Xml.Xsl.XsltOld.ActionFrame
Definition
ActionFrame.cs:10
System.Xml.Xsl.XsltOld.CompiledAction.CheckEmpty
void CheckEmpty(Compiler compiler)
Definition
CompiledAction.cs:58
System.Xml.Xsl.XsltOld.CompiledAction.CompileAttributes
void CompileAttributes(Compiler compiler)
Definition
CompiledAction.cs:14
System.Xml.Xsl.XsltOld.CompiledAction
Definition
CompiledAction.cs:6
System.Xml.Xsl.XsltOld.Compiler
Definition
Compiler.cs:15
System.Xml.Xsl.XsltOld.Processor
Definition
Processor.cs:14
System.Xml.Xsl.XsltOld.XsltOutput._mediaType
string _mediaType
Definition
XsltOutput.cs:49
System.Xml.Xsl.XsltOld.XsltOutput.Standalone
bool Standalone
Definition
XsltOutput.cs:61
System.Xml.Xsl.XsltOld.XsltOutput.DoctypeSystem
string DoctypeSystem
Definition
XsltOutput.cs:65
System.Xml.Xsl.XsltOld.XsltOutput.ParseOutputMethod
static OutputMethod ParseOutputMethod(string value, Compiler compiler)
Definition
XsltOutput.cs:205
System.Xml.Xsl.XsltOld.XsltOutput._standalone
bool _standalone
Definition
XsltOutput.cs:33
System.Xml.Xsl.XsltOld.XsltOutput._indent
bool _indent
Definition
XsltOutput.cs:45
System.Xml.Xsl.XsltOld.XsltOutput.CDataElements
Hashtable CDataElements
Definition
XsltOutput.cs:67
System.Xml.Xsl.XsltOld.XsltOutput._omitXmlDeclSId
int _omitXmlDeclSId
Definition
XsltOutput.cs:31
System.Xml.Xsl.XsltOld.XsltOutput.CompileAttribute
override bool CompileAttribute(Compiler compiler)
Definition
XsltOutput.cs:92
System.Xml.Xsl.XsltOld.XsltOutput.Execute
override void Execute(Processor processor, ActionFrame frame)
Definition
XsltOutput.cs:201
System.Xml.Xsl.XsltOld.XsltOutput._doctypeSystemSId
int _doctypeSystemSId
Definition
XsltOutput.cs:43
System.Xml.Xsl.XsltOld.XsltOutput._encodingSId
int _encodingSId
Definition
XsltOutput.cs:23
System.Xml.Xsl.XsltOld.XsltOutput.Compile
override void Compile(Compiler compiler)
Definition
XsltOutput.cs:86
System.Xml.Xsl.XsltOld.XsltOutput.DoctypePublic
string DoctypePublic
Definition
XsltOutput.cs:63
System.Xml.Xsl.XsltOld.XsltOutput._omitXmlDecl
bool _omitXmlDecl
Definition
XsltOutput.cs:29
System.Xml.Xsl.XsltOld.XsltOutput.CreateDerivedOutput
XsltOutput CreateDerivedOutput(OutputMethod method)
Definition
XsltOutput.cs:75
System.Xml.Xsl.XsltOld.XsltOutput._indentSId
int _indentSId
Definition
XsltOutput.cs:47
System.Xml.Xsl.XsltOld.XsltOutput.Indent
bool Indent
Definition
XsltOutput.cs:69
System.Xml.Xsl.XsltOld.XsltOutput._encoding
Encoding _encoding
Definition
XsltOutput.cs:21
System.Xml.Xsl.XsltOld.XsltOutput._method
OutputMethod _method
Definition
XsltOutput.cs:17
System.Xml.Xsl.XsltOld.XsltOutput._cdataElements
Hashtable _cdataElements
Definition
XsltOutput.cs:53
System.Xml.Xsl.XsltOld.XsltOutput.OmitXmlDeclaration
bool OmitXmlDeclaration
Definition
XsltOutput.cs:57
System.Xml.Xsl.XsltOld.XsltOutput.OutputMethod
OutputMethod
Definition
XsltOutput.cs:9
System.Xml.Xsl.XsltOld.XsltOutput.OutputMethod.Html
@ Html
System.Xml.Xsl.XsltOld.XsltOutput.OutputMethod.Other
@ Other
System.Xml.Xsl.XsltOld.XsltOutput.OutputMethod.Unknown
@ Unknown
System.Xml.Xsl.XsltOld.XsltOutput.OutputMethod.Text
@ Text
System.Xml.Xsl.XsltOld.XsltOutput.OutputMethod.Xml
@ Xml
System.Xml.Xsl.XsltOld.XsltOutput.MediaType
string MediaType
Definition
XsltOutput.cs:73
System.Xml.Xsl.XsltOld.XsltOutput._mediaTypeSId
int _mediaTypeSId
Definition
XsltOutput.cs:51
System.Xml.Xsl.XsltOld.XsltOutput._doctypePublic
string _doctypePublic
Definition
XsltOutput.cs:37
System.Xml.Xsl.XsltOld.XsltOutput._doctypeSystem
string _doctypeSystem
Definition
XsltOutput.cs:41
System.Xml.Xsl.XsltOld.XsltOutput._standaloneSId
int _standaloneSId
Definition
XsltOutput.cs:35
System.Xml.Xsl.XsltOld.XsltOutput._version
string _version
Definition
XsltOutput.cs:25
System.Xml.Xsl.XsltOld.XsltOutput._methodSId
int _methodSId
Definition
XsltOutput.cs:19
System.Xml.Xsl.XsltOld.XsltOutput.HasStandalone
bool HasStandalone
Definition
XsltOutput.cs:59
System.Xml.Xsl.XsltOld.XsltOutput._doctypePublicSId
int _doctypePublicSId
Definition
XsltOutput.cs:39
System.Xml.Xsl.XsltOld.XsltOutput._versionSId
int _versionSId
Definition
XsltOutput.cs:27
System.Xml.Xsl.XsltOld.XsltOutput.Method
OutputMethod Method
Definition
XsltOutput.cs:55
System.Xml.Xsl.XsltOld.XsltOutput
Definition
XsltOutput.cs:7
System.Collections
Definition
BlockingCollection.cs:8
System.Text
Definition
ConsoleEncoding.cs:1
System.Xml.Xsl.XsltOld
Definition
IXsltDebugger.cs:1
System.Xml.ValueHandleType.Dictionary
@ Dictionary
System.ExceptionArgument.value
@ value
System.ExceptionArgument.array
@ array
System
Definition
BlockingCollection.cs:8
source
System.Private.Xml
System.Xml.Xsl.XsltOld
XsltOutput.cs
Generated by
1.10.0