Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SchemaCollectionCompiler.cs
Go to the documentation of this file.
3
4namespace System.Xml.Schema;
5
7{
8 private bool _compileContentModel;
9
11
13
15
20
21 public bool Execute(XmlSchema schema, SchemaInfo schemaInfo, bool compileContentModel)
22 {
25 Prepare();
26 Cleanup();
27 Compile();
28 if (!base.HasErrors)
29 {
30 Output(schemaInfo);
31 }
32 return !base.HasErrors;
33 }
34
35 private void Prepare()
36 {
38 {
39 if (!value.SubstitutionGroup.IsEmpty)
40 {
43 {
47 }
50 }
51 }
52 }
53
84
85 internal static void Cleanup(XmlSchema schema)
86 {
87 for (int i = 0; i < schema.Includes.Count; i++)
88 {
90 if (xmlSchemaExternal.Schema != null)
91 {
93 }
95 {
96 continue;
97 }
98 xmlSchemaRedefine.AttributeGroups.Clear();
99 xmlSchemaRedefine.Groups.Clear();
100 xmlSchemaRedefine.SchemaTypes.Clear();
101 for (int j = 0; j < xmlSchemaRedefine.Items.Count; j++)
102 {
103 object obj = xmlSchemaRedefine.Items[j];
105 {
107 }
109 {
111 }
113 {
115 }
117 {
119 }
120 else if (obj is XmlSchemaElement element)
121 {
122 CleanupElement(element);
123 }
124 else if (obj is XmlSchemaGroup group)
125 {
127 }
128 }
129 }
130 for (int k = 0; k < schema.Items.Count; k++)
131 {
132 object obj2 = schema.Items[k];
134 {
136 }
138 {
140 }
142 {
144 }
145 else if (schema.Items[k] is XmlSchemaSimpleType simpleType2)
146 {
148 }
149 else if (schema.Items[k] is XmlSchemaElement element2)
150 {
152 }
153 else if (schema.Items[k] is XmlSchemaGroup group2)
154 {
156 }
157 }
158 schema.Attributes.Clear();
159 schema.AttributeGroups.Clear();
160 schema.SchemaTypes.Clear();
161 schema.Elements.Clear();
162 schema.Groups.Clear();
163 schema.Notations.Clear();
164 schema.Ids.Clear();
165 schema.IdentityConstraints.Clear();
166 }
167
168 private void Compile()
169 {
172 {
174 }
176 {
178 }
180 {
182 }
184 {
186 {
188 }
189 else
190 {
192 }
193 }
195 {
196 if (value5.ElementDecl == null)
197 {
199 }
200 }
202 {
203 if (value6.AttDef == null)
204 {
206 }
207 }
209 {
210 if (value7.CompiledConstraint == null)
211 {
213 }
214 }
215 while (_complexTypeStack.Count > 0)
216 {
219 }
221 {
223 {
225 }
226 }
228 {
229 if (value9.ElementSchemaType is XmlSchemaComplexType && value9.SchemaTypeName == XmlQualifiedName.Empty)
230 {
232 }
233 }
235 {
237 }
239 }
240
241 private void Output(SchemaInfo schemaInfo)
242 {
244 {
245 schemaInfo.TargetNamespaces[value.QualifiedName.Namespace] = true;
246 schemaInfo.ElementDecls.Add(value.QualifiedName, value.ElementDecl);
247 }
249 {
250 schemaInfo.TargetNamespaces[value2.QualifiedName.Namespace] = true;
251 schemaInfo.AttributeDecls.Add(value2.QualifiedName, value2.AttDef);
252 }
254 {
255 schemaInfo.TargetNamespaces[value3.QualifiedName.Namespace] = true;
257 {
258 schemaInfo.ElementDeclsByType.Add(value3.QualifiedName, value3.ElementDecl);
259 }
260 }
262 {
263 schemaInfo.TargetNamespaces[value4.QualifiedName.Namespace] = true;
267 if (!schemaInfo.Notations.ContainsKey(schemaNotation.Name.Name))
268 {
269 schemaInfo.Notations.Add(schemaNotation.Name.Name, schemaNotation);
270 }
271 }
272 }
273
275 {
276 if (attribute.SchemaType != null)
277 {
278 CleanupSimpleType(attribute.SchemaType);
279 }
280 attribute.AttDef = null;
281 }
282
289
291 {
292 if (complexType.ContentModel != null)
293 {
294 if (complexType.ContentModel is XmlSchemaSimpleContent)
295 {
298 {
301 }
302 else
303 {
306 }
307 }
308 else
309 {
312 {
316 }
317 else
318 {
322 }
323 }
324 }
325 else
326 {
328 CleanupAttributes(complexType.Attributes);
329 }
330 complexType.LocalElements.Clear();
331 complexType.AttributeUses.Clear();
332 complexType.SetAttributeWildcard(null);
333 complexType.SetContentTypeParticle(XmlSchemaParticle.Empty);
335 }
336
338 {
340 }
341
342 private static void CleanupElement(XmlSchemaElement element)
343 {
344 if (element.SchemaType != null)
345 {
347 {
349 }
350 else
351 {
353 }
354 }
355 for (int i = 0; i < element.Constraints.Count; i++)
356 {
357 ((XmlSchemaIdentityConstraint)element.Constraints[i]).CompiledConstraint = null;
358 }
359 element.ElementDecl = null;
360 }
361
362 private static void CleanupAttributes(XmlSchemaObjectCollection attributes)
363 {
364 for (int i = 0; i < attributes.Count; i++)
365 {
366 if (attributes[i] is XmlSchemaAttribute attribute)
367 {
369 }
370 }
371 }
372
373 private static void CleanupGroup(XmlSchemaGroup group)
374 {
375 CleanupParticle(group.Particle);
377 }
378
379 private static void CleanupParticle(XmlSchemaParticle particle)
380 {
381 if (particle is XmlSchemaElement)
382 {
384 }
385 else if (particle is XmlSchemaGroupBase)
386 {
387 XmlSchemaObjectCollection items = ((XmlSchemaGroupBase)particle).Items;
388 for (int i = 0; i < items.Count; i++)
389 {
391 }
392 }
393 }
394
396 {
397 if (substitutionGroup.IsProcessing && substitutionGroup.Members.Count > 0)
398 {
400 return;
401 }
404 {
405 return;
406 }
408 if (xmlSchemaElement != null)
409 {
410 if (xmlSchemaElement.FinalResolved == XmlSchemaDerivationMethod.All)
411 {
413 }
414 for (int i = 0; i < substitutionGroup.Members.Count; i++)
415 {
419 {
421 for (int j = 0; j < xmlSchemaSubstitutionGroupV1Compat.Choice.Items.Count; j++)
422 {
423 substitutionGroup.Choice.Items.Add(xmlSchemaSubstitutionGroupV1Compat.Choice.Items[j]);
424 }
425 }
426 else
427 {
429 }
430 }
433 }
434 else if (substitutionGroup.Members.Count > 0)
435 {
437 }
439 }
440
442 {
444 if (xmlSchemaElement == null)
445 {
446 return;
447 }
448 for (int i = 0; i < substitutionGroup.Members.Count; i++)
449 {
451 if (xmlSchemaElement2 != xmlSchemaElement && !XmlSchemaType.IsDerivedFrom(xmlSchemaElement2.ElementSchemaType, xmlSchemaElement.ElementSchemaType, xmlSchemaElement.FinalResolved))
452 {
454 }
455 }
456 }
457
459 {
460 if (group.IsProcessing)
461 {
464 return;
465 }
466 group.IsProcessing = true;
467 if (group.CanonicalParticle == null)
468 {
470 }
471 group.IsProcessing = false;
472 }
473
475 {
476 if (simpleType.IsProcessing)
477 {
479 }
480 if (simpleType.ElementDecl != null)
481 {
482 return;
483 }
485 try
486 {
488 {
491 XmlSchemaDatatype datatype;
492 if (xmlSchemaSimpleTypeList.ItemTypeName.IsEmpty)
493 {
496 datatype = xmlSchemaSimpleTypeList.ItemType.Datatype;
497 }
498 else
499 {
501 if (simpleType2 == null)
502 {
504 }
505 if ((simpleType2.FinalResolved & XmlSchemaDerivationMethod.List) != 0)
506 {
508 }
510 datatype = simpleType2.Datatype;
511 }
512 simpleType.SetDatatype(datatype.DeriveByList(simpleType));
513 simpleType.SetDerivedBy(XmlSchemaDerivationMethod.List);
514 }
516 {
519 if (xmlSchemaSimpleTypeRestriction.BaseTypeName.IsEmpty)
520 {
522 simpleType.SetBaseSchemaType(xmlSchemaSimpleTypeRestriction.BaseType);
523 datatype2 = xmlSchemaSimpleTypeRestriction.BaseType.Datatype;
524 }
525 else if (simpleType.Redefined != null && xmlSchemaSimpleTypeRestriction.BaseTypeName == simpleType.Redefined.QualifiedName)
526 {
528 simpleType.SetBaseSchemaType(simpleType.Redefined.BaseXmlSchemaType);
529 datatype2 = simpleType.Redefined.Datatype;
530 }
531 else
532 {
534 {
536 }
538 if (simpleType3 == null)
539 {
541 }
542 if ((simpleType3.FinalResolved & XmlSchemaDerivationMethod.Restriction) != 0)
543 {
545 }
546 simpleType.SetBaseSchemaType(simpleType3);
547 datatype2 = simpleType3.Datatype;
548 }
549 simpleType.SetDatatype(datatype2.DeriveByRestriction(xmlSchemaSimpleTypeRestriction.Facets, base.NameTable, simpleType));
550 simpleType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction);
551 }
552 else
553 {
557 simpleType.SetDerivedBy(XmlSchemaDerivationMethod.Union);
558 }
559 }
560 catch (XmlSchemaException ex)
561 {
562 if (ex.SourceSchemaObject == null)
563 {
564 ex.SetSource(simpleType);
565 }
567 simpleType.SetDatatype(DatatypeImplementation.AnySimpleType.Datatype);
568 }
569 finally
570 {
577 }
578 }
579
581 {
585 if (memberTypes != null)
586 {
587 for (int i = 0; i < memberTypes.Length; i++)
588 {
590 if (simpleType2 != null)
591 {
592 if (simpleType2.Datatype.Variety == XmlSchemaDatatypeVariety.Union)
593 {
595 }
596 else
597 {
598 list.Add(simpleType2);
599 }
600 if ((simpleType2.FinalResolved & XmlSchemaDerivationMethod.Union) != 0)
601 {
603 }
604 continue;
605 }
607 }
608 }
610 if (baseTypes != null)
611 {
612 for (int j = 0; j < baseTypes.Count; j++)
613 {
616 if (xmlSchemaSimpleType.Datatype.Variety == XmlSchemaDatatypeVariety.Union)
617 {
619 }
620 else
621 {
623 }
624 }
625 }
626 xmlSchemaSimpleTypeUnion.SetBaseMemberTypes(list.ToArray());
627 return xmlSchemaSimpleTypeUnion.BaseMemberTypes;
628 }
629
641
643 {
644 if (complexType.ElementDecl != null)
645 {
646 return;
647 }
648 if (complexType.IsProcessing)
649 {
651 return;
652 }
654 if (complexType.ContentModel != null)
655 {
656 if (complexType.ContentModel is XmlSchemaSimpleContent)
657 {
659 complexType.SetContentType(XmlSchemaContentType.TextOnly);
661 {
663 }
664 else
665 {
667 }
668 }
669 else
670 {
673 {
675 }
676 else
677 {
679 }
680 }
681 }
682 else
683 {
684 complexType.SetBaseSchemaType(XmlSchemaComplexType.AnyType);
686 complexType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction);
687 complexType.SetContentTypeParticle(CompileContentTypeParticle(complexType.Particle, substitution: true));
688 complexType.SetContentType(GetSchemaContentType(complexType, null, complexType.ContentTypeParticle));
689 }
690 bool flag = false;
691 foreach (XmlSchemaAttribute value in complexType.AttributeUses.Values)
692 {
693 if (value.Use == XmlSchemaUse.Prohibited)
694 {
695 continue;
696 }
697 XmlSchemaDatatype datatype = value.Datatype;
698 if (datatype != null && datatype.TokenizedType == XmlTokenizedType.ID)
699 {
700 if (flag)
701 {
703 }
704 else
705 {
706 flag = true;
707 }
708 }
709 }
715 schemaElementDecl.Block = complexType.BlockResolved;
717 foreach (XmlSchemaAttribute value2 in complexType.AttributeUses.Values)
718 {
719 if (value2.Use == XmlSchemaUse.Prohibited)
720 {
721 if (!schemaElementDecl.ProhibitedAttributes.ContainsKey(value2.QualifiedName))
722 {
723 schemaElementDecl.ProhibitedAttributes.Add(value2.QualifiedName, value2.QualifiedName);
724 }
725 }
726 else if (!schemaElementDecl.AttDefs.ContainsKey(value2.QualifiedName) && value2.AttDef != null && value2.AttDef.Name != XmlQualifiedName.Empty && value2.AttDef != SchemaAttDef.Empty)
727 {
728 schemaElementDecl.AddAttDef(value2.AttDef);
729 }
730 }
733 }
734
736 {
738 if (complexType.Redefined != null && simpleExtension.BaseTypeName == complexType.Redefined.QualifiedName)
739 {
742 complexType.SetBaseSchemaType(xmlSchemaComplexType);
743 complexType.SetDatatype(xmlSchemaComplexType.Datatype);
744 }
745 else
746 {
748 if (anySchemaType == null)
749 {
751 }
752 else
753 {
754 complexType.SetBaseSchemaType(anySchemaType);
755 complexType.SetDatatype(anySchemaType.Datatype);
756 }
758 }
759 if (xmlSchemaComplexType != null)
760 {
761 if ((xmlSchemaComplexType.FinalResolved & XmlSchemaDerivationMethod.Extension) != 0)
762 {
764 }
765 if (xmlSchemaComplexType.ContentType != 0)
766 {
768 }
769 }
770 complexType.SetDerivedBy(XmlSchemaDerivationMethod.Extension);
772 }
773
775 {
778 if (complexType.Redefined != null && simpleRestriction.BaseTypeName == complexType.Redefined.QualifiedName)
779 {
783 }
784 else
785 {
787 if (xmlSchemaComplexType == null)
788 {
790 return;
791 }
792 if (xmlSchemaComplexType.ContentType == XmlSchemaContentType.TextOnly)
793 {
794 if (simpleRestriction.BaseType == null)
795 {
797 }
798 else
799 {
802 {
804 }
805 xmlSchemaDatatype = simpleRestriction.BaseType.Datatype;
806 }
807 }
808 else if (xmlSchemaComplexType.ContentType == XmlSchemaContentType.Mixed && xmlSchemaComplexType.ElementDecl.ContentValidator.IsEmptiable)
809 {
810 if (simpleRestriction.BaseType != null)
811 {
813 complexType.SetBaseSchemaType(simpleRestriction.BaseType);
814 xmlSchemaDatatype = simpleRestriction.BaseType.Datatype;
815 }
816 else
817 {
819 }
820 }
821 else
822 {
824 }
825 }
826 if (xmlSchemaComplexType != null && xmlSchemaComplexType.ElementDecl != null && (xmlSchemaComplexType.FinalResolved & XmlSchemaDerivationMethod.Restriction) != 0)
827 {
829 }
830 if (xmlSchemaComplexType != null)
831 {
832 complexType.SetBaseSchemaType(xmlSchemaComplexType);
833 }
834 if (xmlSchemaDatatype != null)
835 {
836 try
837 {
838 complexType.SetDatatype(xmlSchemaDatatype.DeriveByRestriction(simpleRestriction.Facets, base.NameTable, complexType));
839 }
840 catch (XmlSchemaException ex)
841 {
842 if (ex.SourceSchemaObject == null)
843 {
844 ex.SetSource(complexType);
845 }
848 }
849 }
850 complexType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction);
852 }
853
855 {
857 if (complexType.Redefined != null && complexExtension.BaseTypeName == complexType.Redefined.QualifiedName)
858 {
861 }
862 else
863 {
865 if (xmlSchemaComplexType == null)
866 {
868 return;
869 }
870 }
871 if (xmlSchemaComplexType != null && xmlSchemaComplexType.ElementDecl != null && xmlSchemaComplexType.ContentType == XmlSchemaContentType.TextOnly)
872 {
874 return;
875 }
876 complexType.SetBaseSchemaType(xmlSchemaComplexType);
877 if ((xmlSchemaComplexType.FinalResolved & XmlSchemaDerivationMethod.Extension) != 0)
878 {
880 }
885 {
887 {
892 }
893 else
894 {
895 complexType.SetContentTypeParticle(contentTypeParticle);
896 }
899 {
901 }
902 complexType.SetContentType(xmlSchemaContentType);
903 if (complexType.ContentType != xmlSchemaComplexType.ContentType)
904 {
906 }
907 }
908 else
909 {
910 complexType.SetContentTypeParticle(xmlSchemaParticle);
911 complexType.SetContentType(GetSchemaContentType(complexType, complexContent, complexType.ContentTypeParticle));
912 }
913 complexType.SetDerivedBy(XmlSchemaDerivationMethod.Extension);
914 }
915
917 {
919 if (complexType.Redefined != null && complexRestriction.BaseTypeName == complexType.Redefined.QualifiedName)
920 {
923 }
924 else
925 {
927 if (xmlSchemaComplexType == null)
928 {
930 return;
931 }
932 }
933 if (xmlSchemaComplexType != null && xmlSchemaComplexType.ElementDecl != null && xmlSchemaComplexType.ContentType == XmlSchemaContentType.TextOnly)
934 {
936 return;
937 }
938 complexType.SetBaseSchemaType(xmlSchemaComplexType);
939 if ((xmlSchemaComplexType.FinalResolved & XmlSchemaDerivationMethod.Restriction) != 0)
940 {
942 }
944 complexType.SetContentTypeParticle(CompileContentTypeParticle(complexRestriction.Particle, substitution: true));
945 complexType.SetContentType(GetSchemaContentType(complexType, complexContent, complexType.ContentTypeParticle));
946 if (complexType.ContentType == XmlSchemaContentType.Empty)
947 {
948 _ = xmlSchemaComplexType.ElementDecl;
949 if (xmlSchemaComplexType.ElementDecl != null && !xmlSchemaComplexType.ElementDecl.ContentValidator.IsEmptiable)
950 {
952 }
953 }
954 complexType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction);
955 }
956
964
978
980 {
981 if (particle == null || particle.IsEmpty)
982 {
984 }
985 if (particle is XmlSchemaElement)
986 {
988 }
989 if (particle is XmlSchemaGroupRef)
990 {
992 }
993 if (particle is XmlSchemaAll)
994 {
995 return CannonicalizeAll((XmlSchemaAll)particle, root, substitution);
996 }
997 if (particle is XmlSchemaChoice)
998 {
999 return CannonicalizeChoice((XmlSchemaChoice)particle, root, substitution);
1000 }
1001 if (particle is XmlSchemaSequence)
1002 {
1003 return CannonicalizeSequence((XmlSchemaSequence)particle, root, substitution);
1004 }
1005 return particle;
1006 }
1007
1024
1026 {
1028 if (xmlSchemaGroup == null)
1029 {
1031 return XmlSchemaParticle.Empty;
1032 }
1033 if (xmlSchemaGroup.CanonicalParticle == null)
1034 {
1036 }
1037 if (xmlSchemaGroup.CanonicalParticle == XmlSchemaParticle.Empty)
1038 {
1039 return XmlSchemaParticle.Empty;
1040 }
1043 {
1044 if (!root)
1045 {
1047 return XmlSchemaParticle.Empty;
1048 }
1049 if (groupRef.MinOccurs != 1m || groupRef.MaxOccurs != 1m)
1050 {
1052 return XmlSchemaParticle.Empty;
1053 }
1054 }
1056 {
1057 if (groupRef.MinOccurs != 0m)
1058 {
1060 }
1061 return XmlSchemaParticle.Empty;
1062 }
1066 for (int i = 0; i < xmlSchemaGroupBase.Items.Count; i++)
1067 {
1069 }
1070 groupRef.SetParticle(xmlSchemaGroupBase2);
1071 return xmlSchemaGroupBase2;
1072 }
1073
1075 {
1076 if (all.Items.Count > 0)
1077 {
1079 xmlSchemaAll.MinOccurs = all.MinOccurs;
1080 xmlSchemaAll.MaxOccurs = all.MaxOccurs;
1081 xmlSchemaAll.SourceUri = all.SourceUri;
1082 xmlSchemaAll.LineNumber = all.LineNumber;
1083 xmlSchemaAll.LinePosition = all.LinePosition;
1084 for (int i = 0; i < all.Items.Count; i++)
1085 {
1088 {
1090 }
1091 }
1092 all = xmlSchemaAll;
1093 }
1094 if (all.Items.Count == 0)
1095 {
1096 return XmlSchemaParticle.Empty;
1097 }
1098 if (root && all.Items.Count == 1)
1099 {
1101 xmlSchemaSequence.MinOccurs = all.MinOccurs;
1102 xmlSchemaSequence.MaxOccurs = all.MaxOccurs;
1103 xmlSchemaSequence.Items.Add((XmlSchemaParticle)all.Items[0]);
1104 return xmlSchemaSequence;
1105 }
1106 if (!root && all.Items.Count == 1 && all.MinOccurs == 1m && all.MaxOccurs == 1m)
1107 {
1108 return (XmlSchemaParticle)all.Items[0];
1109 }
1110 if (!root)
1111 {
1113 return XmlSchemaParticle.Empty;
1114 }
1115 return all;
1116 }
1117
1119 {
1121 if (choice.Items.Count > 0)
1122 {
1126 for (int i = 0; i < choice.Items.Count; i++)
1127 {
1130 {
1131 continue;
1132 }
1133 if (xmlSchemaParticle.MinOccurs == 1m && xmlSchemaParticle.MaxOccurs == 1m && xmlSchemaParticle is XmlSchemaChoice)
1134 {
1136 for (int j = 0; j < xmlSchemaChoice2.Items.Count; j++)
1137 {
1138 xmlSchemaChoice.Items.Add(xmlSchemaChoice2.Items[j]);
1139 }
1140 }
1141 else
1142 {
1144 }
1145 }
1147 }
1148 if (!root && choice.Items.Count == 0)
1149 {
1150 if (choice.MinOccurs != 0m)
1151 {
1153 }
1154 return XmlSchemaParticle.Empty;
1155 }
1156 if (!root && choice.Items.Count == 1 && choice.MinOccurs == 1m && choice.MaxOccurs == 1m)
1157 {
1158 return (XmlSchemaParticle)choice.Items[0];
1159 }
1160 return choice;
1161 }
1162
1164 {
1165 if (sequence.Items.Count > 0)
1166 {
1170 for (int i = 0; i < sequence.Items.Count; i++)
1171 {
1174 {
1175 continue;
1176 }
1177 if (xmlSchemaParticle.MinOccurs == 1m && xmlSchemaParticle.MaxOccurs == 1m && xmlSchemaParticle is XmlSchemaSequence)
1178 {
1180 for (int j = 0; j < xmlSchemaSequence2.Items.Count; j++)
1181 {
1183 }
1184 }
1185 else
1186 {
1188 }
1189 }
1191 }
1192 if (sequence.Items.Count == 0)
1193 {
1194 return XmlSchemaParticle.Empty;
1195 }
1196 if (!root && sequence.Items.Count == 1 && sequence.MinOccurs == 1m && sequence.MaxOccurs == 1m)
1197 {
1198 return (XmlSchemaParticle)sequence.Items[0];
1199 }
1200 return sequence;
1201 }
1202
1204 {
1206 {
1207 return true;
1208 }
1210 {
1212 }
1214 {
1215 return false;
1216 }
1218 {
1220 {
1222 }
1223 return false;
1224 }
1226 {
1228 {
1230 }
1232 {
1234 }
1236 }
1238 {
1240 {
1242 }
1244 {
1246 }
1248 {
1250 }
1251 }
1253 {
1255 {
1257 }
1259 {
1261 }
1263 {
1265 }
1266 }
1268 {
1270 {
1272 }
1274 {
1276 }
1277 }
1278 return false;
1279 }
1280
1282 {
1283 if (derivedElement.QualifiedName == baseElement.QualifiedName && derivedElement.IsNillable == baseElement.IsNillable && IsValidOccurrenceRangeRestriction(derivedElement, baseElement) && (baseElement.FixedValue == null || baseElement.FixedValue == derivedElement.FixedValue) && (derivedElement.BlockResolved | baseElement.BlockResolved) == derivedElement.BlockResolved && derivedElement.ElementSchemaType != null && baseElement.ElementSchemaType != null)
1284 {
1285 return XmlSchemaType.IsDerivedFrom(derivedElement.ElementSchemaType, baseElement.ElementSchemaType, ~XmlSchemaDerivationMethod.Restriction);
1286 }
1287 return false;
1288 }
1289
1291 {
1292 if (baseAny.Allows(derivedElement.QualifiedName))
1293 {
1295 }
1296 return false;
1297 }
1298
1300 {
1302 {
1303 return NamespaceList.IsSubset(derivedAny.NamespaceList, baseAny.NamespaceList);
1304 }
1305 return false;
1306 }
1307
1309 {
1312 {
1313 return false;
1314 }
1315 string minOccursString = baseAny.MinOccursString;
1317 for (int i = 0; i < derivedGroupBase.Items.Count; i++)
1318 {
1320 {
1322 return false;
1323 }
1324 }
1326 return true;
1327 }
1328
1330 {
1331 bool flag = false;
1332 for (int i = 0; i < baseGroupBase.Items.Count; i++)
1333 {
1335 if (!flag)
1336 {
1337 string minOccursString = xmlSchemaParticle.MinOccursString;
1338 string maxOccursString = xmlSchemaParticle.MaxOccursString;
1340 if (xmlSchemaParticle.MaxOccurs != decimal.MaxValue)
1341 {
1342 if (baseGroupBase.MaxOccurs == decimal.MaxValue)
1343 {
1344 xmlSchemaParticle.MaxOccurs = decimal.MaxValue;
1345 }
1346 else
1347 {
1349 }
1350 }
1354 }
1356 {
1357 return false;
1358 }
1359 }
1360 return flag;
1361 }
1362
1364 {
1366 {
1367 return false;
1368 }
1369 int num = 0;
1370 for (int i = 0; i < baseGroupBase.Items.Count; i++)
1371 {
1374 {
1375 num++;
1376 }
1378 {
1379 return false;
1380 }
1381 }
1382 if (num < derivedGroupBase.Items.Count)
1383 {
1384 return false;
1385 }
1386 return true;
1387 }
1388
1390 {
1392 {
1393 return false;
1394 }
1395 BitSet bitSet = new BitSet(baseAll.Items.Count);
1396 for (int i = 0; i < derivedSequence.Items.Count; i++)
1397 {
1399 if (mappingParticle >= 0)
1400 {
1402 {
1403 return false;
1404 }
1406 continue;
1407 }
1408 return false;
1409 }
1410 for (int j = 0; j < baseAll.Items.Count; j++)
1411 {
1413 {
1414 return false;
1415 }
1416 }
1417 return true;
1418 }
1419
1421 {
1424 {
1425 return false;
1426 }
1427 for (int i = 0; i < derivedSequence.Items.Count; i++)
1428 {
1430 {
1431 return false;
1432 }
1433 }
1434 return true;
1435 }
1436
1438 {
1439 minOccurs = default(decimal);
1440 maxOccurs = default(decimal);
1441 for (int i = 0; i < sequence.Items.Count; i++)
1442 {
1444 minOccurs += xmlSchemaParticle.MinOccurs;
1445 if (xmlSchemaParticle.MaxOccurs == decimal.MaxValue)
1446 {
1447 maxOccurs = decimal.MaxValue;
1448 }
1449 else if (maxOccurs != decimal.MaxValue)
1450 {
1451 maxOccurs += xmlSchemaParticle.MaxOccurs;
1452 }
1453 }
1454 minOccurs *= sequence.MinOccurs;
1455 if (sequence.MaxOccurs == decimal.MaxValue)
1456 {
1457 maxOccurs = decimal.MaxValue;
1458 }
1459 else if (maxOccurs != decimal.MaxValue)
1460 {
1461 maxOccurs *= sequence.MaxOccurs;
1462 }
1463 }
1464
1469
1471 {
1472 if (baseMinOccurs <= minOccurs)
1473 {
1474 return maxOccurs <= baseMaxOccurs;
1475 }
1476 return false;
1477 }
1478
1480 {
1481 for (int i = 0; i < collection.Count; i++)
1482 {
1484 {
1485 return i;
1486 }
1487 }
1488 return -1;
1489 }
1490
1492 {
1494 return minOccurs == 0m;
1495 }
1496
1498 {
1499 if (particle is XmlSchemaElement || particle is XmlSchemaAny)
1500 {
1501 minOccurs = particle.MinOccurs;
1502 maxOccurs = particle.MaxOccurs;
1503 return;
1504 }
1505 if (particle is XmlSchemaChoice)
1506 {
1507 if (((XmlSchemaChoice)particle).Items.Count == 0)
1508 {
1509 minOccurs = (maxOccurs = 0m);
1510 return;
1511 }
1512 minOccurs = decimal.MaxValue;
1513 maxOccurs = default(decimal);
1515 for (int i = 0; i < xmlSchemaChoice.Items.Count; i++)
1516 {
1518 if (minOccurs2 < minOccurs)
1519 {
1521 }
1522 if (maxOccurs2 > maxOccurs)
1523 {
1525 }
1526 }
1527 minOccurs *= particle.MinOccurs;
1528 if (maxOccurs != decimal.MaxValue)
1529 {
1530 if (particle.MaxOccurs == decimal.MaxValue)
1531 {
1532 maxOccurs = decimal.MaxValue;
1533 }
1534 else
1535 {
1536 maxOccurs *= particle.MaxOccurs;
1537 }
1538 }
1539 return;
1540 }
1541 XmlSchemaObjectCollection items = ((XmlSchemaGroupBase)particle).Items;
1542 if (items.Count == 0)
1543 {
1544 minOccurs = (maxOccurs = 0m);
1545 return;
1546 }
1547 minOccurs = default(decimal);
1548 maxOccurs = default(decimal);
1549 for (int j = 0; j < items.Count; j++)
1550 {
1553 if (maxOccurs != decimal.MaxValue)
1554 {
1555 if (maxOccurs3 == decimal.MaxValue)
1556 {
1557 maxOccurs = decimal.MaxValue;
1558 }
1559 else
1560 {
1562 }
1563 }
1564 }
1565 minOccurs *= particle.MinOccurs;
1566 if (maxOccurs != decimal.MaxValue)
1567 {
1568 if (particle.MaxOccurs == decimal.MaxValue)
1569 {
1570 maxOccurs = decimal.MaxValue;
1571 }
1572 else
1573 {
1574 maxOccurs *= particle.MaxOccurs;
1575 }
1576 }
1577 }
1578
1583
1585 {
1586 if ((complexContent != null && complexContent.IsMixed) || (complexContent == null && complexType.IsMixed))
1587 {
1588 return XmlSchemaContentType.Mixed;
1589 }
1590 if (particle != null && !particle.IsEmpty)
1591 {
1592 return XmlSchemaContentType.ElementOnly;
1593 }
1594 return XmlSchemaContentType.Empty;
1595 }
1596
1598 {
1599 if (attributeGroup.IsProcessing)
1600 {
1602 }
1603 else
1604 {
1605 if (attributeGroup.AttributeUses.Count > 0)
1606 {
1607 return;
1608 }
1611 for (int i = 0; i < attributeGroup.Attributes.Count; i++)
1612 {
1614 {
1615 if (xmlSchemaAttribute.Use != XmlSchemaUse.Prohibited)
1616 {
1618 }
1619 if (attributeGroup.AttributeUses[xmlSchemaAttribute.QualifiedName] == null)
1620 {
1621 attributeGroup.AttributeUses.Add(xmlSchemaAttribute.QualifiedName, xmlSchemaAttribute);
1622 }
1623 else
1624 {
1626 }
1627 continue;
1628 }
1631 if (xmlSchemaAttributeGroup != null)
1632 {
1634 foreach (XmlSchemaAttribute value in xmlSchemaAttributeGroup.AttributeUses.Values)
1635 {
1636 if (attributeGroup.AttributeUses[value.QualifiedName] == null)
1637 {
1638 attributeGroup.AttributeUses.Add(value.QualifiedName, value);
1639 }
1640 else
1641 {
1642 SendValidationEvent(System.SR.Sch_DupAttributeUse, value.QualifiedName.ToString(), value);
1643 }
1644 }
1646 }
1647 else
1648 {
1650 }
1651 }
1654 }
1655 }
1656
1658 {
1660 for (int i = 0; i < attributes.Count; i++)
1661 {
1662 if (attributes[i] is XmlSchemaAttribute xmlSchemaAttribute)
1663 {
1664 if (xmlSchemaAttribute.Use != XmlSchemaUse.Prohibited)
1665 {
1667 }
1669 {
1670 if (derivedType.AttributeUses[xmlSchemaAttribute.QualifiedName] == null)
1671 {
1672 derivedType.AttributeUses.Add(xmlSchemaAttribute.QualifiedName, xmlSchemaAttribute);
1673 }
1674 else
1675 {
1677 }
1678 }
1679 else
1680 {
1682 }
1683 continue;
1684 }
1687 if (xmlSchemaAttributeGroup != null)
1688 {
1690 foreach (XmlSchemaAttribute value in xmlSchemaAttributeGroup.AttributeUses.Values)
1691 {
1692 if (value.Use != XmlSchemaUse.Prohibited || (value.Use == XmlSchemaUse.Prohibited && derivedBy == XmlSchemaDerivationMethod.Restriction && baseType != XmlSchemaComplexType.AnyType))
1693 {
1694 if (derivedType.AttributeUses[value.QualifiedName] == null)
1695 {
1696 derivedType.AttributeUses.Add(value.QualifiedName, value);
1697 }
1698 else
1699 {
1701 }
1702 }
1703 else
1704 {
1705 SendValidationEvent(System.SR.Sch_AttributeIgnored, value.QualifiedName.ToString(), value, XmlSeverityType.Warning);
1706 }
1707 }
1709 }
1710 else
1711 {
1713 }
1714 }
1715 if (baseType != null)
1716 {
1717 if (derivedBy == XmlSchemaDerivationMethod.Extension)
1718 {
1720 {
1721 foreach (XmlSchemaAttribute value2 in baseType.AttributeUses.Values)
1722 {
1724 if (xmlSchemaAttribute4 != null)
1725 {
1726 if (xmlSchemaAttribute4.AttributeSchemaType != value2.AttributeSchemaType || value2.Use == XmlSchemaUse.Prohibited)
1727 {
1729 }
1730 }
1731 else
1732 {
1733 derivedType.AttributeUses.Add(value2.QualifiedName, value2);
1734 }
1735 }
1736 return;
1737 }
1738 }
1740 {
1742 }
1743 else
1744 {
1745 derivedType.SetAttributeWildcard(anyAttribute);
1746 }
1747 foreach (XmlSchemaAttribute value3 in baseType.AttributeUses.Values)
1748 {
1750 if (xmlSchemaAttribute6 == null)
1751 {
1752 derivedType.AttributeUses.Add(value3.QualifiedName, value3);
1753 }
1754 else if (value3.Use == XmlSchemaUse.Prohibited && xmlSchemaAttribute6.Use != XmlSchemaUse.Prohibited)
1755 {
1757 }
1758 else if (xmlSchemaAttribute6.Use != XmlSchemaUse.Prohibited && (value3.AttributeSchemaType == null || xmlSchemaAttribute6.AttributeSchemaType == null || !XmlSchemaType.IsDerivedFrom(xmlSchemaAttribute6.AttributeSchemaType, value3.AttributeSchemaType, XmlSchemaDerivationMethod.Empty)))
1759 {
1761 }
1762 }
1763 {
1764 foreach (XmlSchemaAttribute value4 in derivedType.AttributeUses.Values)
1765 {
1767 if (xmlSchemaAttribute8 == null && (xmlSchemaAnyAttribute == null || !xmlSchemaAnyAttribute.Allows(value4.QualifiedName)))
1768 {
1770 }
1771 }
1772 return;
1773 }
1774 }
1775 derivedType.SetAttributeWildcard(anyAttribute);
1776 }
1777
1779 {
1780 if (a == null)
1781 {
1782 return b;
1783 }
1784 if (b == null)
1785 {
1786 return a;
1787 }
1789 if (xmlSchemaAnyAttribute == null)
1790 {
1792 }
1793 return xmlSchemaAnyAttribute;
1794 }
1795
1797 {
1798 if (a == null)
1799 {
1800 return b;
1801 }
1802 if (b == null)
1803 {
1804 return a;
1805 }
1807 if (xmlSchemaAnyAttribute == null)
1808 {
1810 }
1811 return xmlSchemaAnyAttribute;
1812 }
1813
1815 {
1816 if (xa.IsProcessing)
1817 {
1819 }
1820 else
1821 {
1822 if (xa.AttDef != null)
1823 {
1824 return;
1825 }
1826 xa.IsProcessing = true;
1828 try
1829 {
1830 if (!xa.RefName.IsEmpty)
1831 {
1833 if (xmlSchemaAttribute == null)
1834 {
1835 throw new XmlSchemaException(System.SR.Sch_UndeclaredAttribute, xa.RefName.ToString(), xa);
1836 }
1838 if (xmlSchemaAttribute.AttDef == null)
1839 {
1840 throw new XmlSchemaException(System.SR.Sch_RefInvalidAttribute, xa.RefName.ToString(), xa);
1841 }
1842 schemaAttDef = xmlSchemaAttribute.AttDef.Clone();
1843 if (schemaAttDef.Datatype != null)
1844 {
1845 if (xmlSchemaAttribute.FixedValue != null)
1846 {
1847 if (xa.DefaultValue != null)
1848 {
1849 throw new XmlSchemaException(System.SR.Sch_FixedDefaultInRef, xa.RefName.ToString(), xa);
1850 }
1851 if (xa.FixedValue != null)
1852 {
1853 if (xa.FixedValue != xmlSchemaAttribute.FixedValue)
1854 {
1855 throw new XmlSchemaException(System.SR.Sch_FixedInRef, xa.RefName.ToString(), xa);
1856 }
1857 }
1858 else
1859 {
1862 string defaultValueRaw = (schemaAttDef.DefaultValueExpanded = xmlSchemaAttribute.FixedValue);
1863 schemaAttDef2.DefaultValueRaw = defaultValueRaw;
1864 schemaAttDef.DefaultValueTyped = schemaAttDef.Datatype.ParseValue(schemaAttDef.DefaultValueRaw, base.NameTable, new SchemaNamespaceManager(xa), createAtomicValue: true);
1865 }
1866 }
1867 else if (xmlSchemaAttribute.DefaultValue != null && xa.DefaultValue == null && xa.FixedValue == null)
1868 {
1871 string defaultValueRaw = (schemaAttDef.DefaultValueExpanded = xmlSchemaAttribute.DefaultValue);
1872 schemaAttDef3.DefaultValueRaw = defaultValueRaw;
1873 schemaAttDef.DefaultValueTyped = schemaAttDef.Datatype.ParseValue(schemaAttDef.DefaultValueRaw, base.NameTable, new SchemaNamespaceManager(xa), createAtomicValue: true);
1874 }
1875 }
1876 xa.SetAttributeType(xmlSchemaAttribute.AttributeSchemaType);
1877 }
1878 else
1879 {
1880 schemaAttDef = new SchemaAttDef(xa.QualifiedName);
1881 if (xa.SchemaType != null)
1882 {
1883 CompileSimpleType(xa.SchemaType);
1884 xa.SetAttributeType(xa.SchemaType);
1885 schemaAttDef.SchemaType = xa.SchemaType;
1886 schemaAttDef.Datatype = xa.SchemaType.Datatype;
1887 }
1888 else if (!xa.SchemaTypeName.IsEmpty)
1889 {
1891 if (simpleType == null)
1892 {
1893 throw new XmlSchemaException(System.SR.Sch_UndeclaredSimpleType, xa.SchemaTypeName.ToString(), xa);
1894 }
1895 xa.SetAttributeType(simpleType);
1898 }
1899 else
1900 {
1903 xa.SetAttributeType(DatatypeImplementation.AnySimpleType);
1904 }
1905 }
1906 if (schemaAttDef.Datatype != null)
1907 {
1908 schemaAttDef.Datatype.VerifySchemaValid(_schema.Notations, xa);
1909 }
1910 if (xa.DefaultValue != null || xa.FixedValue != null)
1911 {
1912 if (xa.DefaultValue != null)
1913 {
1916 string defaultValueRaw = (schemaAttDef.DefaultValueExpanded = xa.DefaultValue);
1917 schemaAttDef4.DefaultValueRaw = defaultValueRaw;
1918 }
1919 else
1920 {
1923 string defaultValueRaw = (schemaAttDef.DefaultValueExpanded = xa.FixedValue);
1924 schemaAttDef5.DefaultValueRaw = defaultValueRaw;
1925 }
1926 if (schemaAttDef.Datatype != null)
1927 {
1928 schemaAttDef.DefaultValueTyped = schemaAttDef.Datatype.ParseValue(schemaAttDef.DefaultValueRaw, base.NameTable, new SchemaNamespaceManager(xa), createAtomicValue: true);
1929 }
1930 }
1931 else
1932 {
1933 switch (xa.Use)
1934 {
1935 case XmlSchemaUse.None:
1936 case XmlSchemaUse.Optional:
1938 break;
1939 case XmlSchemaUse.Required:
1941 break;
1942 }
1943 }
1946 }
1947 catch (XmlSchemaException ex)
1948 {
1949 if (ex.SourceSchemaObject == null)
1950 {
1951 ex.SetSource(xa);
1952 }
1955 }
1956 finally
1957 {
1958 xa.IsProcessing = false;
1959 }
1960 }
1961 }
1962
1964 {
1965 if (xi.IsProcessing)
1966 {
1969 }
1970 else
1971 {
1972 if (xi.CompiledConstraint != null)
1973 {
1974 return;
1975 }
1976 xi.IsProcessing = true;
1978 try
1979 {
1982 if (xi is XmlSchemaKeyref)
1983 {
1985 if (xmlSchemaIdentityConstraint == null)
1986 {
1988 }
1990 if (xmlSchemaIdentityConstraint.CompiledConstraint == null)
1991 {
1993 }
1994 if (xmlSchemaIdentityConstraint.Fields.Count != xi.Fields.Count)
1995 {
1996 throw new XmlSchemaException(System.SR.Sch_RefInvalidCardin, xi.QualifiedName.ToString(), xi);
1997 }
1998 if (xmlSchemaIdentityConstraint.CompiledConstraint.Role == CompiledIdentityConstraint.ConstraintRole.Keyref)
1999 {
2000 throw new XmlSchemaException(System.SR.Sch_ReftoKeyref, xi.QualifiedName.ToString(), xi);
2001 }
2002 }
2004 }
2005 catch (XmlSchemaException ex)
2006 {
2007 if (ex.SourceSchemaObject == null)
2008 {
2009 ex.SetSource(xi);
2010 }
2013 }
2014 finally
2015 {
2016 xi.IsProcessing = false;
2017 }
2018 }
2019 }
2020
2022 {
2023 if (xe.IsProcessing)
2024 {
2026 }
2027 else
2028 {
2029 if (xe.ElementDecl != null)
2030 {
2031 return;
2032 }
2033 xe.IsProcessing = true;
2035 try
2036 {
2037 if (!xe.RefName.IsEmpty)
2038 {
2040 if (xmlSchemaElement == null)
2041 {
2042 throw new XmlSchemaException(System.SR.Sch_UndeclaredElement, xe.RefName.ToString(), xe);
2043 }
2045 if (xmlSchemaElement.ElementDecl == null)
2046 {
2047 throw new XmlSchemaException(System.SR.Sch_RefInvalidElement, xe.RefName.ToString(), xe);
2048 }
2049 xe.SetElementType(xmlSchemaElement.ElementSchemaType);
2050 schemaElementDecl = xmlSchemaElement.ElementDecl.Clone();
2051 }
2052 else
2053 {
2054 if (xe.SchemaType != null)
2055 {
2056 xe.SetElementType(xe.SchemaType);
2057 }
2058 else if (!xe.SchemaTypeName.IsEmpty)
2059 {
2060 xe.SetElementType(GetAnySchemaType(xe.SchemaTypeName));
2061 if (xe.ElementSchemaType == null)
2062 {
2063 throw new XmlSchemaException(System.SR.Sch_UndeclaredType, xe.SchemaTypeName.ToString(), xe);
2064 }
2065 }
2066 else if (!xe.SubstitutionGroup.IsEmpty)
2067 {
2069 if (xmlSchemaElement2 == null)
2070 {
2071 throw new XmlSchemaException(System.SR.Sch_UndeclaredEquivClass, xe.SubstitutionGroup.Name, xe);
2072 }
2073 if (xmlSchemaElement2.IsProcessing)
2074 {
2075 return;
2076 }
2078 if (xmlSchemaElement2.ElementDecl == null)
2079 {
2080 xe.SetElementType(XmlSchemaComplexType.AnyType);
2081 schemaElementDecl = XmlSchemaComplexType.AnyType.ElementDecl.Clone();
2082 }
2083 else
2084 {
2085 xe.SetElementType(xmlSchemaElement2.ElementSchemaType);
2086 schemaElementDecl = xmlSchemaElement2.ElementDecl.Clone();
2087 }
2088 }
2089 else
2090 {
2091 xe.SetElementType(XmlSchemaComplexType.AnyType);
2092 schemaElementDecl = XmlSchemaComplexType.AnyType.ElementDecl.Clone();
2093 }
2094 if (schemaElementDecl == null)
2095 {
2096 if (xe.ElementSchemaType is XmlSchemaComplexType)
2097 {
2100 if (xmlSchemaComplexType.ElementDecl != null)
2101 {
2102 schemaElementDecl = xmlSchemaComplexType.ElementDecl.Clone();
2103 }
2104 }
2105 else if (xe.ElementSchemaType is XmlSchemaSimpleType)
2106 {
2109 if (xmlSchemaSimpleType.ElementDecl != null)
2110 {
2111 schemaElementDecl = xmlSchemaSimpleType.ElementDecl.Clone();
2112 }
2113 }
2114 }
2115 schemaElementDecl.Name = xe.QualifiedName;
2116 schemaElementDecl.IsAbstract = xe.IsAbstract;
2117 if (xe.ElementSchemaType is XmlSchemaComplexType xmlSchemaComplexType2)
2118 {
2120 }
2121 schemaElementDecl.IsNillable = xe.IsNillable;
2122 schemaElementDecl.Block |= xe.BlockResolved;
2123 }
2124 if (schemaElementDecl.Datatype != null)
2125 {
2126 schemaElementDecl.Datatype.VerifySchemaValid(_schema.Notations, xe);
2127 }
2128 if ((xe.DefaultValue != null || xe.FixedValue != null) && schemaElementDecl.ContentValidator != null)
2129 {
2130 if (schemaElementDecl.ContentValidator.ContentType == XmlSchemaContentType.TextOnly)
2131 {
2132 if (xe.DefaultValue != null)
2133 {
2136 }
2137 else
2138 {
2141 }
2142 if (schemaElementDecl.Datatype != null)
2143 {
2144 schemaElementDecl.DefaultValueTyped = schemaElementDecl.Datatype.ParseValue(schemaElementDecl.DefaultValueRaw, base.NameTable, new SchemaNamespaceManager(xe), createAtomicValue: true);
2145 }
2146 }
2147 else if (schemaElementDecl.ContentValidator.ContentType != XmlSchemaContentType.Mixed || !schemaElementDecl.ContentValidator.IsEmptiable)
2148 {
2150 }
2151 }
2152 if (xe.HasConstraints)
2153 {
2156 int num = 0;
2157 for (int i = 0; i < constraints.Count; i++)
2158 {
2161 array[num++] = xmlSchemaIdentityConstraint.CompiledConstraint;
2162 }
2164 }
2167 }
2168 catch (XmlSchemaException ex)
2169 {
2170 if (ex.SourceSchemaObject == null)
2171 {
2172 ex.SetSource(xe);
2173 }
2176 }
2177 finally
2178 {
2179 xe.IsProcessing = false;
2180 }
2181 }
2182 }
2183
2185 {
2186 if (complexType.ContentType == XmlSchemaContentType.Empty)
2187 {
2188 return ContentValidator.Empty;
2189 }
2190 if (complexType.ContentType == XmlSchemaContentType.TextOnly)
2191 {
2193 }
2196 {
2197 if (complexType.ContentType == XmlSchemaContentType.ElementOnly)
2198 {
2199 return ContentValidator.Empty;
2200 }
2201 return ContentValidator.Mixed;
2202 }
2205 {
2208 for (int i = 0; i < xmlSchemaAll.Items.Count; i++)
2209 {
2211 if (!allElementsContentValidator.AddElement(xmlSchemaElement.QualifiedName, xmlSchemaElement, xmlSchemaElement.MinOccurs == 0m))
2212 {
2214 }
2215 }
2217 }
2219 try
2220 {
2224 }
2225 catch (UpaException ex)
2226 {
2227 if (ex.Particle1 is XmlSchemaElement)
2228 {
2229 if (ex.Particle2 is XmlSchemaElement)
2230 {
2231 SendValidationEvent(System.SR.Sch_NonDeterministic, ((XmlSchemaElement)ex.Particle1).QualifiedName.ToString(), (XmlSchemaElement)ex.Particle2);
2232 }
2233 else
2234 {
2235 SendValidationEvent(System.SR.Sch_NonDeterministicAnyEx, ((XmlSchemaAny)ex.Particle2).NamespaceList.ToString(), ((XmlSchemaElement)ex.Particle1).QualifiedName.ToString(), (XmlSchemaAny)ex.Particle2);
2236 }
2237 }
2238 else if (ex.Particle2 is XmlSchemaElement)
2239 {
2240 SendValidationEvent(System.SR.Sch_NonDeterministicAnyEx, ((XmlSchemaAny)ex.Particle1).NamespaceList.ToString(), ((XmlSchemaElement)ex.Particle2).QualifiedName.ToString(), (XmlSchemaAny)ex.Particle1);
2241 }
2242 else
2243 {
2244 SendValidationEvent(System.SR.Sch_NonDeterministicAnyAny, ((XmlSchemaAny)ex.Particle1).NamespaceList.ToString(), ((XmlSchemaAny)ex.Particle2).NamespaceList.ToString(), (XmlSchemaAny)ex.Particle1);
2245 }
2247 }
2248 catch (NotSupportedException)
2249 {
2252 }
2253 }
2254
2256 {
2257 if (particle is XmlSchemaElement)
2258 {
2260 contentValidator.AddName(xmlSchemaElement.QualifiedName, xmlSchemaElement);
2261 }
2262 else if (particle is XmlSchemaAny)
2263 {
2265 contentValidator.AddNamespaceList(xmlSchemaAny.NamespaceList, xmlSchemaAny);
2266 }
2267 else if (particle is XmlSchemaGroupBase)
2268 {
2269 XmlSchemaObjectCollection items = ((XmlSchemaGroupBase)particle).Items;
2270 bool flag = particle is XmlSchemaChoice;
2271 contentValidator.OpenGroup();
2272 bool flag2 = true;
2273 for (int i = 0; i < items.Count; i++)
2274 {
2276 if (flag2)
2277 {
2278 flag2 = false;
2279 }
2280 else if (flag)
2281 {
2282 contentValidator.AddChoice();
2283 }
2284 else
2285 {
2286 contentValidator.AddSequence();
2287 }
2289 }
2290 contentValidator.CloseGroup();
2291 }
2292 if (!(particle.MinOccurs == 1m) || !(particle.MaxOccurs == 1m))
2293 {
2294 if (particle.MinOccurs == 0m && particle.MaxOccurs == 1m)
2295 {
2296 contentValidator.AddQMark();
2297 }
2298 else if (particle.MinOccurs == 0m && particle.MaxOccurs == decimal.MaxValue)
2299 {
2300 contentValidator.AddStar();
2301 }
2302 else if (particle.MinOccurs == 1m && particle.MaxOccurs == decimal.MaxValue)
2303 {
2304 contentValidator.AddPlus();
2305 }
2306 else
2307 {
2308 contentValidator.AddLeafRange(particle.MinOccurs, particle.MaxOccurs);
2309 }
2310 }
2311 }
2312
2314 {
2315 if (particle is XmlSchemaElement)
2316 {
2319 if (complexType.LocalElements[xmlSchemaElement.QualifiedName] == null)
2320 {
2321 complexType.LocalElements.Add(xmlSchemaElement.QualifiedName, xmlSchemaElement);
2322 return;
2323 }
2325 if (xmlSchemaElement2.ElementSchemaType != xmlSchemaElement.ElementSchemaType)
2326 {
2328 }
2329 }
2330 else if (particle is XmlSchemaGroupBase)
2331 {
2332 XmlSchemaObjectCollection items = ((XmlSchemaGroupBase)particle).Items;
2333 for (int i = 0; i < items.Count; i++)
2334 {
2336 }
2337 }
2338 }
2339
2341 {
2342 if (complexType.IsProcessing)
2343 {
2345 return;
2346 }
2348 if (complexType.ContentTypeParticle != XmlSchemaParticle.Empty)
2349 {
2350 CompileParticleElements(complexType, complexType.ContentTypeParticle);
2351 }
2353 }
2354
2379
2389
2407}
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
void AddRange(IEnumerable< KeyValuePair< TKey, TValue > > collection)
void Add(TKey key, TValue value)
static string Sch_GroupCircularRef
Definition SR.cs:1034
static string Sch_UndefAttributeGroupRef
Definition SR.cs:1044
static string Sch_SubstitutionCircularRef
Definition SR.cs:930
static string Sch_ElementCircularRef
Definition SR.cs:1066
static string Sch_NonDeterministic
Definition SR.cs:584
static string Sch_AttributeRestrictionInvalid
Definition SR.cs:1052
static string Sch_InvalidExamplar
Definition SR.cs:942
static string Sch_IdentityConstraintCircularRef
Definition SR.cs:928
static string Sch_NotSimpleContent
Definition SR.cs:962
static string Sch_TypeCircularRef
Definition SR.cs:952
static string Sch_ElementCannotHaveValue
Definition SR.cs:1070
static string Sch_UndeclaredEquivClass
Definition SR.cs:562
static string Sch_InvalidContentRestriction
Definition SR.cs:978
static string Sch_InvalidParticleRestriction
Definition SR.cs:988
static string Sch_UndefGroupRef
Definition SR.cs:1032
static string Sch_DupAttributeUse
Definition SR.cs:986
static string Sch_InvalidSimpleTypeRestriction
Definition SR.cs:1152
static string Sch_RefInvalidCardin
Definition SR.cs:724
static string Sch_UndeclaredSimpleType
Definition SR.cs:560
static string Sch_BaseFinalUnion
Definition SR.cs:970
static string Sch_AttributeRestrictionInvalidFromWildcard
Definition SR.cs:1058
static string Sch_RefInvalidElement
Definition SR.cs:1068
static string Sch_NeedSimpleTypeChild
Definition SR.cs:1146
static string Sch_InvalidAttributeExtension
Definition SR.cs:1046
static string Sch_DifContentType
Definition SR.cs:976
static string Sch_UnionFromUnion
Definition SR.cs:608
static string Sch_AttributeRestrictionProhibited
Definition SR.cs:1050
static string Sch_UndeclaredType
Definition SR.cs:558
static string Sch_FixedInRef
Definition SR.cs:538
static string Sch_InvalidSubstitutionMember
Definition SR.cs:946
static string Sch_NotComplexContent
Definition SR.cs:964
static string Sch_BaseFinalExtension
Definition SR.cs:960
static string Sch_ElementTypeCollision
Definition SR.cs:1074
static string Sch_InvalidAnyAttributeRestriction
Definition SR.cs:1048
static string Sch_BaseFinalList
Definition SR.cs:968
static string Sch_AllRefMinMax
Definition SR.cs:1038
static string Sch_DerivedNotFromBase
Definition SR.cs:1144
static string Sch_UnexpressibleAnyAttribute
Definition SR.cs:1062
static string Sch_FixedDefaultInRef
Definition SR.cs:540
static string Sch_EmptyChoice
Definition SR.cs:1142
static string Sch_DupElement
Definition SR.cs:480
static string Sch_NoExamplar
Definition SR.cs:944
static string Sch_UndeclaredElement
Definition SR.cs:412
static string Sch_AttributeIgnored
Definition SR.cs:546
static string Sch_RefInvalidIdentityConstraint
Definition SR.cs:722
static string Sch_RefInvalidAttribute
Definition SR.cs:1064
static string Sch_AttributeGroupCircularRef
Definition SR.cs:1042
static string Sch_UndeclaredIdentityConstraint
Definition SR.cs:720
static string Sch_ComplexContentModel
Definition SR.cs:1158
static string Sch_ReftoKeyref
Definition SR.cs:726
static string Sch_UndefBaseExtension
Definition SR.cs:974
static string Sch_AttributeCircularRef
Definition SR.cs:926
static string Sch_UndefBaseRestriction
Definition SR.cs:972
static string Sch_BaseFinalRestriction
Definition SR.cs:966
static string Sch_NonDeterministicAnyEx
Definition SR.cs:586
static string Sch_TwoIdAttrUses
Definition SR.cs:954
static string Sch_UndeclaredAttribute
Definition SR.cs:414
static string Sch_AllRefNotRoot
Definition SR.cs:1036
static string Sch_NonDeterministicAnyAny
Definition SR.cs:588
static string Sch_NotAllAlone
Definition SR.cs:1040
Definition SR.cs:7
void SendValidationEvent(string code, XmlSchemaObject source)
static readonly CompiledIdentityConstraint Empty
static readonly ContentValidator Empty
static readonly ContentValidator Mixed
static readonly ContentValidator TextOnly
static XmlSchemaSimpleType GetTokenTypeV1Compat()
static XmlSchemaSimpleType GetNormalizedStringTypeV1Compat()
static XmlSchemaSimpleType GetSimpleTypeFromXsdType(XmlQualifiedName qname)
static bool IsSubset(NamespaceList sub, NamespaceList super)
static readonly SchemaAttDef Empty
bool IsGroupBaseFromAny(XmlSchemaGroupBase derivedGroupBase, XmlSchemaAny baseAny)
void CompileComplexContentRestriction(XmlSchemaComplexType complexType, XmlSchemaComplexContent complexContent, XmlSchemaComplexContentRestriction complexRestriction)
void CalculateEffectiveTotalRange(XmlSchemaParticle particle, out decimal minOccurs, out decimal maxOccurs)
bool IsAnyFromAny(XmlSchemaAny derivedAny, XmlSchemaAny baseAny)
void CompileLocalAttributes(XmlSchemaComplexType baseType, XmlSchemaComplexType derivedType, XmlSchemaObjectCollection attributes, XmlSchemaAnyAttribute anyAttribute, XmlSchemaDerivationMethod derivedBy)
void CheckSubstitutionGroup(XmlSchemaSubstitutionGroup substitutionGroup)
void CompileSimpleContentRestriction(XmlSchemaComplexType complexType, XmlSchemaSimpleContentRestriction simpleRestriction)
bool IsValidRestriction(XmlSchemaParticle derivedParticle, XmlSchemaParticle baseParticle)
XmlSchemaParticle CannonicalizeParticle(XmlSchemaParticle particle, bool root, bool substitution)
ContentValidator CompileComplexContent(XmlSchemaComplexType complexType)
XmlSchemaSimpleType GetSimpleType(XmlQualifiedName name)
bool IsElementFromGroupBase(XmlSchemaElement derivedElement, XmlSchemaGroupBase baseGroupBase, bool skipEmptableOnly)
int GetMappingParticle(XmlSchemaParticle particle, XmlSchemaObjectCollection collection)
bool IsSequenceFromChoice(XmlSchemaSequence derivedSequence, XmlSchemaChoice baseChoice)
void CheckUnionType(XmlSchemaSimpleType unionMember, List< XmlSchemaSimpleType > memberTypeDefinitions, XmlSchemaSimpleType parentType)
bool IsValidOccurrenceRangeRestriction(decimal minOccurs, decimal maxOccurs, decimal baseMinOccurs, decimal baseMaxOccurs)
static void CleanupAttribute(XmlSchemaAttribute attribute)
void CompileAttributeGroup(XmlSchemaAttributeGroup attributeGroup)
void PushComplexType(XmlSchemaComplexType complexType)
readonly Stack< XmlSchemaComplexType > _complexTypeStack
static void CleanupComplexType(XmlSchemaComplexType complexType)
bool IsSequenceFromAll(XmlSchemaSequence derivedSequence, XmlSchemaAll baseAll)
XmlSchemaComplexType GetComplexType(XmlQualifiedName name)
SchemaCollectionCompiler(XmlNameTable nameTable, ValidationEventHandler eventHandler)
static void CleanupAttributes(XmlSchemaObjectCollection attributes)
XmlSchemaParticle CannonicalizeElement(XmlSchemaElement element, bool substitution)
void CompileSimpleContentExtension(XmlSchemaComplexType complexType, XmlSchemaSimpleContentExtension simpleExtension)
void CalculateSequenceRange(XmlSchemaSequence sequence, out decimal minOccurs, out decimal maxOccurs)
void CompileComplexContentExtension(XmlSchemaComplexType complexType, XmlSchemaComplexContent complexContent, XmlSchemaComplexContentExtension complexExtension)
void CompileCompexTypeElements(XmlSchemaComplexType complexType)
void BuildParticleContentModel(ParticleContentValidator contentValidator, XmlSchemaParticle particle)
XmlSchemaSimpleType[] CompileBaseMemberTypes(XmlSchemaSimpleType simpleType)
XmlSchemaParticle CannonicalizeAll(XmlSchemaAll all, bool root, bool substitution)
static void CleanupElement(XmlSchemaElement element)
bool IsParticleEmptiable(XmlSchemaParticle particle)
bool Execute(XmlSchema schema, SchemaInfo schemaInfo, bool compileContentModel)
XmlSchemaType GetAnySchemaType(XmlQualifiedName name)
void CompileSubstitutionGroup(XmlSchemaSubstitutionGroupV1Compat substitutionGroup)
static void CleanupSimpleType(XmlSchemaSimpleType simpleType)
XmlSchemaParticle CompileContentTypeParticle(XmlSchemaParticle particle, bool substitution)
XmlSchemaAnyAttribute CompileAnyAttributeUnion(XmlSchemaAnyAttribute a, XmlSchemaAnyAttribute b)
XmlSchemaParticle CannonicalizeGroupRef(XmlSchemaGroupRef groupRef, bool root, bool substitution)
bool IsElementFromAny(XmlSchemaElement derivedElement, XmlSchemaAny baseAny)
void CompileParticleElements(XmlSchemaComplexType complexType, XmlSchemaParticle particle)
bool IsValidOccurrenceRangeRestriction(XmlSchemaParticle derivedParticle, XmlSchemaParticle baseParticle)
void CheckParticleDerivation(XmlSchemaComplexType complexType)
XmlSchemaParticle CannonicalizeChoice(XmlSchemaChoice choice, bool root, bool substitution)
void CompileIdentityConstraint(XmlSchemaIdentityConstraint xi)
bool IsGroupBaseFromGroupBase(XmlSchemaGroupBase derivedGroupBase, XmlSchemaGroupBase baseGroupBase, bool skipEmptableOnly)
XmlSchemaParticle CannonicalizeSequence(XmlSchemaSequence sequence, bool root, bool substitution)
void CompileComplexType(XmlSchemaComplexType complexType)
void CompileSimpleType(XmlSchemaSimpleType simpleType)
XmlSchemaContentType GetSchemaContentType(XmlSchemaComplexType complexType, XmlSchemaComplexContent complexContent, XmlSchemaParticle particle)
bool IsElementFromElement(XmlSchemaElement derivedElement, XmlSchemaElement baseElement)
XmlSchemaAnyAttribute CompileAnyAttributeIntersection(XmlSchemaAnyAttribute a, XmlSchemaAnyAttribute b)
static void CleanupParticle(XmlSchemaParticle particle)
static void CleanupAttributeGroup(XmlSchemaAttributeGroup attributeGroup)
static readonly SchemaElementDecl Empty
static bool IsSubset(XmlSchemaAnyAttribute sub, XmlSchemaAnyAttribute super)
static XmlSchemaAnyAttribute Intersection(XmlSchemaAnyAttribute o1, XmlSchemaAnyAttribute o2, bool v1Compat)
static XmlSchemaAnyAttribute Union(XmlSchemaAnyAttribute o1, XmlSchemaAnyAttribute o2, bool v1Compat)
XmlSchemaDatatype DeriveByList(XmlSchemaType schemaType)
static XmlSchemaDatatype DeriveByUnion(XmlSchemaSimpleType[] types, XmlSchemaType schemaType)
XmlSchemaObjectCollection Constraints
XmlSchemaDerivationMethod BlockResolved
void Insert(XmlQualifiedName name, XmlSchemaObject value)
void Add(XmlQualifiedName name, XmlSchemaObject value)
static readonly XmlSchemaParticle Empty
static bool IsDerivedFrom([NotNullWhen(true)] XmlSchemaType? derivedType, [NotNullWhen(true)] XmlSchemaType? baseType, XmlSchemaDerivationMethod except)
static bool IsDerivedFromDatatype(XmlSchemaDatatype derivedDataType, XmlSchemaDatatype baseDataType, XmlSchemaDerivationMethod except)
XmlSchemaObjectTable SchemaTypes
Definition XmlSchema.cs:256
XmlSchemaObjectTable AttributeGroups
Definition XmlSchema.cs:243
XmlSchemaObjectTable Groups
Definition XmlSchema.cs:307
XmlSchemaObjectTable Notations
Definition XmlSchema.cs:310
XmlSchemaObjectTable IdentityConstraints
Definition XmlSchema.cs:313
XmlSchemaObjectTable Attributes
Definition XmlSchema.cs:230
XmlSchemaObjectTable Elements
Definition XmlSchema.cs:269
static readonly XmlQualifiedName Empty