private void CompileAttributeGroup(XmlSchemaAttributeGroup attributeGroup) {
if (attributeGroup.IsProcessing) {
SendValidationEvent(Res.Sch_AttributeGroupCircularRef, attributeGroup);
return;
}
if (attributeGroup.AttributeUses.Count > 0) {// already checked
return;
}
attributeGroup.IsProcessing = true;
XmlSchemaAnyAttribute anyAttribute = attributeGroup.AnyAttribute;
foreach (XmlSchemaObject obj in attributeGroup.Attributes) {
if (obj is XmlSchemaAttribute) {
XmlSchemaAttribute attribute = (XmlSchemaAttribute)obj;
if (attribute.Use != XmlSchemaUse.Prohibited) {
CompileAttribute(attribute);
}
if (attributeGroup.AttributeUses[attribute.QualifiedName] == null) {
attributeGroup.AttributeUses.Add(attribute.QualifiedName, attribute);
}
else {
SendValidationEvent(Res.Sch_DupAttributeUse, attribute.QualifiedName.ToString(), attribute);
}
}
else { // XmlSchemaAttributeGroupRef
XmlSchemaAttributeGroupRef attributeGroupRef = (XmlSchemaAttributeGroupRef)obj;
XmlSchemaAttributeGroup attributeGroupResolved;
if (attributeGroup.Redefined != null && attributeGroupRef.RefName == attributeGroup.Redefined.QualifiedName) {
attributeGroupResolved = (XmlSchemaAttributeGroup)attributeGroup.Redefined;
}
else {
attributeGroupResolved = (XmlSchemaAttributeGroup)this.schema.AttributeGroups[attributeGroupRef.RefName];
}
if (attributeGroupResolved != null) {
CompileAttributeGroup(attributeGroupResolved);
foreach (XmlSchemaAttribute attribute in attributeGroupResolved.AttributeUses.Values) {
if (attributeGroup.AttributeUses[attribute.QualifiedName] == null) {
attributeGroup.AttributeUses.Add(attribute.QualifiedName, attribute);
}
else {
SendValidationEvent(Res.Sch_DupAttributeUse, attribute.QualifiedName.ToString(), attribute);
}
}
anyAttribute = CompileAnyAttributeIntersection(anyAttribute, attributeGroupResolved.AttributeWildcard);
}
else {
SendValidationEvent(Res.Sch_UndefAttributeGroupRef, attributeGroupRef.RefName.ToString(), attributeGroupRef);
}
}
}
attributeGroup.AttributeWildcard = anyAttribute;
attributeGroup.IsProcessing = false;
}