Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SchemaCollectionPreprocessor.cs
Go to the documentation of this file.
3using System.IO;
4
5namespace System.Xml.Schema;
6
8{
9 private enum Compositor
10 {
11 Root,
12 Include,
13 Import
14 }
15
17
18 private string _targetNamespace;
19
20 private bool _buildinIncluded;
21
23
25
27
29
31
33
34 private string _xmlns;
35
37
39 {
40 set
41 {
43 }
44 }
45
50
52 {
54 _xmlns = base.NameTable.Add("xmlns");
56 if (loadExternals && _xmlResolver != null)
57 {
59 if (schema.BaseUri != null)
60 {
61 _schemaLocations.Add(schema.BaseUri, schema.BaseUri);
62 }
64 }
67 if (!base.HasErrors)
68 {
70 for (int i = 0; i < schema.Includes.Count; i++)
71 {
73 if (xmlSchemaExternal.Schema != null)
74 {
76 }
77 }
78 }
79 return !base.HasErrors;
80 }
81
82 private void Cleanup(XmlSchema schema)
83 {
84 if (schema.IsProcessing)
85 {
86 return;
87 }
89 for (int i = 0; i < schema.Includes.Count; i++)
90 {
92 if (xmlSchemaExternal.Schema != null)
93 {
95 }
97 {
99 xmlSchemaRedefine.AttributeGroups.Clear();
100 xmlSchemaRedefine.Groups.Clear();
101 xmlSchemaRedefine.SchemaTypes.Clear();
102 }
103 }
104 schema.Attributes.Clear();
105 schema.AttributeGroups.Clear();
106 schema.SchemaTypes.Clear();
107 schema.Elements.Clear();
108 schema.Groups.Clear();
109 schema.Notations.Clear();
110 schema.Ids.Clear();
111 schema.IdentityConstraints.Clear();
112 schema.IsProcessing = false;
113 }
114
116 {
117 if (schema.IsProcessing)
118 {
119 return;
120 }
121 schema.IsProcessing = true;
122 for (int i = 0; i < schema.Includes.Count; i++)
123 {
125 Uri uri = null;
126 if (xmlSchemaExternal.Schema != null)
127 {
128 if (xmlSchemaExternal is XmlSchemaImport && ((XmlSchemaImport)xmlSchemaExternal).Namespace == "http://www.w3.org/XML/1998/namespace")
129 {
130 _buildinIncluded = true;
131 continue;
132 }
133 uri = xmlSchemaExternal.BaseUri;
134 if (uri != null && _schemaLocations[uri] == null)
135 {
136 _schemaLocations.Add(uri, uri);
137 }
139 continue;
140 }
142 {
144 string ns = ((xmlSchemaImport.Namespace != null) ? xmlSchemaImport.Namespace : string.Empty);
146 if (xmlSchemaExternal.Schema != null)
147 {
149 if (xmlSchemaExternal.Schema.BaseUri != null && _schemaLocations[xmlSchemaExternal.Schema.BaseUri] == null)
150 {
151 _schemaLocations.Add(xmlSchemaExternal.Schema.BaseUri, xmlSchemaExternal.Schema.BaseUri);
152 }
153 Uri uri2 = null;
154 for (int j = 0; j < xmlSchemaExternal.Schema.Includes.Count; j++)
155 {
158 {
159 continue;
160 }
162 uri2 = ((xmlSchemaImport2.BaseUri != null) ? xmlSchemaImport2.BaseUri : ((xmlSchemaImport2.Schema != null && xmlSchemaImport2.Schema.BaseUri != null) ? xmlSchemaImport2.Schema.BaseUri : null));
163 if (uri2 != null)
164 {
165 if (_schemaLocations[uri2] != null)
166 {
168 }
169 else
170 {
172 }
173 }
174 }
175 continue;
176 }
177 }
178 if (xmlSchemaExternal is XmlSchemaImport && ((XmlSchemaImport)xmlSchemaExternal).Namespace == "http://www.w3.org/XML/1998/namespace")
179 {
180 if (!_buildinIncluded)
181 {
182 _buildinIncluded = true;
184 }
185 continue;
186 }
187 string schemaLocation = xmlSchemaExternal.SchemaLocation;
188 if (schemaLocation == null)
189 {
190 continue;
191 }
193 if (!(uri3 != null) || _schemaLocations[uri3] != null)
194 {
195 continue;
196 }
198 if (schemaEntity != null)
199 {
202 XmlTextReader xmlTextReader = new XmlTextReader(uri3.ToString(), schemaEntity, base.NameTable);
204 try
205 {
206 Parser parser = new Parser(SchemaType.XSD, base.NameTable, base.SchemaNames, base.EventHandler);
207 parser.Parse(xmlTextReader, null);
208 while (xmlTextReader.Read())
209 {
210 }
213 }
214 catch (XmlSchemaException ex)
215 {
216 SendValidationEventNoThrow(new XmlSchemaException(System.SR.Sch_CannotLoadSchema, new string[2] { schemaLocation, ex.Message }, ex.SourceUri, ex.LineNumber, ex.LinePosition), XmlSeverityType.Error);
217 }
218 catch (Exception)
219 {
221 }
222 finally
223 {
224 xmlTextReader.Close();
225 }
226 }
227 else
228 {
230 }
231 }
232 schema.IsProcessing = false;
233 }
234
236 {
238 _referenceNamespaces.Add("http://www.w3.org/2001/XMLSchema", "http://www.w3.org/2001/XMLSchema");
239 _referenceNamespaces.Add(string.Empty, string.Empty);
240 for (int i = 0; i < schema.Includes.Count; i++)
241 {
243 {
244 string @namespace = xmlSchemaImport.Namespace;
245 if (@namespace != null && _referenceNamespaces[@namespace] == null)
246 {
247 _referenceNamespaces.Add(@namespace, @namespace);
248 }
249 }
250 }
251 if (schema.TargetNamespace != null && _referenceNamespaces[schema.TargetNamespace] == null)
252 {
253 _referenceNamespaces.Add(schema.TargetNamespace, schema.TargetNamespace);
254 }
255 }
256
258 {
259 if (schema.IsProcessing)
260 {
261 return;
262 }
263 schema.IsProcessing = true;
264 string targetNamespace2 = schema.TargetNamespace;
265 if (targetNamespace2 != null)
266 {
268 if (targetNamespace2.Length == 0)
269 {
271 }
272 else
273 {
274 try
275 {
277 }
278 catch
279 {
281 }
282 }
283 }
284 if (schema.Version != null)
285 {
286 try
287 {
289 }
290 catch (Exception)
291 {
293 }
294 }
295 switch (compositor)
296 {
297 case Compositor.Root:
298 if (targetNamespace == null && schema.TargetNamespace != null)
299 {
300 targetNamespace = schema.TargetNamespace;
301 }
302 else if (schema.TargetNamespace == null && targetNamespace != null && targetNamespace.Length == 0)
303 {
304 targetNamespace = null;
305 }
306 if (targetNamespace != schema.TargetNamespace)
307 {
309 }
310 break;
311 case Compositor.Import:
312 if (targetNamespace != schema.TargetNamespace)
313 {
315 }
316 break;
317 case Compositor.Include:
318 if (schema.TargetNamespace != null && targetNamespace != schema.TargetNamespace)
319 {
321 }
322 break;
323 }
324 for (int i = 0; i < schema.Includes.Count; i++)
325 {
329 string schemaLocation = xmlSchemaExternal.SchemaLocation;
330 if (schemaLocation != null)
331 {
332 try
333 {
335 }
336 catch
337 {
339 }
340 }
342 {
344 }
345 if (xmlSchemaExternal.Schema != null)
346 {
348 {
349 Preprocess(xmlSchemaExternal.Schema, schema.TargetNamespace, Compositor.Include);
350 }
352 {
353 if (((XmlSchemaImport)xmlSchemaExternal).Namespace == null && schema.TargetNamespace == null)
354 {
356 }
357 else if (((XmlSchemaImport)xmlSchemaExternal).Namespace == schema.TargetNamespace)
358 {
360 }
362 }
363 else
364 {
365 Preprocess(xmlSchemaExternal.Schema, schema.TargetNamespace, Compositor.Include);
366 }
367 }
368 else
369 {
371 {
372 continue;
373 }
374 string @namespace = ((XmlSchemaImport)xmlSchemaExternal).Namespace;
375 if (@namespace == null)
376 {
377 continue;
378 }
379 if (@namespace.Length == 0)
380 {
381 SendValidationEvent(System.SR.Sch_InvalidNamespaceAttribute, @namespace, xmlSchemaExternal);
382 continue;
383 }
384 try
385 {
386 XmlConvert.ToUri(@namespace);
387 }
388 catch (FormatException)
389 {
390 SendValidationEvent(System.SR.Sch_InvalidNamespace, @namespace, xmlSchemaExternal);
391 }
392 }
393 }
395 _targetNamespace = ((targetNamespace == null) ? string.Empty : targetNamespace);
396 if (schema.BlockDefault == XmlSchemaDerivationMethod.All)
397 {
399 }
400 else if (schema.BlockDefault == XmlSchemaDerivationMethod.None)
401 {
403 }
404 else
405 {
406 if (((uint)schema.BlockDefault & 0xFFFFFFF8u) != 0)
407 {
409 }
411 }
412 if (schema.FinalDefault == XmlSchemaDerivationMethod.All)
413 {
415 }
416 else if (schema.FinalDefault == XmlSchemaDerivationMethod.None)
417 {
419 }
420 else
421 {
422 if (((uint)schema.FinalDefault & 0xFFFFFFE1u) != 0)
423 {
425 }
427 }
428 _elementFormDefault = schema.ElementFormDefault;
430 {
432 }
433 _attributeFormDefault = schema.AttributeFormDefault;
435 {
437 }
438 for (int j = 0; j < schema.Includes.Count; j++)
439 {
442 {
444 if (xmlSchemaExternal2.Schema != null)
445 {
447 }
448 else
449 {
450 for (int k = 0; k < xmlSchemaRedefine.Items.Count; k++)
451 {
453 {
455 break;
456 }
457 }
458 }
459 }
461 if (schema2 != null)
462 {
463 foreach (XmlSchemaElement value in schema2.Elements.Values)
464 {
465 AddToTable(schema.Elements, value.QualifiedName, value);
466 }
467 foreach (XmlSchemaAttribute value2 in schema2.Attributes.Values)
468 {
469 AddToTable(schema.Attributes, value2.QualifiedName, value2);
470 }
471 foreach (XmlSchemaGroup value3 in schema2.Groups.Values)
472 {
473 AddToTable(schema.Groups, value3.QualifiedName, value3);
474 }
475 foreach (XmlSchemaAttributeGroup value4 in schema2.AttributeGroups.Values)
476 {
477 AddToTable(schema.AttributeGroups, value4.QualifiedName, value4);
478 }
479 foreach (XmlSchemaType value5 in schema2.SchemaTypes.Values)
480 {
481 AddToTable(schema.SchemaTypes, value5.QualifiedName, value5);
482 }
483 foreach (XmlSchemaNotation value6 in schema2.Notations.Values)
484 {
485 AddToTable(schema.Notations, value6.QualifiedName, value6);
486 }
487 }
489 }
491 for (int l = 0; l < schema.Items.Count; l++)
492 {
493 SetParent(schema.Items[l], schema);
495 {
497 AddToTable(schema.Attributes, xmlSchemaAttribute2.QualifiedName, xmlSchemaAttribute2);
498 }
499 else if (schema.Items[l] is XmlSchemaAttributeGroup)
500 {
504 }
505 else if (schema.Items[l] is XmlSchemaComplexType)
506 {
509 AddToTable(schema.SchemaTypes, xmlSchemaComplexType.QualifiedName, xmlSchemaComplexType);
510 }
511 else if (schema.Items[l] is XmlSchemaSimpleType)
512 {
515 AddToTable(schema.SchemaTypes, xmlSchemaSimpleType.QualifiedName, xmlSchemaSimpleType);
516 }
517 else if (schema.Items[l] is XmlSchemaElement)
518 {
521 AddToTable(schema.Elements, xmlSchemaElement2.QualifiedName, xmlSchemaElement2);
522 }
523 else if (schema.Items[l] is XmlSchemaGroup)
524 {
527 AddToTable(schema.Groups, xmlSchemaGroup2.QualifiedName, xmlSchemaGroup2);
528 }
529 else if (schema.Items[l] is XmlSchemaNotation)
530 {
533 AddToTable(schema.Notations, xmlSchemaNotation2.QualifiedName, xmlSchemaNotation2);
534 }
535 else if (!(schema.Items[l] is XmlSchemaAnnotation))
536 {
538 list.Add(schema.Items[l]);
539 }
540 }
541 for (int m = 0; m < list.Count; m++)
542 {
543 schema.Items.Remove(list[m]);
544 }
545 schema.IsProcessing = false;
546 }
547
549 {
550 for (int i = 0; i < redefine.Items.Count; i++)
551 {
552 SetParent(redefine.Items[i], redefine);
553 if (redefine.Items[i] is XmlSchemaGroup xmlSchemaGroup)
554 {
556 if (redefine.Groups[xmlSchemaGroup.QualifiedName] != null)
557 {
559 continue;
560 }
561 AddToTable(redefine.Groups, xmlSchemaGroup.QualifiedName, xmlSchemaGroup);
563 if (xmlSchemaGroup.Redefined != null)
564 {
566 }
567 else
568 {
570 }
571 }
572 else if (redefine.Items[i] is XmlSchemaAttributeGroup)
573 {
576 if (redefine.AttributeGroups[xmlSchemaAttributeGroup.QualifiedName] != null)
577 {
579 continue;
580 }
583 if (xmlSchemaAttributeGroup.Redefined != null)
584 {
586 }
587 else
588 {
590 }
591 }
592 else if (redefine.Items[i] is XmlSchemaComplexType)
593 {
596 if (redefine.SchemaTypes[xmlSchemaComplexType.QualifiedName] != null)
597 {
599 continue;
600 }
603 if (xmlSchemaType != null)
604 {
606 {
609 }
610 else
611 {
613 }
614 }
615 else
616 {
618 }
619 }
620 else
621 {
622 if (!(redefine.Items[i] is XmlSchemaSimpleType))
623 {
624 continue;
625 }
628 if (redefine.SchemaTypes[xmlSchemaSimpleType.QualifiedName] != null)
629 {
631 continue;
632 }
635 if (xmlSchemaType2 != null)
636 {
638 {
641 }
642 else
643 {
645 }
646 }
647 else
648 {
650 }
651 }
652 }
653 foreach (DictionaryEntry group in redefine.Groups)
654 {
655 redefine.Schema.Groups.Insert((XmlQualifiedName)group.Key, (XmlSchemaObject)group.Value);
656 }
657 foreach (DictionaryEntry attributeGroup in redefine.AttributeGroups)
658 {
659 redefine.Schema.AttributeGroups.Insert((XmlQualifiedName)attributeGroup.Key, (XmlSchemaObject)attributeGroup.Value);
660 }
661 foreach (DictionaryEntry schemaType in redefine.SchemaTypes)
662 {
663 redefine.Schema.SchemaTypes.Insert((XmlQualifiedName)schemaType.Key, (XmlSchemaObject)schemaType.Value);
664 }
665 }
666
668 {
669 int num = 0;
670 for (int i = 0; i < items.Count; i++)
671 {
673 {
674 if (xmlSchemaGroupRef.RefName == name)
675 {
676 if (xmlSchemaGroupRef.MinOccurs != 1m || xmlSchemaGroupRef.MaxOccurs != 1m)
677 {
679 }
680 num++;
681 }
682 }
683 else if (items[i] is XmlSchemaGroupBase)
684 {
685 num += CountGroupSelfReference(((XmlSchemaGroupBase)items[i]).Items, name);
686 }
687 if (num > 1)
688 {
689 break;
690 }
691 }
692 return num;
693 }
694
696 {
697 int num = 0;
698 if (group.Particle != null)
699 {
700 num = CountGroupSelfReference(group.Particle.Items, group.QualifiedName);
701 }
702 if (num > 1)
703 {
705 }
706 }
707
709 {
710 int num = 0;
711 for (int i = 0; i < attributeGroup.Attributes.Count; i++)
712 {
714 {
715 num++;
716 }
717 }
718 if (num > 1)
719 {
721 }
722 }
723
736
759
761 {
762 if (attribute.Name != null)
763 {
765 attribute.SetQualifiedName(new XmlQualifiedName(attribute.Name, _targetNamespace));
766 }
767 else
768 {
770 }
771 if (attribute.Use != 0)
772 {
774 }
775 if (attribute.Form != 0)
776 {
778 }
781 }
782
784 {
785 if (attribute.Name != null)
786 {
789 attribute.SetQualifiedName(new XmlQualifiedName(attribute.Name, (attribute.Form == XmlSchemaForm.Qualified || (attribute.Form == XmlSchemaForm.None && _attributeFormDefault == XmlSchemaForm.Qualified)) ? _targetNamespace : null));
790 }
791 else
792 {
794 if (attribute.RefName.IsEmpty)
795 {
797 }
798 else
799 {
801 }
802 if (!attribute.SchemaTypeName.IsEmpty || attribute.SchemaType != null || attribute.Form != 0)
803 {
805 }
806 attribute.SetQualifiedName(attribute.RefName);
807 }
809 }
810
812 {
814 if (_schema.TargetNamespace == "http://www.w3.org/2001/XMLSchema-instance")
815 {
817 }
818 if (!attribute.RefName.IsEmpty)
819 {
821 }
822 if (attribute.DefaultValue != null && attribute.FixedValue != null)
823 {
825 }
826 if (attribute.DefaultValue != null && attribute.Use != XmlSchemaUse.Optional && attribute.Use != 0)
827 {
829 }
830 if (attribute.Name == _xmlns)
831 {
833 }
834 if (attribute.SchemaType != null)
835 {
836 SetParent(attribute.SchemaType, attribute);
837 if (!attribute.SchemaTypeName.IsEmpty)
838 {
840 }
841 PreprocessSimpleType(attribute.SchemaType, local: true);
842 }
843 if (!attribute.SchemaTypeName.IsEmpty)
844 {
845 ValidateQNameAttribute(attribute, "type", attribute.SchemaTypeName);
846 }
847 }
848
864
866 {
867 if (element.Name != null)
868 {
869 ValidateNameAttribute(element);
871 }
872 else
873 {
875 }
877 if (element.Final == XmlSchemaDerivationMethod.All)
878 {
880 }
881 else if (element.Final == XmlSchemaDerivationMethod.None)
882 {
884 {
886 }
887 else
888 {
890 }
891 }
892 else
893 {
894 if (((uint)element.Final & 0xFFFFFFF9u) != 0)
895 {
897 }
898 element.SetFinalResolved(element.Final & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction));
899 }
900 if (element.Form != 0)
901 {
903 }
904 if (element.MinOccursString != null)
905 {
907 }
908 if (element.MaxOccursString != null)
909 {
911 }
912 if (!element.SubstitutionGroup.IsEmpty)
913 {
914 ValidateQNameAttribute(element, "type", element.SubstitutionGroup);
915 }
916 ValidateIdAttribute(element);
917 }
918
920 {
921 if (element.Name != null)
922 {
923 ValidateNameAttribute(element);
925 element.SetQualifiedName(new XmlQualifiedName(element.Name, (element.Form == XmlSchemaForm.Qualified || (element.Form == XmlSchemaForm.None && _elementFormDefault == XmlSchemaForm.Qualified)) ? _targetNamespace : null));
926 }
927 else
928 {
929 PreprocessAnnotation(element);
930 if (element.RefName.IsEmpty)
931 {
933 }
934 else
935 {
936 ValidateQNameAttribute(element, "ref", element.RefName);
937 }
938 if (!element.SchemaTypeName.IsEmpty || element.IsAbstract || element.Block != XmlSchemaDerivationMethod.None || element.SchemaType != null || element.HasConstraints || element.DefaultValue != null || element.Form != 0 || element.FixedValue != null || element.HasNillableAttribute)
939 {
941 }
942 if (element.DefaultValue != null && element.FixedValue != null)
943 {
945 }
946 element.SetQualifiedName(element.RefName);
947 }
948 if (element.MinOccurs > element.MaxOccurs)
949 {
952 }
953 if (element.IsAbstract)
954 {
956 }
957 if (element.Final != XmlSchemaDerivationMethod.None)
958 {
960 }
961 if (!element.SubstitutionGroup.IsEmpty)
962 {
963 SendValidationEvent(System.SR.Sch_ForbiddenAttribute, "substitutionGroup", element);
964 }
965 ValidateIdAttribute(element);
966 }
967
969 {
970 PreprocessAnnotation(element);
971 if (!element.RefName.IsEmpty)
972 {
974 }
975 if (element.Block == XmlSchemaDerivationMethod.All)
976 {
978 }
979 else if (element.Block == XmlSchemaDerivationMethod.None)
980 {
982 {
984 }
985 else
986 {
988 }
989 }
990 else
991 {
992 if (((uint)element.Block & 0xFFFFFFF8u) != 0)
993 {
995 }
996 element.SetBlockResolved(element.Block & (XmlSchemaDerivationMethod.Substitution | XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction));
997 }
998 if (element.SchemaType != null)
999 {
1000 SetParent(element.SchemaType, element);
1001 if (!element.SchemaTypeName.IsEmpty)
1002 {
1004 }
1006 {
1008 }
1009 else
1010 {
1012 }
1013 }
1014 if (!element.SchemaTypeName.IsEmpty)
1015 {
1016 ValidateQNameAttribute(element, "type", element.SchemaTypeName);
1017 }
1018 if (element.DefaultValue != null && element.FixedValue != null)
1019 {
1021 }
1022 for (int i = 0; i < element.Constraints.Count; i++)
1023 {
1024 SetParent(element.Constraints[i], element);
1026 }
1027 }
1028
1030 {
1031 bool flag = true;
1032 PreprocessAnnotation(constraint);
1033 if (constraint.Name != null)
1034 {
1035 ValidateNameAttribute(constraint);
1036 constraint.SetQualifiedName(new XmlQualifiedName(constraint.Name, _targetNamespace));
1037 }
1038 else
1039 {
1041 flag = false;
1042 }
1043 if (_schema.IdentityConstraints[constraint.QualifiedName] != null)
1044 {
1046 flag = false;
1047 }
1048 else
1049 {
1050 _schema.IdentityConstraints.Add(constraint.QualifiedName, constraint);
1051 }
1052 if (constraint.Selector == null)
1053 {
1055 flag = false;
1056 }
1057 if (constraint.Fields.Count == 0)
1058 {
1060 flag = false;
1061 }
1062 if (constraint is XmlSchemaKeyref)
1063 {
1065 if (xmlSchemaKeyref.Refer.IsEmpty)
1066 {
1068 flag = false;
1069 }
1070 else
1071 {
1073 }
1074 }
1075 if (flag)
1076 {
1077 ValidateIdAttribute(constraint);
1078 ValidateIdAttribute(constraint.Selector);
1079 SetParent(constraint.Selector, constraint);
1080 for (int i = 0; i < constraint.Fields.Count; i++)
1081 {
1082 SetParent(constraint.Fields[i], constraint);
1083 ValidateIdAttribute(constraint.Fields[i]);
1084 }
1085 }
1086 }
1087
1089 {
1090 if (local)
1091 {
1092 if (simpleType.Name != null)
1093 {
1095 }
1096 }
1097 else
1098 {
1099 if (simpleType.Name != null)
1100 {
1102 simpleType.SetQualifiedName(new XmlQualifiedName(simpleType.Name, _targetNamespace));
1103 }
1104 else
1105 {
1107 }
1108 if (simpleType.Final == XmlSchemaDerivationMethod.All)
1109 {
1110 simpleType.SetFinalResolved(XmlSchemaDerivationMethod.All);
1111 }
1112 else if (simpleType.Final == XmlSchemaDerivationMethod.None)
1113 {
1115 {
1116 simpleType.SetFinalResolved(XmlSchemaDerivationMethod.All);
1117 }
1118 else
1119 {
1121 }
1122 }
1123 else
1124 {
1125 if (((uint)simpleType.Final & 0xFFFFFFE3u) != 0)
1126 {
1128 }
1129 simpleType.SetFinalResolved(simpleType.Final & (XmlSchemaDerivationMethod.Restriction | XmlSchemaDerivationMethod.List | XmlSchemaDerivationMethod.Union));
1130 }
1131 }
1132 if (simpleType.Content == null)
1133 {
1135 }
1137 {
1140 for (int i = 0; i < xmlSchemaSimpleTypeRestriction.Facets.Count; i++)
1141 {
1143 }
1144 if (xmlSchemaSimpleTypeRestriction.BaseType != null)
1145 {
1146 if (!xmlSchemaSimpleTypeRestriction.BaseTypeName.IsEmpty)
1147 {
1149 }
1151 }
1152 else if (xmlSchemaSimpleTypeRestriction.BaseTypeName.IsEmpty)
1153 {
1155 }
1156 else
1157 {
1159 }
1162 }
1163 else if (simpleType.Content is XmlSchemaSimpleTypeList)
1164 {
1167 if (xmlSchemaSimpleTypeList.ItemType != null)
1168 {
1169 if (!xmlSchemaSimpleTypeList.ItemTypeName.IsEmpty)
1170 {
1172 }
1175 }
1176 else if (xmlSchemaSimpleTypeList.ItemTypeName.IsEmpty)
1177 {
1179 }
1180 else
1181 {
1183 }
1186 }
1187 else
1188 {
1191 int num = xmlSchemaSimpleTypeUnion.BaseTypes.Count;
1192 if (xmlSchemaSimpleTypeUnion.MemberTypes != null)
1193 {
1194 num += xmlSchemaSimpleTypeUnion.MemberTypes.Length;
1195 for (int j = 0; j < xmlSchemaSimpleTypeUnion.MemberTypes.Length; j++)
1196 {
1198 }
1199 }
1200 if (num == 0)
1201 {
1203 }
1204 for (int k = 0; k < xmlSchemaSimpleTypeUnion.BaseTypes.Count; k++)
1205 {
1208 }
1211 }
1213 }
1214
1216 {
1217 if (local)
1218 {
1219 if (complexType.Name != null)
1220 {
1222 }
1223 }
1224 else
1225 {
1226 if (complexType.Name != null)
1227 {
1229 complexType.SetQualifiedName(new XmlQualifiedName(complexType.Name, _targetNamespace));
1230 }
1231 else
1232 {
1234 }
1235 if (complexType.Block == XmlSchemaDerivationMethod.All)
1236 {
1237 complexType.SetBlockResolved(XmlSchemaDerivationMethod.All);
1238 }
1239 else if (complexType.Block == XmlSchemaDerivationMethod.None)
1240 {
1241 complexType.SetBlockResolved(_blockDefault & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction));
1242 }
1243 else
1244 {
1245 if (((uint)complexType.Block & 0xFFFFFFF9u) != 0)
1246 {
1248 }
1249 complexType.SetBlockResolved(complexType.Block & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction));
1250 }
1251 if (complexType.Final == XmlSchemaDerivationMethod.All)
1252 {
1253 complexType.SetFinalResolved(XmlSchemaDerivationMethod.All);
1254 }
1255 else if (complexType.Final == XmlSchemaDerivationMethod.None)
1256 {
1258 {
1259 complexType.SetFinalResolved(XmlSchemaDerivationMethod.All);
1260 }
1261 else
1262 {
1263 complexType.SetFinalResolved(_finalDefault & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction));
1264 }
1265 }
1266 else
1267 {
1268 if (((uint)complexType.Final & 0xFFFFFFF9u) != 0)
1269 {
1271 }
1272 complexType.SetFinalResolved(complexType.Final & (XmlSchemaDerivationMethod.Extension | XmlSchemaDerivationMethod.Restriction));
1273 }
1274 }
1275 if (complexType.ContentModel != null)
1276 {
1277 SetParent(complexType.ContentModel, complexType);
1278 PreprocessAnnotation(complexType.ContentModel);
1279 if (complexType.Particle == null)
1280 {
1281 _ = complexType.Attributes;
1282 }
1283 if (complexType.ContentModel is XmlSchemaSimpleContent)
1284 {
1286 if (xmlSchemaSimpleContent.Content == null)
1287 {
1288 if (complexType.QualifiedName == XmlQualifiedName.Empty)
1289 {
1291 }
1292 else
1293 {
1294 SendValidationEvent(System.SR.Sch_NoRestOrExtQName, complexType.QualifiedName.Name, complexType.QualifiedName.Namespace, complexType);
1295 }
1296 }
1297 else
1298 {
1302 {
1304 if (xmlSchemaSimpleContentExtension.BaseTypeName.IsEmpty)
1305 {
1307 }
1308 else
1309 {
1311 }
1314 }
1315 else
1316 {
1318 if (xmlSchemaSimpleContentRestriction.BaseTypeName.IsEmpty)
1319 {
1321 }
1322 else
1323 {
1325 }
1326 if (xmlSchemaSimpleContentRestriction.BaseType != null)
1327 {
1330 }
1333 }
1334 }
1336 }
1337 else
1338 {
1340 if (xmlSchemaComplexContent.Content == null)
1341 {
1342 if (complexType.QualifiedName == XmlQualifiedName.Empty)
1343 {
1345 }
1346 else
1347 {
1348 SendValidationEvent(System.SR.Sch_NoRestOrExtQName, complexType.QualifiedName.Name, complexType.QualifiedName.Namespace, complexType);
1349 }
1350 }
1351 else
1352 {
1353 if (!xmlSchemaComplexContent.HasMixedAttribute && complexType.IsMixed)
1354 {
1356 }
1360 {
1362 if (xmlSchemaComplexContentExtension.BaseTypeName.IsEmpty)
1363 {
1365 }
1366 else
1367 {
1369 }
1370 if (xmlSchemaComplexContentExtension.Particle != null)
1371 {
1374 }
1377 }
1378 else
1379 {
1381 if (xmlSchemaComplexContentRestriction.BaseTypeName.IsEmpty)
1382 {
1384 }
1385 else
1386 {
1388 }
1389 if (xmlSchemaComplexContentRestriction.Particle != null)
1390 {
1393 }
1396 }
1398 }
1399 }
1400 }
1401 else
1402 {
1403 if (complexType.Particle != null)
1404 {
1407 }
1408 PreprocessAttributes(complexType.Attributes, complexType.AnyAttribute, complexType);
1409 }
1411 }
1412
1414 {
1415 if (group.Name != null)
1416 {
1418 group.SetQualifiedName(new XmlQualifiedName(group.Name, _targetNamespace));
1419 }
1420 else
1421 {
1423 }
1424 if (group.Particle == null)
1425 {
1427 return;
1428 }
1429 if (group.Particle.MinOccursString != null)
1430 {
1432 }
1433 if (group.Particle.MaxOccursString != null)
1434 {
1436 }
1437 PreprocessParticle(group.Particle);
1440 }
1441
1443 {
1444 if (notation.Name != null)
1445 {
1448 }
1449 else
1450 {
1452 }
1453 if (notation.Public != null)
1454 {
1455 try
1456 {
1457 XmlConvert.ToUri(notation.Public);
1458 }
1459 catch
1460 {
1462 }
1463 }
1464 else
1465 {
1467 }
1468 if (notation.System != null)
1469 {
1470 try
1471 {
1472 XmlConvert.ToUri(notation.System);
1473 }
1474 catch
1475 {
1477 }
1478 }
1481 }
1482
1484 {
1485 if (particle is XmlSchemaAll xmlSchemaAll)
1486 {
1487 if (particle.MinOccurs != 0m && particle.MinOccurs != 1m)
1488 {
1491 }
1492 if (particle.MaxOccurs != 1m)
1493 {
1496 }
1497 for (int i = 0; i < xmlSchemaAll.Items.Count; i++)
1498 {
1500 if (xmlSchemaElement.MaxOccurs != 0m && xmlSchemaElement.MaxOccurs != 1m)
1501 {
1504 }
1505 SetParent(xmlSchemaElement, particle);
1507 }
1508 }
1509 else
1510 {
1511 if (particle.MinOccurs > particle.MaxOccurs)
1512 {
1513 particle.MinOccurs = particle.MaxOccurs;
1515 }
1516 if (particle is XmlSchemaChoice xmlSchemaChoice)
1517 {
1519 for (int j = 0; j < items.Count; j++)
1520 {
1521 SetParent(items[j], particle);
1522 if (items[j] is XmlSchemaElement element)
1523 {
1524 PreprocessLocalElement(element);
1525 }
1526 else
1527 {
1529 }
1530 }
1531 }
1532 else if (particle is XmlSchemaSequence)
1533 {
1535 for (int k = 0; k < items2.Count; k++)
1536 {
1537 SetParent(items2[k], particle);
1539 {
1541 }
1542 else
1543 {
1545 }
1546 }
1547 }
1548 else if (particle is XmlSchemaGroupRef)
1549 {
1551 if (xmlSchemaGroupRef.RefName.IsEmpty)
1552 {
1554 }
1555 else
1556 {
1558 }
1559 }
1560 else if (particle is XmlSchemaAny)
1561 {
1562 try
1563 {
1564 ((XmlSchemaAny)particle).BuildNamespaceListV1Compat(_targetNamespace);
1565 }
1566 catch
1567 {
1569 }
1570 }
1571 }
1572 PreprocessAnnotation(particle);
1573 ValidateIdAttribute(particle);
1574 }
1575
1577 {
1578 for (int i = 0; i < attributes.Count; i++)
1579 {
1580 SetParent(attributes[i], parent);
1581 if (attributes[i] is XmlSchemaAttribute attribute)
1582 {
1584 continue;
1585 }
1587 if (xmlSchemaAttributeGroupRef.RefName.IsEmpty)
1588 {
1590 }
1591 else
1592 {
1594 }
1595 PreprocessAnnotation(attributes[i]);
1596 ValidateIdAttribute(attributes[i]);
1597 }
1598 if (anyAttribute != null)
1599 {
1600 try
1601 {
1602 SetParent(anyAttribute, parent);
1604 anyAttribute.BuildNamespaceListV1Compat(_targetNamespace);
1605 }
1606 catch
1607 {
1609 }
1611 }
1612 }
1613
1615 {
1616 if (xso.IdAttribute == null)
1617 {
1618 return;
1619 }
1620 try
1621 {
1623 if (_schema.Ids[xso.IdAttribute] != null)
1624 {
1626 }
1627 else
1628 {
1629 _schema.Ids.Add(xso.IdAttribute, xso);
1630 }
1631 }
1632 catch (Exception ex)
1633 {
1635 }
1636 }
1637
1639 {
1640 string nameAttribute = xso.NameAttribute;
1641 if (nameAttribute == null || nameAttribute.Length == 0)
1642 {
1644 }
1647 if (num != nameAttribute.Length)
1648 {
1650 string msg = System.SR.Format(System.SR.Xml_BadNameCharWithPos, array[0], array[1], num);
1652 }
1653 else
1654 {
1656 }
1657 }
1658
1660 {
1661 try
1662 {
1663 value.Verify();
1664 value.Atomize(base.NameTable);
1665 if (_referenceNamespaces[value.Namespace] == null)
1666 {
1668 }
1669 }
1670 catch (Exception ex)
1671 {
1673 }
1674 }
1675
1676 private void SetParent(XmlSchemaObject child, XmlSchemaObject parent)
1677 {
1678 child.Parent = parent;
1679 }
1680
1682 {
1683 if (schemaObject is XmlSchemaAnnotated { Annotation: not null } xmlSchemaAnnotated)
1684 {
1686 for (int i = 0; i < xmlSchemaAnnotated.Annotation.Items.Count; i++)
1687 {
1688 xmlSchemaAnnotated.Annotation.Items[i].Parent = xmlSchemaAnnotated.Annotation;
1689 }
1690 }
1691 }
1692
1694 {
1695 try
1696 {
1698 }
1699 catch
1700 {
1701 return null;
1702 }
1703 }
1704
1706 {
1707 try
1708 {
1709 return (Stream)_xmlResolver.GetEntity(ruri, null, null);
1710 }
1711 catch
1712 {
1713 return null;
1714 }
1715 }
1716}
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
void Add(TKey key, TValue value)
virtual void Add(object key, object? value)
Definition Hashtable.cs:676
static string Sch_MinGtMax
Definition SR.cs:834
static string Sch_InvalidComplexTypeBlockValue
Definition SR.cs:516
static string Sch_AttributeValueDataType
Definition SR.cs:1808
static string Sch_IdConstraintNoFields
Definition SR.cs:840
static string Sch_InvalidComplexTypeFinalValue
Definition SR.cs:518
static string Sch_ImportTargetNamespaceNull
Definition SR.cs:800
static string Sch_NoRestOrExtQName
Definition SR.cs:858
static string Sch_InvalidIncludeLocation
Definition SR.cs:1076
static string Sch_InvalidNameAttributeEx
Definition SR.cs:1138
static string Sch_InvalidAny
Definition SR.cs:938
static string Sch_RedefineNoSchema
Definition SR.cs:948
static string Sch_InvalidIdAttribute
Definition SR.cs:1136
static string Sch_InvalidAnyAttribute
Definition SR.cs:932
static string Sch_DupIdentityConstraint
Definition SR.cs:520
static string Sch_SimpleTypeRestRefBase
Definition SR.cs:848
static string Sch_MultipleAttrGroupSelfRef
Definition SR.cs:828
static string Sch_MissAttribute
Definition SR.cs:428
static string Sch_AttrGroupRedefineNotFound
Definition SR.cs:810
static string Sch_MinMaxGroupRedefine
Definition SR.cs:824
static string Sch_InvalidNamespace
Definition SR.cs:790
static string Sch_NoRestOrExt
Definition SR.cs:860
static string Sch_ElementNameRef
Definition SR.cs:552
static string Sch_InvalidTypeRedefine
Definition SR.cs:830
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string Sch_SimpleTypeUnionNoBase
Definition SR.cs:856
static string Sch_MismatchTargetNamespaceImport
Definition SR.cs:598
static string Sch_MismatchTargetNamespaceInclude
Definition SR.cs:596
static string Sch_GroupRedefineNotFound
Definition SR.cs:806
static string Sch_SimpleTypeListRefBaseNone
Definition SR.cs:854
static string Sch_InvalidElementBlockValue
Definition SR.cs:510
static string Sch_SimpleTypeDoubleRedefine
Definition SR.cs:818
static string Sch_InvalidPublicAttribute
Definition SR.cs:1126
static string Sch_InvalidSystemAttribute
Definition SR.cs:1128
static string Xml_BadNameCharWithPos
Definition SR.cs:210
static string Sch_InvalidAttribute
Definition SR.cs:1140
static string Sch_ComplexTypeRedefineNotFound
Definition SR.cs:814
static string Sch_NoSimpleTypeContent
Definition SR.cs:846
static string Sch_NullValue
Definition SR.cs:1156
static string Sch_InvalidTargetNamespaceAttribute
Definition SR.cs:792
static string Sch_AttributeNameRef
Definition SR.cs:554
static string Sch_DefaultFixedAttributes
Definition SR.cs:536
static string Sch_ForbiddenAttribute
Definition SR.cs:544
static string Sch_NoGroupParticle
Definition SR.cs:862
static string Sch_DupIdAttribute
Definition SR.cs:934
static string Sch_InvalidAllMin
Definition SR.cs:864
static string Sch_TargetNamespaceXsi
Definition SR.cs:746
static string Sch_InvalidAllElementMax
Definition SR.cs:936
static string Sch_InvalidElementFinalValue
Definition SR.cs:512
static string Sch_InvalidFinalDefaultValue
Definition SR.cs:508
static string Sch_SimpleTypeRedefineNotFound
Definition SR.cs:822
static string Sch_SimpleToComplexTypeRedefine
Definition SR.cs:816
static string Sch_InvalidSimpleTypeFinalValue
Definition SR.cs:514
static string Sch_InvalidElementRef
Definition SR.cs:832
static string Sch_MultipleGroupSelfRef
Definition SR.cs:826
static string Sch_XmlNsAttribute
Definition SR.cs:592
static string Sch_SimpleTypeListRefBase
Definition SR.cs:852
static string Sch_CannotLoadSchema
Definition SR.cs:1078
static string Sch_ComplexToSimpleTypeRedefine
Definition SR.cs:820
static string Sch_InvalidAllMax
Definition SR.cs:866
static string Sch_ImportTargetNamespace
Definition SR.cs:798
static string Sch_GroupDoubleRedefine
Definition SR.cs:802
static string Sch_MismatchTargetNamespaceEx
Definition SR.cs:600
static string Sch_UnrefNS
Definition SR.cs:1150
static string Sch_InvalidBlockDefaultValue
Definition SR.cs:506
static string Sch_InvalidNamespaceAttribute
Definition SR.cs:794
static string Sch_InvalidCollection
Definition SR.cs:1148
static string Sch_ComplexTypeDoubleRedefine
Definition SR.cs:812
static string Sch_SimpleTypeRestRefBaseNone
Definition SR.cs:850
static string Sch_InvalidSchemaLocation
Definition SR.cs:796
static string Sch_AttrGroupDoubleRedefine
Definition SR.cs:808
static string Sch_IdConstraintNoRefer
Definition SR.cs:842
static string Sch_IdConstraintNoSelector
Definition SR.cs:838
static string Sch_TypeMutualExclusive
Definition SR.cs:550
static string Sch_OptionalDefaultAttribute
Definition SR.cs:924
static string Sch_InvalidAttributeRef
Definition SR.cs:922
static string Sch_MissRequiredAttribute
Definition SR.cs:490
Definition SR.cs:7
void SendValidationEvent(string code, XmlSchemaObject source)
void AddToTable(XmlSchemaObjectTable table, XmlQualifiedName qname, XmlSchemaObject item)
void SendValidationEventNoThrow(XmlSchemaException e, XmlSeverityType severity)
static XmlSchema GetBuildInSchema()
SchemaCollectionPreprocessor(XmlNameTable nameTable, SchemaNames schemaNames, ValidationEventHandler eventHandler)
void PreprocessAttributes(XmlSchemaObjectCollection attributes, XmlSchemaAnyAttribute anyAttribute, XmlSchemaObject parent)
void PreprocessAttributeGroup(XmlSchemaAttributeGroup attributeGroup)
void SetParent(XmlSchemaObject child, XmlSchemaObject parent)
void LoadExternals(XmlSchema schema, XmlSchemaCollection xsc)
void PreprocessIdentityConstraint(XmlSchemaIdentityConstraint constraint)
Uri ResolveSchemaLocationUri(XmlSchema enclosingSchema, string location)
void CheckRefinedAttributeGroup(XmlSchemaAttributeGroup attributeGroup)
int CountGroupSelfReference(XmlSchemaObjectCollection items, XmlQualifiedName name)
bool Execute(XmlSchema schema, string targetNamespace, bool loadExternals, XmlSchemaCollection xsc)
void PreprocessSimpleType(XmlSchemaSimpleType simpleType, bool local)
void PreprocessComplexType(XmlSchemaComplexType complexType, bool local)
void Preprocess(XmlSchema schema, string targetNamespace, Compositor compositor)
void ValidateQNameAttribute(XmlSchemaObject xso, string attributeName, XmlQualifiedName value)
void PreprocessAttributeContent(XmlSchemaAttribute attribute)
XmlSchemaDerivationMethod Final
void SetBlockResolved(XmlSchemaDerivationMethod value)
XmlSchemaDerivationMethod Block
XmlSchemaObjectCollection Constraints
void SetFinalResolved(XmlSchemaDerivationMethod value)
void SetQualifiedName(XmlQualifiedName value)
void Add(XmlQualifiedName name, XmlSchemaObject value)
XmlSchemaObjectTable SchemaTypes
Definition XmlSchema.cs:256
XmlSchemaObjectTable AttributeGroups
Definition XmlSchema.cs:243
XmlSchemaObjectTable Groups
Definition XmlSchema.cs:307
XmlSchemaObjectTable IdentityConstraints
Definition XmlSchema.cs:313
static int ParseNCName(string s, int offset)
static string NonCDataNormalize(string value)
static ? string VerifyTOKEN(string? token)
static string VerifyNCName(string name)
static Uri ToUri(string s)
static string[] BuildCharExceptionArgs(string data, int invCharIndex)
static readonly XmlQualifiedName Empty
object? GetEntity(Uri absoluteUri, string? role, Type? ofObjectToReturn)
virtual Uri ResolveUri(Uri? baseUri, string? relativeUri)