private void ProcessSubstitutionGroups() {
foreach (XmlSchemaElement element in this.elements.Values) {
if (!element.SubstitutionGroup.IsEmpty) {
XmlSchemaElement headElement = this.elements[element.SubstitutionGroup] as XmlSchemaElement;
if (headElement == null) {
SendValidationEvent(Res.Sch_NoExamplar, element);
continue;
}
//Check derivation of member's type against head's type
if (!XmlSchemaType.IsDerivedFrom(element.ElementSchemaType, headElement.ElementSchemaType, headElement.FinalResolved)) {
SendValidationEvent(Res.Sch_InvalidSubstitutionMember, (element.QualifiedName).ToString(), (headElement.QualifiedName).ToString(), element);
}
if ((headElement.BlockResolved & XmlSchemaDerivationMethod.Substitution) != 0) { //head element blocks substitution, dont build substGroup
continue;
}
//Create substitutionGroup
XmlSchemaSubstitutionGroup substitutionGroup = (XmlSchemaSubstitutionGroup)this.examplars[element.SubstitutionGroup];
if (substitutionGroup == null) {
substitutionGroup = new XmlSchemaSubstitutionGroup();
substitutionGroup.Examplar = element.SubstitutionGroup;
examplars.Add(element.SubstitutionGroup, substitutionGroup);
}
ArrayList members = substitutionGroup.Members;
if (!members.Contains(element)) { //Members might contain element if the same schema is included and imported through different paths. Imp, hence will be added to set directly
members.Add(element);
}
}
}
//Check the subst groups that we just built
foreach (XmlSchemaSubstitutionGroup substitutionGroup in examplars.Values) {
CompileSubstitutionGroup(substitutionGroup);
}
}
private void CompileSubstitutionGroup(XmlSchemaSubstitutionGroup substitutionGroup) {