Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XsltLoader.cs
Go to the documentation of this file.
3using System.IO;
4using System.Text;
7
8namespace System.Xml.Xsl.Xslt;
9
10internal sealed class XsltLoader : IErrorHelper
11{
12 private enum InstructionFlags
13 {
14 None = 0,
15 AllowParam = 1,
16 AllowSort = 2,
18 }
19
21
23
25
27
29
31
33
34 internal static QilName nullMode = AstFactory.QName(string.Empty);
35
36 public static int V1Opt = 1;
37
38 public static int V1Req = 2;
39
40 public static int V2Opt = 4;
41
42 public static int V2Req = 8;
43
45
47 {
48 new XsltInput.XsltAttribute("version", V1Req | V2Req),
50 new XsltInput.XsltAttribute("default-validation", V2Opt),
51 new XsltInput.XsltAttribute("input-type-annotations", V2Opt)
52 };
53
58
60 {
61 new XsltInput.XsltAttribute("elements", V1Req | V2Req)
62 };
63
65 {
66 new XsltInput.XsltAttribute("name", V2Opt),
67 new XsltInput.XsltAttribute("method", V1Opt | V2Opt),
68 new XsltInput.XsltAttribute("byte-order-mark", V2Opt),
69 new XsltInput.XsltAttribute("cdata-section-elements", V1Opt | V2Opt),
70 new XsltInput.XsltAttribute("doctype-public", V1Opt | V2Opt),
71 new XsltInput.XsltAttribute("doctype-system", V1Opt | V2Opt),
72 new XsltInput.XsltAttribute("encoding", V1Opt | V2Opt),
73 new XsltInput.XsltAttribute("escape-uri-attributes", V2Opt),
74 new XsltInput.XsltAttribute("include-content-type", V2Opt),
75 new XsltInput.XsltAttribute("indent", V1Opt | V2Opt),
76 new XsltInput.XsltAttribute("media-type", V1Opt | V2Opt),
77 new XsltInput.XsltAttribute("normalization-form", V2Opt),
78 new XsltInput.XsltAttribute("omit-xml-declaration", V1Opt | V2Opt),
79 new XsltInput.XsltAttribute("standalone", V1Opt | V2Opt),
80 new XsltInput.XsltAttribute("undeclare-prefixes", V2Opt),
81 new XsltInput.XsltAttribute("use-character-maps", V2Opt),
82 new XsltInput.XsltAttribute("version", V1Opt | V2Opt)
83 };
84
86 {
87 new XsltInput.XsltAttribute("name", V1Req | V2Req),
88 new XsltInput.XsltAttribute("match", V1Req | V2Req),
89 new XsltInput.XsltAttribute("use", V1Req | V2Opt),
90 new XsltInput.XsltAttribute("collation", V2Opt)
91 };
92
94 {
95 new XsltInput.XsltAttribute("name", V1Opt | V2Opt),
96 new XsltInput.XsltAttribute("infinity", V1Opt | V2Opt),
97 new XsltInput.XsltAttribute("NaN", V1Opt | V2Opt),
98 new XsltInput.XsltAttribute("decimal-separator", V1Opt | V2Opt),
99 new XsltInput.XsltAttribute("grouping-separator", V1Opt | V2Opt),
100 new XsltInput.XsltAttribute("percent", V1Opt | V2Opt),
101 new XsltInput.XsltAttribute("per-mille", V1Opt | V2Opt),
102 new XsltInput.XsltAttribute("zero-digit", V1Opt | V2Opt),
103 new XsltInput.XsltAttribute("digit", V1Opt | V2Opt),
104 new XsltInput.XsltAttribute("pattern-separator", V1Opt | V2Opt),
105 new XsltInput.XsltAttribute("minus-sign", V1Opt | V2Opt)
106 };
107
109 {
110 new XsltInput.XsltAttribute("stylesheet-prefix", V1Req | V2Req),
111 new XsltInput.XsltAttribute("result-prefix", V1Req | V2Req)
112 };
113
115 {
116 new XsltInput.XsltAttribute("name", V1Req | V2Req),
117 new XsltInput.XsltAttribute("use-attribute-sets", V1Opt | V2Opt)
118 };
119
121 {
122 new XsltInput.XsltAttribute("match", V1Opt | V2Opt),
123 new XsltInput.XsltAttribute("name", V1Opt | V2Opt),
124 new XsltInput.XsltAttribute("priority", V1Opt | V2Opt),
125 new XsltInput.XsltAttribute("mode", V1Opt | V2Opt),
126 new XsltInput.XsltAttribute("as", V2Opt)
127 };
128
130 {
131 new XsltInput.XsltAttribute("implements-prefix", V1Req | V2Req),
132 new XsltInput.XsltAttribute("language", V1Opt | V2Opt)
133 };
134
136 {
137 new XsltInput.XsltAttribute("name", V1Opt | V2Opt),
138 new XsltInput.XsltAttribute("href", V1Opt | V2Opt)
139 };
140
142 {
143 new XsltInput.XsltAttribute("namespace", V1Req | V2Req)
144 };
145
147
149 {
150 new XsltInput.XsltAttribute("select", V1Opt | V2Opt),
151 new XsltInput.XsltAttribute("mode", V1Opt | V2Opt)
152 };
153
155 {
156 new XsltInput.XsltAttribute("name", V1Req | V2Req)
157 };
158
160 {
161 new XsltInput.XsltAttribute("copy-namespaces", V2Opt),
162 new XsltInput.XsltAttribute("inherit-namespaces", V2Opt),
163 new XsltInput.XsltAttribute("use-attribute-sets", V1Opt | V2Opt),
164 new XsltInput.XsltAttribute("type", V2Opt),
165 new XsltInput.XsltAttribute("validation", V2Opt)
166 };
167
169 {
170 new XsltInput.XsltAttribute("select", V1Req | V2Req),
171 new XsltInput.XsltAttribute("copy-namespaces", V2Opt),
172 new XsltInput.XsltAttribute("type", V2Opt),
173 new XsltInput.XsltAttribute("validation", V2Opt)
174 };
175
177 {
178 new XsltInput.XsltAttribute("test", V1Req | V2Req)
179 };
180
182 {
183 new XsltInput.XsltAttribute("select", V1Req | V2Req)
184 };
185
187 {
188 new XsltInput.XsltAttribute("select", V2Opt),
189 new XsltInput.XsltAttribute("terminate", V1Opt | V2Opt)
190 };
191
193 {
194 new XsltInput.XsltAttribute("value", V1Opt | V2Opt),
195 new XsltInput.XsltAttribute("select", V2Opt),
196 new XsltInput.XsltAttribute("level", V1Opt | V2Opt),
197 new XsltInput.XsltAttribute("count", V1Opt | V2Opt),
198 new XsltInput.XsltAttribute("from", V1Opt | V2Opt),
199 new XsltInput.XsltAttribute("format", V1Opt | V2Opt),
200 new XsltInput.XsltAttribute("lang", V1Opt | V2Opt),
201 new XsltInput.XsltAttribute("letter-value", V1Opt | V2Opt),
202 new XsltInput.XsltAttribute("ordinal", V2Opt),
203 new XsltInput.XsltAttribute("grouping-separator", V1Opt | V2Opt),
204 new XsltInput.XsltAttribute("grouping-size", V1Opt | V2Opt)
205 };
206
208 {
209 new XsltInput.XsltAttribute("select", V1Req | V2Opt),
210 new XsltInput.XsltAttribute("separator", V2Opt),
211 new XsltInput.XsltAttribute("disable-output-escaping", V1Opt | V2Opt)
212 };
213
215 {
216 new XsltInput.XsltAttribute("name", V1Req | V2Req),
217 new XsltInput.XsltAttribute("select", V1Opt | V2Opt),
218 new XsltInput.XsltAttribute("as", V2Opt),
219 new XsltInput.XsltAttribute("required", 0),
220 new XsltInput.XsltAttribute("tunnel", 0)
221 };
222
224 {
225 new XsltInput.XsltAttribute("name", V1Req | V2Req),
226 new XsltInput.XsltAttribute("select", V1Opt | V2Opt),
227 new XsltInput.XsltAttribute("as", V2Opt),
228 new XsltInput.XsltAttribute("required", V2Opt),
229 new XsltInput.XsltAttribute("tunnel", V2Opt)
230 };
231
233 {
234 new XsltInput.XsltAttribute("name", V1Req | V2Req),
235 new XsltInput.XsltAttribute("select", V1Opt | V2Opt),
236 new XsltInput.XsltAttribute("as", V2Opt),
237 new XsltInput.XsltAttribute("required", 0),
238 new XsltInput.XsltAttribute("tunnel", V2Opt)
239 };
240
242 {
243 new XsltInput.XsltAttribute("select", V2Opt)
244 };
245
247 {
248 new XsltInput.XsltAttribute("name", V1Req | V2Req),
249 new XsltInput.XsltAttribute("select", V2Opt)
250 };
251
253 {
254 new XsltInput.XsltAttribute("disable-output-escaping", V1Opt | V2Opt)
255 };
256
258 {
259 new XsltInput.XsltAttribute("name", V1Req | V2Req),
260 new XsltInput.XsltAttribute("namespace", V1Opt | V2Opt),
261 new XsltInput.XsltAttribute("inherit-namespaces", V2Opt),
262 new XsltInput.XsltAttribute("use-attribute-sets", V1Opt | V2Opt),
263 new XsltInput.XsltAttribute("type", V2Opt),
264 new XsltInput.XsltAttribute("validation", V2Opt)
265 };
266
268 {
269 new XsltInput.XsltAttribute("name", V1Req | V2Req),
270 new XsltInput.XsltAttribute("namespace", V1Opt | V2Opt),
271 new XsltInput.XsltAttribute("select", V2Opt),
272 new XsltInput.XsltAttribute("separator", V2Opt),
273 new XsltInput.XsltAttribute("type", V2Opt),
274 new XsltInput.XsltAttribute("validation", V2Opt)
275 };
276
278 {
279 new XsltInput.XsltAttribute("select", V1Opt | V2Opt),
280 new XsltInput.XsltAttribute("lang", V1Opt | V2Opt),
281 new XsltInput.XsltAttribute("order", V1Opt | V2Opt),
282 new XsltInput.XsltAttribute("collation", V1Opt | V2Opt),
283 new XsltInput.XsltAttribute("stable", V1Opt | V2Opt),
284 new XsltInput.XsltAttribute("case-order", V1Opt | V2Opt),
285 new XsltInput.XsltAttribute("data-type", V1Opt | V2Opt)
286 };
287
288 private bool V1 => _compiler.Version == 1;
289
290 public void Load(Compiler compiler, object stylesheet, XmlResolver xmlResolver)
291 {
294 if (stylesheet is XmlReader reader)
295 {
297 Load(reader);
298 }
299 else if (stylesheet is string text)
300 {
303 {
305 }
306 Uri uri = xmlResolver2.ResolveUri(null, text);
307 if (uri == null)
308 {
310 }
313 using (reader2 = CreateReader(uri, xmlResolver2))
314 {
315 Load(reader2);
316 }
317 }
318 else if (stylesheet is IXPathNavigable iXPathNavigable)
319 {
322 Load(reader2);
323 }
326 foreach (AttributeSet value in compiler.AttributeSets.Values)
327 {
329 }
330 }
331
332 private void Load(XmlReader reader)
333 {
334 _atoms = new KeywordsTable(reader.NameTable);
336 LoadStylesheet(reader, include: false);
337 }
338
339 private void AtomizeAttributes(XsltInput.XsltAttribute[] attributes)
340 {
341 for (int i = 0; i < attributes.Length; i++)
342 {
343 attributes[i].name = _atoms.NameTable.Add(attributes[i].name);
344 }
345 }
346
380
381 private Uri ResolveUri(string relativeUri, string baseUri)
382 {
383 Uri baseUri2 = ((baseUri.Length != 0) ? _xmlResolver.ResolveUri(null, baseUri) : null);
385 if (uri == null)
386 {
388 }
389 return uri;
390 }
391
393 {
394 object entity = xmlResolver.GetEntity(uri, null, null);
395 if (entity is Stream stream)
396 {
398 }
399 if (entity is XmlReader result)
400 {
401 return result;
402 }
404 {
405 return XPathNavigatorReader.Create(iXPathNavigable.CreateNavigator());
406 }
407 throw new XslLoadException(System.SR.Xslt_CannotLoadStylesheet, uri.ToString(), (entity == null) ? "null" : entity.GetType().ToString());
408 }
409
411 {
412 using XmlReader reader = CreateReader(uri, _xmlResolver);
413 return LoadStylesheet(reader, include);
414 }
415
417 {
418 string baseURI = reader.BaseURI;
419 _documentUriInUse.Add(baseURI, null);
420 _compiler.AddModule(baseURI);
424 _input = new XsltInput(reader, _compiler, _atoms);
425 _curStylesheet = stylesheet;
426 try
427 {
428 LoadDocument();
429 if (!include)
430 {
434 int num = importHrefs.Count;
435 while (0 <= --num)
436 {
438 }
439 }
440 }
441 catch (XslLoadException)
442 {
443 throw;
444 }
445 catch (Exception ex2)
446 {
448 {
449 throw;
450 }
452 if (!(ex2 is XmlException { SourceUri: not null } ex3))
453 {
455 }
456 else
457 {
458 ISourceLineInfo sourceLineInfo2 = new SourceLineInfo(ex3.SourceUri, ex3.LineNumber, ex3.LinePosition, ex3.LineNumber, ex3.LinePosition);
460 }
462 throw new XslLoadException(ex2, lineInfo);
463 }
464 finally
465 {
466 _documentUriInUse.Remove(baseURI);
467 _input = input;
469 }
470 return stylesheet;
471 }
472
473 private void LoadDocument()
474 {
476 {
478 return;
479 }
481 {
483 {
485 }
486 else
487 {
490 }
491 }
492 else
493 {
495 }
496 _input.Finish();
497 }
498
500 {
501 _curTemplate = AstFactory.Template(null, "/", nullMode, double.NaN, _input.XslVersion);
504 if (xslNode != null)
505 {
506 SetLineInfo(_curTemplate, xslNode.SourceLine);
508 list.Add(xslNode);
511 }
512 _curTemplate = null;
513 }
514
515 private void LoadRealStylesheet()
516 {
522 {
523 return;
524 }
525 bool flag = true;
526 do
527 {
528 bool flag2 = false;
529 switch (_input.NodeType)
530 {
531 case XmlNodeType.Element:
533 {
535 {
536 if (!flag)
537 {
540 }
541 else
542 {
543 flag2 = true;
544 LoadImport();
545 }
546 }
547 else if (_input.IsKeyword(_atoms.Include))
548 {
549 LoadInclude();
550 }
552 {
553 LoadStripSpace(attributes.nsList);
554 }
556 {
557 LoadPreserveSpace(attributes.nsList);
558 }
559 else if (_input.IsKeyword(_atoms.Output))
560 {
561 LoadOutput();
562 }
563 else if (_input.IsKeyword(_atoms.Key))
564 {
565 LoadKey(attributes.nsList);
566 }
568 {
569 LoadDecimalFormat(attributes.nsList);
570 }
572 {
573 LoadNamespaceAlias(attributes.nsList);
574 }
576 {
577 LoadAttributeSet(attributes.nsList);
578 }
580 {
582 }
583 else if (_input.IsKeyword(_atoms.Param))
584 {
586 }
588 {
589 LoadTemplate(attributes.nsList);
590 }
591 else
592 {
595 {
597 }
599 }
600 }
602 {
603 LoadMsScript(attributes.nsList);
604 }
605 else
606 {
608 {
610 }
612 }
613 flag = flag2;
614 break;
615 default:
617 break;
618 case XmlNodeType.Whitespace:
619 case XmlNodeType.SignificantWhitespace:
620 break;
621 }
622 }
623 while (_input.MoveToNextSibling());
624 }
625
626 private void LoadImport()
627 {
629 if (_input.MoveToXsltAttribute(0, "href"))
630 {
633 {
635 }
636 else
637 {
639 }
640 }
642 }
643
644 private void LoadInclude()
645 {
647 if (_input.MoveToXsltAttribute(0, "href"))
648 {
651 {
653 }
654 else
655 {
656 LoadStylesheet(uri, include: true);
657 }
658 }
660 }
661
672
683
684 private void LoadOutput()
685 {
688 XmlWriterSettings settings = output.Settings;
691 if (qilName != null)
692 {
693 ReportNYI("xsl:output/@name");
694 }
695 if (_input.MoveToXsltAttribute(1, "method") && output.MethodPrec <= currentPrecedence)
696 {
701 {
702 if (currentPrecedence == output.MethodPrec && !output.Method.Equals(xmlQualifiedName))
703 {
705 }
709 }
710 }
711 TriState triState = ParseYesNoAttribute(2, "byte-order-mark");
712 if (triState != TriState.Unknown)
713 {
714 ReportNYI("xsl:output/@byte-order-mark");
715 }
716 if (_input.MoveToXsltAttribute(3, "cdata-section-elements"))
717 {
721 for (int i = 0; i < array.Length; i++)
722 {
723 list.Add(ResolveQName(ignoreDefaultNs: false, array[i]));
724 }
726 {
728 }
729 }
731 {
732 if (currentPrecedence == output.DocTypePublicPrec && settings.DocTypePublic != _input.Value)
733 {
735 }
738 }
739 if (_input.MoveToXsltAttribute(5, "doctype-system") && output.DocTypeSystemPrec <= currentPrecedence)
740 {
741 if (currentPrecedence == output.DocTypeSystemPrec && settings.DocTypeSystem != _input.Value)
742 {
744 }
747 }
748 if (_input.MoveToXsltAttribute(6, "encoding") && output.EncodingPrec <= currentPrecedence)
749 {
750 try
751 {
753 if (currentPrecedence == output.EncodingPrec && output.Encoding != _input.Value)
754 {
756 }
757 settings.Encoding = encoding;
760 }
761 catch (ArgumentException)
762 {
764 {
766 }
767 }
768 }
769 if (ParseYesNoAttribute(7, "escape-uri-attributes") == TriState.False)
770 {
771 ReportNYI("xsl:output/@escape-uri-attributes == flase()");
772 }
773 if (ParseYesNoAttribute(8, "include-content-type") == TriState.False)
774 {
775 ReportNYI("xsl:output/@include-content-type == flase()");
776 }
778 if (triState2 != TriState.Unknown && output.IndentPrec <= currentPrecedence)
779 {
780 bool flag = triState2 == TriState.True;
781 if (currentPrecedence == output.IndentPrec && settings.Indent != flag)
782 {
784 }
785 settings.Indent = flag;
787 }
788 if (_input.MoveToXsltAttribute(10, "media-type") && output.MediaTypePrec <= currentPrecedence)
789 {
790 if (currentPrecedence == output.MediaTypePrec && settings.MediaType != _input.Value)
791 {
793 }
796 }
797 if (_input.MoveToXsltAttribute(11, "normalization-form"))
798 {
799 ReportNYI("xsl:output/@normalization-form");
800 }
801 triState2 = ParseYesNoAttribute(12, "omit-xml-declaration");
802 if (triState2 != TriState.Unknown && output.OmitXmlDeclarationPrec <= currentPrecedence)
803 {
804 bool flag2 = triState2 == TriState.True;
805 if (currentPrecedence == output.OmitXmlDeclarationPrec && settings.OmitXmlDeclaration != flag2)
806 {
807 ReportWarning(System.SR.Xslt_AttributeRedefinition, "omit-xml-declaration");
808 }
811 }
812 triState2 = ParseYesNoAttribute(13, "standalone");
813 if (triState2 != TriState.Unknown && output.StandalonePrec <= currentPrecedence)
814 {
816 if (currentPrecedence == output.StandalonePrec && settings.Standalone != xmlStandalone)
817 {
819 }
822 }
823 if (ParseYesNoAttribute(14, "undeclare-prefixes") == TriState.True)
824 {
825 ReportNYI("xsl:output/@undeclare-prefixes == true()");
826 }
828 if (list2.Count != 0)
829 {
830 ReportNYI("xsl:output/@use-character-maps");
831 }
832 if (_input.MoveToXsltAttribute(16, "version") && output.VersionPrec <= currentPrecedence)
833 {
834 if (currentPrecedence == output.VersionPrec && output.Version != _input.Value)
835 {
837 }
840 }
842 }
843
845 {
847 XmlWriterSettings settings = output.Settings;
848 if (settings.OutputMethod == XmlOutputMethod.Html && output.IndentPrec == int.MinValue)
849 {
850 settings.Indent = true;
851 }
852 if (output.MediaTypePrec == int.MinValue)
853 {
854 settings.MediaType = ((settings.OutputMethod == XmlOutputMethod.Xml) ? "text/xml" : ((settings.OutputMethod == XmlOutputMethod.Html) ? "text/html" : ((settings.OutputMethod == XmlOutputMethod.Text) ? "text/plain" : null)));
855 }
856 }
857
859 {
860 foreach (XslNode item in list)
861 {
862 switch (item.NodeType)
863 {
864 case XslNodeType.UseAttributeSet:
865 {
867 {
869 }
870 break;
871 }
872 case XslNodeType.List:
874 break;
875 }
876 }
877 }
878
880 {
881 switch (attSet.CycleCheck)
882 {
883 case CycleCheck.NotStarted:
884 attSet.CycleCheck = CycleCheck.Processing;
886 attSet.CycleCheck = CycleCheck.Completed;
887 break;
888 default:
889 _compiler.ReportError(attSet.Content[0].SourceLine, System.SR.Xslt_CircularAttributeSet, attSet.Name.QualifiedName);
890 break;
891 case CycleCheck.Completed:
892 break;
893 }
894 }
895
897 {
901 string match = ParseStringAttribute(1, "match");
902 string text = ParseStringAttribute(2, "use");
905 List<XslNode> list = null;
906 if (V1)
907 {
908 if (text == null)
909 {
911 }
912 else
913 {
915 }
916 }
917 else
918 {
920 if (list.Count != 0)
921 {
923 }
924 if (text == null == (list.Count == 0))
925 {
927 }
928 else if (text == null)
929 {
930 ReportNYI("xsl:key[count(@use) = 0]");
931 }
932 }
933 Key item = (Key)SetInfo(AstFactory.Key(qilName, match, text, _input.XslVersion), null, attributes);
935 {
937 return;
938 }
939 List<Key> list2 = new List<Key>();
940 list2.Add(item);
941 _compiler.Keys.Add(list2);
942 }
943
945 {
949 if (_input.MoveToXsltAttribute(0, "name"))
950 {
954 {
956 }
957 }
958 else
959 {
961 }
962 string text = DecimalFormatDecl.Default.InfinitySymbol;
963 if (_input.MoveToXsltAttribute(1, "infinity"))
964 {
965 text = _input.Value;
966 }
967 string text2 = DecimalFormatDecl.Default.NanSymbol;
968 if (_input.MoveToXsltAttribute(2, "NaN"))
969 {
971 }
972 char[] characters = DecimalFormatDecl.Default.Characters;
973 char[] array = new char[8];
974 for (int i = 0; i < 8; i++)
975 {
976 array[i] = ParseCharAttribute(3 + i, _decimalFormatAttributes[3 + i].name, characters[i]);
977 }
978 for (int j = 0; j < 7; j++)
979 {
980 for (int k = j + 1; k < 7; k++)
981 {
982 if (array[j] == array[k])
983 {
986 break;
987 }
988 }
989 }
991 {
993 _input.MoveToXsltAttribute(1, "infinity");
995 _input.MoveToXsltAttribute(2, "NaN");
997 for (int l = 0; l < 8; l++)
998 {
1001 }
1002 }
1003 else
1004 {
1007 }
1009 }
1010
1012 {
1015 string text = null;
1016 string text2 = null;
1017 string text3 = null;
1018 if (_input.MoveToXsltAttribute(0, "stylesheet-prefix"))
1019 {
1020 if (_input.Value.Length == 0)
1021 {
1022 ReportError(System.SR.Xslt_EmptyNsAlias, "stylesheet-prefix");
1023 }
1024 else
1025 {
1026 text = _input.LookupXmlNamespace((_input.Value == "#default") ? string.Empty : _input.Value);
1027 }
1028 }
1029 if (_input.MoveToXsltAttribute(1, "result-prefix"))
1030 {
1031 if (_input.Value.Length == 0)
1032 {
1033 ReportError(System.SR.Xslt_EmptyNsAlias, "result-prefix");
1034 }
1035 else
1036 {
1037 text2 = ((_input.Value == "#default") ? string.Empty : _input.Value);
1039 }
1040 }
1043 {
1046 }
1047 }
1048
1050 {
1055 {
1059 {
1061 }
1062 }
1064 if (_input.MoveToXsltAttribute(1, "use-attribute-sets"))
1065 {
1067 }
1070 {
1071 do
1072 {
1073 switch (_input.NodeType)
1074 {
1075 case XmlNodeType.Element:
1077 {
1079 break;
1080 }
1082 _input.SkipNode();
1083 break;
1084 default:
1086 break;
1087 case XmlNodeType.Whitespace:
1088 case XmlNodeType.SignificantWhitespace:
1089 break;
1090 }
1091 }
1092 while (_input.MoveToNextSibling());
1093 }
1094 value.AddContent(SetInfo(AstFactory.List(), LoadEndTag(list), attributes));
1095 }
1096
1103
1105 {
1108 string text = ParseStringAttribute(0, "match");
1109 QilName name = ParseQNameAttribute(1);
1110 double num = double.NaN;
1111 if (_input.MoveToXsltAttribute(2, "priority"))
1112 {
1114 if (double.IsNaN(num) && !_input.ForwardCompatibility)
1115 {
1117 }
1118 }
1120 if (text == null)
1121 {
1124 mode = nullMode;
1125 if (_input.AttributeExists(2, "priority"))
1126 {
1127 if (V1)
1128 {
1130 }
1131 else
1132 {
1134 }
1135 }
1136 }
1137 if (_input.MoveToXsltAttribute(4, "as"))
1138 {
1139 ReportNYI("xsl:template/@as");
1140 }
1145 {
1147 }
1148 _curTemplate = null;
1149 }
1150
1152 {
1155 string text = null;
1156 if (_input.MoveToXsltAttribute(0, "implements-prefix"))
1157 {
1158 if (_input.Value.Length == 0)
1159 {
1160 ReportError(System.SR.Xslt_EmptyAttrValue, "implements-prefix", _input.Value);
1161 }
1162 else
1163 {
1165 if (text == "http://www.w3.org/1999/XSL/Transform")
1166 {
1168 text = null;
1169 }
1170 }
1171 }
1172 if (text == null)
1173 {
1175 }
1176 string text2 = ParseStringAttribute(1, "language");
1177 if (text2 == null)
1178 {
1179 text2 = "jscript";
1180 }
1182 {
1184 _input.SkipNode();
1185 return;
1186 }
1188 }
1189
1191 {
1193 }
1194
1196 {
1197 return LoadInstructions(new List<XslNode>(), flags);
1198 }
1199
1201 {
1202 return LoadInstructions(content, InstructionFlags.None);
1203 }
1204
1206 {
1208 {
1210 }
1213 {
1214 bool flag = true;
1215 int num = 0;
1216 do
1217 {
1218 XmlNodeType nodeType = _input.NodeType;
1220 if (nodeType != XmlNodeType.Element)
1221 {
1222 if (nodeType == XmlNodeType.Whitespace)
1223 {
1224 continue;
1225 }
1226 if (nodeType != XmlNodeType.SignificantWhitespace)
1227 {
1228 flag = false;
1229 }
1231 }
1232 else
1233 {
1234 string namespaceUri = _input.NamespaceUri;
1235 string localName = _input.LocalName;
1236 if (namespaceUri == _atoms.UriXsl)
1237 {
1239 if (instructionFlags != 0)
1240 {
1241 string text = (((flags & instructionFlags) == 0) ? System.SR.Xslt_UnexpectedElement : ((!flag) ? System.SR.Xslt_NotAtTop : null));
1242 if (text != null)
1243 {
1244 ReportError(text, _input.QualifiedName, elementName);
1245 flag = false;
1246 _input.SkipNode();
1247 continue;
1248 }
1249 }
1250 else
1251 {
1252 flag = false;
1253 }
1254 instruction = (Ref.Equal(localName, _atoms.ApplyImports) ? XslApplyImports() : (Ref.Equal(localName, _atoms.ApplyTemplates) ? XslApplyTemplates() : (Ref.Equal(localName, _atoms.CallTemplate) ? XslCallTemplate() : (Ref.Equal(localName, _atoms.Copy) ? XslCopy() : (Ref.Equal(localName, _atoms.CopyOf) ? XslCopyOf() : (Ref.Equal(localName, _atoms.Fallback) ? XslFallback() : (Ref.Equal(localName, _atoms.If) ? XslIf() : (Ref.Equal(localName, _atoms.Choose) ? XslChoose() : (Ref.Equal(localName, _atoms.ForEach) ? XslForEach() : (Ref.Equal(localName, _atoms.Message) ? XslMessage() : (Ref.Equal(localName, _atoms.Number) ? XslNumber() : (Ref.Equal(localName, _atoms.ValueOf) ? XslValueOf() : (Ref.Equal(localName, _atoms.Comment) ? XslComment() : (Ref.Equal(localName, _atoms.ProcessingInstruction) ? XslProcessingInstruction() : (Ref.Equal(localName, _atoms.Text) ? XslText() : (Ref.Equal(localName, _atoms.Element) ? XslElement() : (Ref.Equal(localName, _atoms.Attribute) ? XslAttribute() : (Ref.Equal(localName, _atoms.Variable) ? XslVarPar() : (Ref.Equal(localName, _atoms.Param) ? XslVarPar() : (Ref.Equal(localName, _atoms.Sort) ? XslSort(num++) : LoadUnknownXsltInstruction(elementName)))))))))))))))))))));
1255 }
1256 else
1257 {
1258 flag = false;
1260 }
1261 }
1262 AddInstruction(content, instruction);
1263 }
1264 while (_input.MoveToNextSibling());
1265 }
1267 return content;
1268 }
1269
1271 {
1275 {
1276 int num = 0;
1277 do
1278 {
1279 switch (_input.NodeType)
1280 {
1281 case XmlNodeType.Element:
1283 {
1287 }
1288 else if (flags == InstructionFlags.AllowSort && _input.IsXsltKeyword(_atoms.Sort))
1289 {
1290 AddInstruction(list, XslSort(num++));
1291 }
1292 else if (flags == InstructionFlags.AllowFallback && _input.IsXsltKeyword(_atoms.Fallback))
1293 {
1294 XslFallback();
1295 }
1296 else
1297 {
1299 _input.SkipNode();
1300 }
1301 break;
1302 default:
1304 break;
1305 case XmlNodeType.Whitespace:
1306 case XmlNodeType.SignificantWhitespace:
1307 break;
1308 }
1309 }
1310 while (_input.MoveToNextSibling());
1311 }
1312 return list;
1313 }
1314
1316 {
1319 {
1321 _input.SkipNode();
1322 return null;
1323 }
1325 attributes.SaveExtendedLineInfo(_input);
1326 if (V1)
1327 {
1328 if (list.Count != 0)
1329 {
1330 ISourceLineInfo sourceLine = list[0].SourceLine;
1332 {
1334 }
1336 }
1337 list = null;
1338 }
1339 else
1340 {
1341 if (list.Count != 0)
1342 {
1343 ReportNYI("xsl:apply-imports/xsl:with-param");
1344 }
1345 list = null;
1346 }
1348 }
1349
1351 {
1353 string text = ParseStringAttribute(0, "select");
1354 if (text == null)
1355 {
1356 text = "node()";
1357 }
1358 QilName mode = ParseModeAttribute(1);
1359 List<XslNode> content = LoadWithParams(InstructionFlags.AllowSort);
1360 attributes.SaveExtendedLineInfo(_input);
1361 return SetInfo(AstFactory.ApplyTemplates(mode, text, attributes, _input.XslVersion), content, attributes);
1362 }
1363
1365 {
1367 QilName name = ParseQNameAttribute(0);
1369 attributes.SaveExtendedLineInfo(_input);
1370 return SetInfo(AstFactory.CallTemplate(name, attributes), content, attributes);
1371 }
1372
1374 {
1376 bool flag = ParseYesNoAttribute(0, "copy-namespaces") != TriState.False;
1377 bool flag2 = ParseYesNoAttribute(1, "inherit-namespaces") != TriState.False;
1378 if (!flag)
1379 {
1380 ReportNYI("xsl:copy[@copy-namespaces = 'no']");
1381 }
1382 if (!flag2)
1383 {
1384 ReportNYI("xsl:copy[@inherit-namespaces = 'no']");
1385 }
1387 if (_input.MoveToXsltAttribute(2, "use-attribute-sets"))
1388 {
1390 }
1393 return SetInfo(AstFactory.Copy(), LoadEndTag(LoadInstructions(list)), attributes);
1394 }
1395
1397 {
1399 string select = ParseStringAttribute(0, "select");
1400 if (ParseYesNoAttribute(1, "copy-namespaces") == TriState.False)
1401 {
1402 ReportNYI("xsl:copy-of[@copy-namespaces = 'no']");
1403 }
1407 return SetInfo(AstFactory.CopyOf(select, _input.XslVersion), null, attributes);
1408 }
1409
1411 {
1413 _input.SkipNode();
1414 return null;
1415 }
1416
1417 private XslNode XslIf()
1418 {
1420 string test = ParseStringAttribute(0, "test");
1421 return SetInfo(AstFactory.If(test, _input.XslVersion), LoadInstructions(), attributes);
1422 }
1423
1425 {
1427 List<XslNode> content = new List<XslNode>();
1428 bool flag = false;
1429 bool flag2 = false;
1432 {
1433 do
1434 {
1435 switch (_input.NodeType)
1436 {
1437 case XmlNodeType.Element:
1438 {
1439 XslNode xslNode = null;
1441 {
1443 {
1444 if (flag)
1445 {
1447 _input.SkipNode();
1448 break;
1449 }
1450 flag2 = true;
1451 xslNode = XslIf();
1452 }
1454 {
1455 if (flag)
1456 {
1458 _input.SkipNode();
1459 break;
1460 }
1461 flag = true;
1463 }
1464 }
1465 if (xslNode == null)
1466 {
1468 _input.SkipNode();
1469 }
1470 else
1471 {
1472 AddInstruction(content, xslNode);
1473 }
1474 break;
1475 }
1476 default:
1478 break;
1479 case XmlNodeType.Whitespace:
1480 case XmlNodeType.SignificantWhitespace:
1481 break;
1482 }
1483 }
1484 while (_input.MoveToNextSibling());
1485 }
1487 return SetInfo(AstFactory.Choose(), content, attributes);
1488 }
1489
1491 {
1493 return SetInfo(AstFactory.Otherwise(), LoadInstructions(), attributes);
1494 }
1495
1497 {
1499 string select = ParseStringAttribute(0, "select");
1501 List<XslNode> content = LoadInstructions(InstructionFlags.AllowSort);
1502 attributes.SaveExtendedLineInfo(_input);
1503 return SetInfo(AstFactory.ForEach(select, attributes, _input.XslVersion), content, attributes);
1504 }
1505
1507 {
1509 string text = ParseStringAttribute(0, "select");
1510 bool term = ParseYesNoAttribute(1, "terminate") == TriState.True;
1512 if (list.Count != 0)
1513 {
1514 list = LoadEndTag(list);
1515 }
1516 if (text != null)
1517 {
1519 }
1520 return SetInfo(AstFactory.Message(term), list, attributes);
1521 }
1522
1524 {
1526 string value = ParseStringAttribute(0, "value");
1527 string text = ParseStringAttribute(1, "select");
1528 if (text != null)
1529 {
1530 ReportNYI("xsl:number/@select");
1531 }
1532 NumberLevel level = NumberLevel.Single;
1533 if (_input.MoveToXsltAttribute(2, "level"))
1534 {
1535 switch (_input.Value)
1536 {
1537 case "single":
1538 level = NumberLevel.Single;
1539 break;
1540 case "multiple":
1541 level = NumberLevel.Multiple;
1542 break;
1543 case "any":
1544 level = NumberLevel.Any;
1545 break;
1546 default:
1548 {
1550 }
1551 break;
1552 }
1553 }
1554 string count = ParseStringAttribute(3, "count");
1555 string from = ParseStringAttribute(4, "from");
1556 string text2 = ParseStringAttribute(5, "format");
1557 string lang = ParseStringAttribute(6, "lang");
1558 string letterValue = ParseStringAttribute(7, "letter-value");
1559 string value2 = ParseStringAttribute(8, "ordinal");
1560 if (!string.IsNullOrEmpty(value2))
1561 {
1562 ReportNYI("xsl:number/@ordinal");
1563 }
1564 string groupingSeparator = ParseStringAttribute(9, "grouping-separator");
1565 string groupingSize = ParseStringAttribute(10, "grouping-size");
1566 if (text2 == null)
1567 {
1568 text2 = "1";
1569 }
1572 }
1573
1575 {
1577 string text = ParseStringAttribute(0, "select");
1578 string text2 = ParseStringAttribute(1, "separator");
1579 bool flag = ParseYesNoAttribute(2, "disable-output-escaping") == TriState.True;
1580 if (text2 == null)
1581 {
1583 {
1584 text2 = ((text != null) ? " " : string.Empty);
1585 }
1586 }
1587 else
1588 {
1589 ReportNYI("xsl:value-of/@separator");
1590 }
1591 List<XslNode> list = null;
1592 if (V1)
1593 {
1594 if (text == null)
1595 {
1596 _input.SkipNode();
1597 return SetInfo(AstFactory.Error(XslLoadException.CreateMessage(attributes.lineInfo, System.SR.Xslt_MissingAttribute, "select")), null, attributes);
1598 }
1600 }
1601 else
1602 {
1603 list = LoadContent(text != null);
1605 if (list.Count != 0)
1606 {
1607 ReportNYI("xsl:value-of/*");
1608 list = null;
1609 }
1610 }
1611 return SetInfo(AstFactory.XslNode(flag ? XslNodeType.ValueOfDoe : XslNodeType.ValueOf, null, text, _input.XslVersion), null, attributes);
1612 }
1613
1615 {
1616 string localName = _input.LocalName;
1619 {
1623 });
1625 string text = ParseStringAttribute(1, "select");
1626 string text2 = ParseStringAttribute(2, "as");
1627 TriState triState = ParseYesNoAttribute(3, "required");
1628 if (triState == TriState.True)
1629 {
1630 ReportNYI("xsl:param/@required == true()");
1631 }
1632 if (text2 != null)
1633 {
1634 ReportNYI("xsl:param/@as");
1635 }
1636 TriState triState2 = ParseYesNoAttribute(4, "tunnel");
1637 if (triState2 != TriState.Unknown)
1638 {
1639 if (xslNodeType == XslNodeType.Param && _curTemplate == null)
1640 {
1642 {
1644 }
1645 }
1646 else if (triState2 == TriState.True)
1647 {
1648 ReportNYI("xsl:param/@tunnel == true()");
1649 }
1650 }
1652 CheckError(triState == TriState.True && (text != null || list.Count != 0), System.SR.Xslt_RequiredAndSelect, qilName.ToString());
1654 SetInfo(varPar, list, attributes);
1655 return varPar;
1656 }
1657
1659 {
1661 string text = ParseStringAttribute(0, "select");
1662 if (text != null)
1663 {
1664 ReportNYI("xsl:comment/@select");
1665 }
1666 return SetInfo(AstFactory.Comment(), LoadContent(text != null), attributes);
1667 }
1668
1670 {
1673 CheckError(hasSelect && list.Count != 0, System.SR.Xslt_ElementCntSel, elementName);
1674 if (list.Count != 0)
1675 {
1676 list = LoadEndTag(list);
1677 }
1678 return list;
1679 }
1680
1682 {
1684 string name = ParseNCNameAttribute(0);
1685 string text = ParseStringAttribute(1, "select");
1686 if (text != null)
1687 {
1688 ReportNYI("xsl:processing-instruction/@select");
1689 }
1690 return SetInfo(AstFactory.PI(name, _input.XslVersion), LoadContent(text != null), attributes);
1691 }
1692
1694 {
1696 SerializationHints hints = ((ParseYesNoAttribute(0, "disable-output-escaping") == TriState.True) ? SerializationHints.DisableOutputEscaping : SerializationHints.None);
1700 {
1701 do
1702 {
1703 XmlNodeType nodeType = _input.NodeType;
1704 if (nodeType == XmlNodeType.Text || (uint)(nodeType - 13) <= 1u)
1705 {
1707 continue;
1708 }
1710 _input.SkipNode();
1711 }
1712 while (_input.MoveToNextSibling());
1713 }
1714 return SetInfo(AstFactory.List(), list, attributes);
1715 }
1716
1718 {
1720 string nameAvt = ParseNCNameAttribute(0);
1721 string text = ParseStringAttribute(1, "namespace");
1722 CheckError(text == "http://www.w3.org/2000/xmlns/", System.SR.Xslt_ReservedNS, text);
1723 if (ParseYesNoAttribute(2, "inherit-namespaces") == TriState.False)
1724 {
1725 ReportNYI("xsl:copy[@inherit-namespaces = 'no']");
1726 }
1730 if (_input.MoveToXsltAttribute(3, "use-attribute-sets"))
1731 {
1733 }
1735 }
1736
1738 {
1740 string nameAvt = ParseNCNameAttribute(0);
1741 string text = ParseStringAttribute(1, "namespace");
1742 CheckError(text == "http://www.w3.org/2000/xmlns/", System.SR.Xslt_ReservedNS, text);
1743 string text2 = ParseStringAttribute(2, "select");
1744 if (text2 != null)
1745 {
1746 ReportNYI("xsl:attribute/@select");
1747 }
1748 string text3 = ParseStringAttribute(3, "separator");
1749 if (text3 != null)
1750 {
1751 ReportNYI("xsl:attribute/@separator");
1752 }
1753 text3 = ((text3 != null) ? text3 : ((text2 != null) ? " " : string.Empty));
1756 return SetInfo(AstFactory.Attribute(nameAvt, text, _input.XslVersion), LoadContent(text2 != null), attributes);
1757 }
1758
1760 {
1762 string text = ParseStringAttribute(0, "select");
1763 string lang = ParseStringAttribute(1, "lang");
1764 string order = ParseStringAttribute(2, "order");
1766 TriState triState = ParseYesNoAttribute(4, "stable");
1767 string caseOrder = ParseStringAttribute(5, "case-order");
1768 string dataType = ParseStringAttribute(6, "data-type");
1769 if (triState != TriState.Unknown)
1770 {
1772 }
1773 List<XslNode> list = null;
1774 if (V1)
1775 {
1777 }
1778 else
1779 {
1780 list = LoadContent(text != null);
1781 if (list.Count != 0)
1782 {
1783 ReportNYI("xsl:sort/*");
1784 list = null;
1785 }
1786 }
1787 if (text == null)
1788 {
1789 text = ".";
1790 }
1791 return SetInfo(AstFactory.Sort(text, lang, dataType, order, caseOrder, _input.XslVersion), null, attributes);
1792 }
1793
1795 {
1796 string prefix = _input.Prefix;
1797 string localName = _input.LocalName;
1798 string namespaceUri = _input.NamespaceUri;
1800 if (_input.IsExtensionNamespace(namespaceUri))
1801 {
1802 return SetInfo(AstFactory.List(), LoadFallbacks(localName), literalAttributes);
1803 }
1805 for (int i = 1; _input.MoveToLiteralAttribute(i); i++)
1806 {
1808 {
1810 }
1811 }
1812 for (int j = 1; _input.MoveToLiteralAttribute(j); j++)
1813 {
1814 if (!_input.IsXsltNamespace())
1815 {
1818 }
1819 }
1821 return SetInfo(AstFactory.LiteralElement(AstFactory.QName(localName, namespaceUri, prefix)), list, literalAttributes);
1822 }
1823
1825 {
1826 foreach (XslNode item in content)
1827 {
1828 if (item.NodeType == XslNodeType.WithParam && item.Name.Equals(withParam.Name))
1829 {
1831 break;
1832 }
1833 }
1834 }
1835
1836 private static void AddInstruction(List<XslNode> content, XslNode instruction)
1837 {
1838 if (instruction != null)
1839 {
1840 content.Add(instruction);
1841 }
1842 }
1843
1845 {
1847 {
1849 }
1850 return content;
1851 }
1852
1854 {
1857 {
1859 _input.SkipNode();
1860 return null;
1861 }
1864 return SetInfo(AstFactory.List(), content, attributes);
1865 }
1866
1868 {
1873 {
1874 do
1875 {
1877 {
1879 list.Add(SetInfo(AstFactory.List(), LoadInstructions(), attributes));
1880 }
1881 else
1882 {
1883 _input.SkipNode();
1884 }
1885 }
1886 while (_input.MoveToNextSibling());
1887 }
1888 if (list.Count == 0)
1889 {
1891 }
1892 return list;
1893 }
1894
1896 {
1897 if (!_input.MoveToXsltAttribute(attNum, "mode"))
1898 {
1899 return nullMode;
1900 }
1902 string value = _input.Value;
1903 QilName result;
1904 if (!V1 && value == "#default")
1905 {
1906 result = nullMode;
1907 }
1908 else if (!V1 && value == "#current")
1909 {
1910 ReportNYI("xsl:apply-templates[@mode='#current']");
1911 result = nullMode;
1912 }
1913 else if (!V1 && value == "#all")
1914 {
1916 result = nullMode;
1917 }
1918 else
1919 {
1920 result = CreateXPathQName(value);
1921 }
1923 {
1924 result = nullMode;
1925 }
1926 return result;
1927 }
1928
1930 {
1931 if (!_input.MoveToXsltAttribute(attNum, "mode"))
1932 {
1933 return nullMode;
1934 }
1935 string value = _input.Value;
1936 if (value == "#all")
1937 {
1938 ReportNYI("xsl:template[@mode='#all']");
1939 return nullMode;
1940 }
1941 string[] array = XmlConvert.SplitString(value);
1942 List<QilName> list = new List<QilName>(array.Length);
1944 if (array.Length == 0)
1945 {
1947 }
1948 else
1949 {
1950 string[] array2 = array;
1951 foreach (string text in array2)
1952 {
1954 bool flag;
1955 switch (text)
1956 {
1957 case "#default":
1958 qilName = nullMode;
1959 goto IL_00e6;
1960 case "#current":
1961 ReportNYI("xsl:apply-templates[@mode='#current']");
1962 break;
1963 case "#all":
1965 break;
1966 default:
1967 {
1969 goto IL_00e6;
1970 }
1971 IL_00e6:
1972 flag = false;
1973 foreach (QilName item in list)
1974 {
1975 flag |= item.Equals(qilName);
1976 }
1977 if (flag)
1978 {
1980 }
1981 else
1982 {
1983 list.Add(qilName);
1984 }
1985 continue;
1986 }
1987 break;
1988 }
1989 }
1991 {
1992 list.Clear();
1993 list.Add(nullMode);
1994 }
1995 if (1 < list.Count)
1996 {
1997 ReportNYI("Multipe modes");
1998 return nullMode;
1999 }
2000 if (list.Count == 0)
2001 {
2002 return nullMode;
2003 }
2004 return list[0];
2005 }
2006
2008 {
2009 if (_input.MoveToXsltAttribute(attNum, "collation"))
2010 {
2011 ReportNYI("@collation");
2012 }
2013 return null;
2014 }
2015
2016 private bool ResolveQName(bool ignoreDefaultNs, string qname, out string localName, out string namespaceName, out string prefix)
2017 {
2018 if (qname == null)
2019 {
2021 localName = _compiler.PhantomNCName;
2023 return false;
2024 }
2025 if (!_compiler.ParseQName(qname, out prefix, out localName, this))
2026 {
2028 return false;
2029 }
2030 if (ignoreDefaultNs && prefix.Length == 0)
2031 {
2032 namespaceName = string.Empty;
2033 }
2034 else
2035 {
2037 if (namespaceName == null)
2038 {
2040 return false;
2041 }
2042 }
2043 return true;
2044 }
2045
2047 {
2048 bool flag = _input.IsRequiredAttribute(attNum);
2049 QilName qilName = null;
2050 if (!flag)
2051 {
2053 }
2055 {
2057 }
2058 if (!flag)
2059 {
2061 }
2062 if (qilName == null && flag)
2063 {
2065 }
2066 return qilName;
2067 }
2068
2069 private string ParseNCNameAttribute(int attNum)
2070 {
2071 if (_input.MoveToXsltAttribute(attNum, "name"))
2072 {
2073 return _input.Value;
2074 }
2075 return _compiler.PhantomNCName;
2076 }
2077
2078 private QilName CreateXPathQName(string qname)
2079 {
2080 ResolveQName(ignoreDefaultNs: true, qname, out var localName, out var namespaceName, out var prefix);
2081 return AstFactory.QName(localName, namespaceName, prefix);
2082 }
2083
2085 {
2087 return new XmlQualifiedName(localName, namespaceName);
2088 }
2089
2090 private void ParseWhitespaceRules(string elements, bool preserveSpace)
2091 {
2092 if (elements == null || elements.Length == 0)
2093 {
2094 return;
2095 }
2096 string[] array = XmlConvert.SplitString(elements);
2097 for (int i = 0; i < array.Length; i++)
2098 {
2099 string text;
2100 if (!_compiler.ParseNameTest(array[i], out var prefix, out var localName, this))
2101 {
2103 }
2104 else if (prefix == null || prefix.Length == 0)
2105 {
2106 text = prefix;
2107 }
2108 else
2109 {
2111 if (text == null)
2112 {
2114 }
2115 }
2116 int index = ((localName == null) ? 1 : 0) + ((text == null) ? 1 : 0);
2118 }
2119 }
2120
2122 {
2124 method = XmlOutputMethod.AutoDetect;
2126 {
2127 return null;
2128 }
2129 if (prefix.Length == 0)
2130 {
2131 switch (localName)
2132 {
2133 case "xml":
2134 method = XmlOutputMethod.Xml;
2135 break;
2136 case "html":
2137 method = XmlOutputMethod.Html;
2138 break;
2139 case "text":
2140 method = XmlOutputMethod.Text;
2141 break;
2142 default:
2144 return null;
2145 }
2146 }
2147 else if (!_input.ForwardCompatibility)
2148 {
2150 }
2151 return new XmlQualifiedName(localName, namespaceName);
2152 }
2153
2155 {
2158 foreach (string qname in array)
2159 {
2161 }
2163 {
2164 list.Clear();
2165 }
2166 }
2167
2169 {
2171 if (_input.MoveToXsltAttribute(attNum, "use-character-maps"))
2172 {
2175 foreach (string qname in array)
2176 {
2177 list.Add(CreateXPathQName(qname));
2178 }
2180 {
2181 list.Clear();
2182 }
2183 }
2184 return list;
2185 }
2186
2187 private string ParseStringAttribute(int attNum, string attName)
2188 {
2190 {
2191 return _input.Value;
2192 }
2193 return null;
2194 }
2195
2196 private char ParseCharAttribute(int attNum, string attName, char defVal)
2197 {
2199 {
2200 if (_input.Value.Length == 1)
2201 {
2202 return _input.Value[0];
2203 }
2205 {
2207 }
2208 }
2209 return defVal;
2210 }
2211
2213 {
2215 {
2216 string value = _input.Value;
2217 if (value == "yes")
2218 {
2219 return TriState.True;
2220 }
2221 if (value == "no")
2222 {
2223 return TriState.False;
2224 }
2226 {
2228 }
2229 }
2230 return TriState.Unknown;
2231 }
2232
2233 private void ParseTypeAttribute(int attNum)
2234 {
2235 if (_input.MoveToXsltAttribute(attNum, "type"))
2236 {
2238 }
2239 }
2240
2242 {
2243 string text = (defVal ? _atoms.DefaultValidation : "validation");
2245 {
2246 return;
2247 }
2248 string value = _input.Value;
2249 switch (value)
2250 {
2251 case "strict":
2252 if (defVal)
2253 {
2254 goto default;
2255 }
2256 goto case "preserve";
2257 default:
2258 if (!(value == "lax") || defVal)
2259 {
2260 break;
2261 }
2262 goto case "preserve";
2263 case "preserve":
2265 return;
2266 }
2268 {
2270 }
2271 }
2272
2274 {
2275 if (!_input.MoveToXsltAttribute(attNum, "input-type-annotations"))
2276 {
2277 return;
2278 }
2279 string value = _input.Value;
2280 switch (value)
2281 {
2282 case "strip":
2283 case "preserve":
2284 if (_compiler.inputTypeAnnotations == null)
2285 {
2287 }
2288 else
2289 {
2291 }
2292 return;
2293 }
2295 {
2296 ReportError(System.SR.Xslt_InvalidAttrValue, "input-type-annotations", value);
2297 }
2298 }
2299
2300 private void CheckNoContent()
2301 {
2305 if (sourceLineInfo != null)
2306 {
2308 }
2309 }
2310
2312 {
2315 {
2316 do
2317 {
2318 if (_input.NodeType != XmlNodeType.Whitespace)
2319 {
2320 if (sourceLineInfo == null)
2321 {
2323 }
2324 _input.SkipNode();
2325 }
2326 }
2327 while (_input.MoveToNextSibling());
2328 }
2329 return sourceLineInfo;
2330 }
2331
2333 {
2334 node.SourceLine = lineInfo;
2335 return node;
2336 }
2337
2338 private static void SetContent(XslNode node, List<XslNode> content)
2339 {
2340 if (content != null && content.Count == 0)
2341 {
2342 content = null;
2343 }
2344 node.SetContent(content);
2345 }
2346
2348 {
2349 to.Namespaces = info.nsList;
2350 SetContent(to, content);
2351 SetLineInfo(to, info.lineInfo);
2352 return to;
2353 }
2354
2356 {
2357 if (parentList == null)
2358 {
2359 return thisList;
2360 }
2361 if (thisList == null)
2362 {
2363 return parentList;
2364 }
2365 while (parentList != null)
2366 {
2367 bool flag = false;
2368 for (NsDecl nsDecl = thisList; nsDecl != null; nsDecl = nsDecl.Prev)
2369 {
2370 if (Ref.Equal(nsDecl.Prefix, parentList.Prefix) && (nsDecl.Prefix != null || nsDecl.NsUri == parentList.NsUri))
2371 {
2372 flag = true;
2373 break;
2374 }
2375 }
2376 if (!flag)
2377 {
2378 thisList = new NsDecl(thisList, parentList.Prefix, parentList.NsUri);
2379 }
2380 parentList = parentList.Prev;
2381 }
2382 return thisList;
2383 }
2384
2385 public void ReportError(string res, params string[] args)
2386 {
2388 }
2389
2390 public void ReportWarning(string res, params string[] args)
2391 {
2393 }
2394
2395 private void ReportNYI(string arg)
2396 {
2398 {
2400 }
2401 }
2402
2403 public void CheckError(bool cond, string res, params string[] args)
2404 {
2405 if (cond)
2406 {
2408 }
2409 }
2410}
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
void AddRange(IEnumerable< KeyValuePair< TKey, TValue > > collection)
void Add(TKey key, TValue value)
static string Xslt_ModeListDup
Definition SR.cs:1948
static string Xslt_ModeListAll
Definition SR.cs:1950
static string Xslt_NonTemplateTunnel
Definition SR.cs:2006
static string Xslt_ReservedNS
Definition SR.cs:1958
static string Xslt_RequiredAndSelect
Definition SR.cs:2002
static string Xslt_MissingAttribute
Definition SR.cs:1882
static string Xslt_InputTypeAnnotations
Definition SR.cs:2014
static string Xslt_EmptyNsAlias
Definition SR.cs:1912
static string Xslt_BistateAttribute
Definition SR.cs:1886
static string Xslt_PriorityWithoutMatch
Definition SR.cs:1952
static string Xslt_EmptyAttrValue
Definition SR.cs:1910
static string Xslt_NoSelectNoContent
Definition SR.cs:2004
static string Xslt_DupTemplateName
Definition SR.cs:1898
static string Xslt_CharAttribute
Definition SR.cs:1888
static string Xslt_InvalidMethod
Definition SR.cs:1970
static string Xslt_InvalidApplyImports
Definition SR.cs:1954
static string Xslt_WrongStylesheetElement
Definition SR.cs:1866
static string Xslt_DupOtherwise
Definition SR.cs:1966
static string Xslt_InvalidAttrValue
Definition SR.cs:1884
static string Xslt_ModeListEmpty
Definition SR.cs:1946
static string Xslt_SortStable
Definition SR.cs:2012
static string Xslt_NoWhen
Definition SR.cs:1962
static string Xslt_BothMatchNameAbsent
Definition SR.cs:1900
static string Xslt_NotAtTop
Definition SR.cs:1870
static string Xslt_KeyCntUse
Definition SR.cs:1896
static string Xslt_AttributeRedefinition
Definition SR.cs:1968
static string Xslt_CantResolve
Definition SR.cs:2078
static string Xslt_NullNsAtTopLevel
Definition SR.cs:1874
static string Xslt_NotEmptyContents
Definition SR.cs:1878
static string Xslt_DupGlobalVariable
Definition SR.cs:1904
static string Xslt_InputTooComplex
Definition SR.cs:1862
static string Xslt_WhenAfterOtherwise
Definition SR.cs:1964
static string Xslt_UnknownExtensionElement
Definition SR.cs:1942
static string Xslt_CircularInclude
Definition SR.cs:1890
static string Xslt_SchemaAttributeValue
Definition SR.cs:1998
static string Xslt_DupNsAlias
Definition SR.cs:1908
static string Xslt_NotYetImplemented
Definition SR.cs:1994
static string Xslt_TextNodesNotAllowed
Definition SR.cs:1876
static string Xslt_DecimalFormatRedefined
Definition SR.cs:1940
static string Xslt_InvalidEncoding
Definition SR.cs:1972
static string Xslt_SchemaAttribute
Definition SR.cs:1996
static string Xslt_ScriptXsltNamespace
Definition SR.cs:1928
static string Xslt_ModeWithoutMatch
Definition SR.cs:1944
static string Xslt_CircularAttributeSet
Definition SR.cs:1922
static string Xslt_CannotLoadStylesheet
Definition SR.cs:1864
static string CompilingScriptsNotSupported
Definition SR.cs:2148
static string Xslt_ElementCntSel
Definition SR.cs:2000
static string Xslt_DecimalFormatSignsNotDistinct
Definition SR.cs:1938
static string Xslt_UnexpectedElement
Definition SR.cs:1872
static string Xslt_DuplicateWithParam
Definition SR.cs:1956
Definition SR.cs:7
static Encoding GetEncoding(int codepage)
Definition Encoding.cs:593
override string ToString()
Definition Uri.cs:1119
static bool Equal(string strA, string strB)
Definition Ref.cs:5
static XPathNavigatorReader Create(XPathNavigator navToRead)
static string[] SplitString(string value)
static bool IsCatchableException(Exception e)
string Add(char[] array, int offset, int length)
static readonly XmlNullResolver Singleton
XmlNameTable NameTable
Definition XmlReader.cs:116
virtual Uri ResolveUri(Uri? baseUri, string? relativeUri)
List< XmlQualifiedName > CDataSectionElements
XmlReader CreateReader(Stream stream, string baseUri)
static unsafe double StringToDouble(string s)
static string CreateMessage(ISourceLineInfo lineInfo, string res, params string[] args)
static XsltException Create(string res, params string[] args)
static XslNode CopyOf(string select, XslVersion xslVer)
Definition AstFactory.cs:59
static XslNode Text(string data)
static XslNode LiteralElement(QilName name)
Definition AstFactory.cs:99
static XslNodeEx CallTemplate(QilName name, XsltInput.ContextInfo ctxInfo)
Definition AstFactory.cs:39
static XslNode XslNode(XslNodeType nodeType, QilName name, string arg, XslVersion xslVer)
Definition AstFactory.cs:9
static XslNode Message(bool term)
static AttributeSet AttributeSet(QilName name)
Definition AstFactory.cs:34
static Sort Sort(string select, string lang, string dataType, string order, string caseOrder, XslVersion xslVer)
static Number Number(NumberLevel level, string count, string from, string value, string format, string lang, string letterValue, string groupingSeparator, string groupingSize, XslVersion xslVer)
static QilName QName(string local, string uri, string prefix)
static NodeCtor Attribute(string nameAvt, string nsAvt, XslVersion xslVer)
Definition AstFactory.cs:29
static Key Key(QilName name, string match, string use, XslVersion xslVer)
Definition AstFactory.cs:84
static VarPar VarPar(XslNodeType nt, QilName name, string select, XslVersion xslVer)
static NodeCtor Element(string nameAvt, string nsAvt, XslVersion xslVer)
Definition AstFactory.cs:64
static XslNode If(string test, XslVersion xslVer)
Definition AstFactory.cs:79
static XslNode Error(string message)
Definition AstFactory.cs:69
static XslNodeEx ApplyTemplates(QilName mode, string select, XsltInput.ContextInfo ctxInfo, XslVersion xslVer)
Definition AstFactory.cs:19
static XslNode LiteralAttribute(QilName name, string value, XslVersion xslVer)
Definition AstFactory.cs:94
static XslNode PI(string name, XslVersion xslVer)
static XslNodeEx ForEach(string select, XsltInput.ContextInfo ctxInfo, XslVersion xslVer)
Definition AstFactory.cs:74
static XslNode ApplyImports(QilName mode, Stylesheet sheet, XslVersion xslVer)
Definition AstFactory.cs:14
static XslNode UseAttributeSet(QilName name)
static Template Template(QilName name, string match, QilName mode, double priority, XslVersion xslVer)
bool ParseNameTest(string nameTest, out string prefix, out string localName, IErrorHelper errorHelper)
Definition Compiler.cs:258
Dictionary< QilName, AttributeSet > AttributeSets
Definition Compiler.cs:99
bool IsPhantomNamespace(string namespaceName)
Definition Compiler.cs:291
void MergeWithStylesheet(Stylesheet sheet)
Definition Compiler.cs:226
readonly string PhantomNCName
Definition Compiler.cs:105
Stylesheet CreateStylesheet()
Definition Compiler.cs:143
void ReportWarning(ISourceLineInfo lineInfo, string res, params string[] args)
Definition Compiler.cs:337
bool ExitForwardsCompatible(bool fwdCompat)
Definition Compiler.cs:315
void ReportError(ISourceLineInfo lineInfo, string res, params string[] args)
Definition Compiler.cs:331
DecimalFormats DecimalFormats
Definition Compiler.cs:89
bool SetNsAlias(string ssheetNsUri, string resultNsUri, string resultPrefix, int importPrecedence)
Definition Compiler.cs:170
void AddModule(string baseUri)
Definition Compiler.cs:153
List< ProtoTemplate > AllTemplates
Definition Compiler.cs:93
bool ParseQName(string qname, out string prefix, out string localName, IErrorHelper errorHelper)
Definition Compiler.cs:242
TrimSafeDictionary ScriptClasses
Definition Scripts.cs:50
Dictionary< QilName, AttributeSet > AttributeSets
Definition Stylesheet.cs:14
bool AddTemplate(Template template)
Definition Stylesheet.cs:73
void AddWhitespaceRule(int index, WhitespaceRule rule)
Definition Stylesheet.cs:55
readonly QilName Mode
Definition Template.cs:11
readonly QilName Name
Definition XslNode.cs:14
void SaveExtendedLineInfo(XsltInput input)
Definition XsltInput.cs:90
ISourceLineInfo BuildLineInfo()
bool IsRequiredAttribute(int attNum)
Definition XsltInput.cs:687
ContextInfo GetLiteralAttributes(bool asStylesheet)
Definition XsltInput.cs:874
bool AttributeExists(int attNum, string attName)
Definition XsltInput.cs:692
bool IsXsltKeyword(string kwd)
Definition XsltInput.cs:717
ISourceLineInfo BuildNameLineInfo()
string LookupXmlNamespace(string prefix)
bool IsKeyword(string kwd)
Definition XsltInput.cs:702
bool MoveToXsltAttribute(int attNum, string attName)
Definition XsltInput.cs:681
ISourceLineInfo BuildReaderLineInfo()
bool MoveToLiteralAttribute(int attNum)
Definition XsltInput.cs:670
bool IsExtensionNamespace(string uri)
Definition XsltInput.cs:726
void LoadGlobalVariableOrParameter(NsDecl stylesheetNsList, XslNodeType nodeType)
void Load(XmlReader reader)
readonly XsltInput.XsltAttribute[] _scriptAttributes
readonly XsltInput.XsltAttribute[] _usingAttributes
readonly XsltInput.XsltAttribute[] _messageAttributes
readonly XsltInput.XsltAttribute[] _valueOfAttributes
void LoadKey(NsDecl stylesheetNsList)
XslNode LoadLiteralResultElement(bool asStylesheet)
readonly XsltInput.XsltAttribute[] _decimalFormatAttributes
Definition XsltLoader.cs:93
void ReportError(string res, params string[] args)
List< XslNode > LoadInstructions(InstructionFlags flags)
void LoadStripSpace(NsDecl stylesheetNsList)
Stylesheet LoadStylesheet(Uri uri, bool include)
void ReportWarning(string res, params string[] args)
readonly XsltInput.XsltAttribute[] _ifAttributes
readonly XsltInput.XsltAttribute[] _applyTemplatesAttributes
void ParseValidationAttribute(int attNum, bool defVal)
QueryReaderSettings _readerSettings
Definition XsltLoader.cs:24
readonly XsltInput.XsltAttribute[] _callTemplateAttributes
void LoadMsScript(NsDecl stylesheetNsList)
readonly XsltInput.XsltAttribute[] _attributeSetAttributes
List< QilName > ParseUseCharacterMaps(int attNum)
List< XslNode > LoadContent(bool hasSelect)
static void AddInstruction(List< XslNode > content, XslNode instruction)
readonly XsltInput.XsltAttribute[] _forEachAttributes
static NsDecl MergeNamespaces(NsDecl thisList, NsDecl parentList)
XmlQualifiedName ParseOutputMethod(string attValue, out XmlOutputMethod method)
readonly XsltInput.XsltAttribute[] _sortAttributes
readonly XsltInput.XsltAttribute[] _loadStripSpaceAttributes
Definition XsltLoader.cs:59
string ParseNCNameAttribute(int attNum)
TriState ParseYesNoAttribute(int attNum, string attName)
readonly XsltInput.XsltAttribute[] _paramAttributes
QilName ParseQNameAttribute(int attNum)
XslNode LoadUnknownXsltInstruction(string parentName)
readonly XsltInput.XsltAttribute[] _attributeAttributes
readonly XsltInput.XsltAttribute[] _copyAttributes
void CheckError(bool cond, string res, params string[] args)
void AddUseAttributeSets(List< XslNode > list)
string ParseStringAttribute(int attNum, string attName)
List< XslNode > LoadInstructions()
XmlReader CreateReader(Uri uri, XmlResolver xmlResolver)
List< XslNode > LoadWithParams(InstructionFlags flags)
bool ResolveQName(bool ignoreDefaultNs, string qname, out string localName, out string namespaceName, out string prefix)
QilName ParseModeListAttribute(int attNum)
readonly XsltInput.XsltAttribute[] _keyAttributes
Definition XsltLoader.cs:85
Stylesheet LoadStylesheet(XmlReader reader, bool include)
readonly XsltInput.XsltAttribute[] _stylesheetAttributes
Definition XsltLoader.cs:46
void LoadNamespaceAlias(NsDecl stylesheetNsList)
readonly XsltInput.XsltAttribute[] _processingInstructionAttributes
void ParseInputTypeAnnotationsAttribute(int attNum)
List< XslNode > LoadFallbacks(string instrName)
void ParseTypeAttribute(int attNum)
readonly XsltInput.XsltAttribute[] _withParamAttributes
QilName ParseModeAttribute(int attNum)
List< XslNode > LoadInstructions(List< XslNode > content, InstructionFlags flags)
readonly XsltInput.XsltAttribute[] _templateAttributes
void CheckWithParam(List< XslNode > content, XslNode withParam)
static XslNode SetInfo(XslNode to, List< XslNode > content, XsltInput.ContextInfo info)
XslNode XslSort(int sortNumber)
void LoadAttributeSet(NsDecl stylesheetNsList)
readonly XsltInput.XsltAttribute[] _commentAttributes
readonly XsltInput.XsltAttribute[] _elementAttributes
void ParseWhitespaceRules(string elements, bool preserveSpace)
Uri ResolveUri(string relativeUri, string baseUri)
readonly XsltInput.XsltAttribute[] _copyOfAttributes
readonly XsltInput.XsltAttribute[] _numberAttributes
ISourceLineInfo SkipEmptyContent()
void CheckAttributeSetsDfs(AttributeSet attSet)
static XslNode SetLineInfo(XslNode node, ISourceLineInfo lineInfo)
void LoadTemplate(NsDecl stylesheetNsList)
char ParseCharAttribute(int attNum, string attName, char defVal)
readonly XsltInput.XsltAttribute[] _namespaceAliasAttributes
readonly XsltInput.XsltAttribute[] _outputAttributes
Definition XsltLoader.cs:64
void LoadDecimalFormat(NsDecl stylesheetNsList)
readonly XsltInput.XsltAttribute[] _textAttributes
readonly HybridDictionary _documentUriInUse
Definition XsltLoader.cs:44
List< XslNode > LoadEndTag(List< XslNode > content)
List< XslNode > LoadInstructions(List< XslNode > content)
readonly XsltInput.XsltAttribute[] _importIncludeAttributes
Definition XsltLoader.cs:54
static void SetContent(XslNode node, List< XslNode > content)
string ParseCollationAttribute(int attNum)
QilName CreateXPathQName(string qname)
void Load(Compiler compiler, object stylesheet, XmlResolver xmlResolver)
XmlQualifiedName ResolveQName(bool ignoreDefaultNs, string qname)
void LoadPreserveSpace(NsDecl stylesheetNsList)
readonly XsltInput.XsltAttribute[] _assemblyAttributes
readonly XsltInput.XsltAttribute[] _variableAttributes
void AtomizeAttributes(XsltInput.XsltAttribute[] attributes)
void CheckUseAttrubuteSetInList(IList< XslNode > list)