private void CompileSubstitutionGroup(XmlSchemaSubstitutionGroup substitutionGroup) {
if (substitutionGroup.IsProcessing) {
foreach (XmlSchemaElement element in substitutionGroup.Members) {
SendValidationEvent(Res.Sch_SubstitutionCircularRef, element);
return;
}
}
XmlSchemaElement examplar = (XmlSchemaElement)elements[substitutionGroup.Examplar];
Debug.Assert(examplar != null); //Headelement presence is checked while building subst groups
if (substitutionGroup.Members.Contains(examplar)) {// already checked
return;
}
substitutionGroup.IsProcessing = true;
try {
if (examplar.FinalResolved == XmlSchemaDerivationMethod.All) {
SendValidationEvent(Res.Sch_InvalidExamplar, examplar);
}
//Build transitive members
ArrayList newMembers = null;
foreach (XmlSchemaElement element in substitutionGroup.Members) {
//Chain to other head's that are members of this head's substGroup
XmlSchemaSubstitutionGroup g = (XmlSchemaSubstitutionGroup)examplars[element.QualifiedName];
if (g != null) {
CompileSubstitutionGroup(g);
foreach (XmlSchemaElement element1 in g.Members) {
if (element1 != element) { //Exclude the head
if (newMembers == null) {
newMembers = new ArrayList();
}
newMembers.Add(element1);
}
}
}
}
if (newMembers != null) {
foreach (XmlSchemaElement newMember in newMembers) {
substitutionGroup.Members.Add(newMember);
}
}
substitutionGroup.Members.Add(examplar); // Compiled mark
}
finally {
substitutionGroup.IsProcessing = false;
}
}