public static int ValidateAttributesResolved( XmlSchemaObjectTable attributesResolved, ValidationEventHandler h, XmlSchema schema, XmlSchemaObjectCollection attributes, XmlSchemaAnyAttribute anyAttribute, ref XmlSchemaAnyAttribute anyAttributeUse, XmlSchemaAttributeGroup redefined, bool skipEquivalent) { int errorCount = 0; if (anyAttribute != null && anyAttributeUse == null) { anyAttributeUse = anyAttribute; } ArrayList newAttrNames = new ArrayList(); foreach (XmlSchemaObject xsobj in attributes) { XmlSchemaAttributeGroupRef grpRef = xsobj as XmlSchemaAttributeGroupRef; if (grpRef != null) { // Resolve attributeGroup redefinition. XmlSchemaAttributeGroup grp = null; if (redefined != null && grpRef.RefName == redefined.QualifiedName) { grp = redefined; } else { grp = schema.FindAttributeGroup(grpRef.RefName); } // otherwise, it might be missing sub components. if (grp == null) { if (!schema.missedSubComponents) // && schema.Schemas [grpRef.RefName.Namespace] != null) { grpRef.error(h, "Referenced attribute group " + grpRef.RefName + " was not found in the corresponding schema."); } continue; } if (grp.AttributeGroupRecursionCheck) { grp.error(h, "Attribute group recursion was found: " + grpRef.RefName); continue; } try { grp.AttributeGroupRecursionCheck = true; errorCount += grp.Validate(h, schema); } finally { grp.AttributeGroupRecursionCheck = false; } if (grp.AnyAttributeUse != null) { if (anyAttribute == null) { anyAttributeUse = grp.AnyAttributeUse; } } foreach (DictionaryEntry entry in grp.AttributeUses) { XmlSchemaAttribute attr = (XmlSchemaAttribute)entry.Value; if (StrictMsCompliant && attr.Use == XmlSchemaUse.Prohibited) { continue; } if (attr.RefName != null && attr.RefName != XmlQualifiedName.Empty && (!skipEquivalent || !AreAttributesEqual(attr, attributesResolved [attr.RefName] as XmlSchemaAttribute))) { AddToTable(attributesResolved, attr, attr.RefName, h); } else if (!skipEquivalent || !AreAttributesEqual(attr, attributesResolved [attr.QualifiedName] as XmlSchemaAttribute)) { AddToTable(attributesResolved, attr, attr.QualifiedName, h); } } } else { XmlSchemaAttribute attr = xsobj as XmlSchemaAttribute; if (attr != null) { errorCount += attr.Validate(h, schema); if (newAttrNames.Contains(attr.QualifiedName)) { attr.error(h, String.Format("Duplicate attributes was found for '{0}'", attr.QualifiedName)); } newAttrNames.Add(attr.QualifiedName); if (StrictMsCompliant && attr.Use == XmlSchemaUse.Prohibited) { continue; } if (attr.RefName != null && attr.RefName != XmlQualifiedName.Empty && (!skipEquivalent || !AreAttributesEqual(attr, attributesResolved [attr.RefName] as XmlSchemaAttribute))) { AddToTable(attributesResolved, attr, attr.RefName, h); } else if (!skipEquivalent || !AreAttributesEqual(attr, attributesResolved [attr.QualifiedName] as XmlSchemaAttribute)) { AddToTable(attributesResolved, attr, attr.QualifiedName, h); } } else { if (anyAttribute != null) { anyAttributeUse = (XmlSchemaAnyAttribute)xsobj; anyAttribute.Validate(h, schema); } } } } return(errorCount); }
public static int ValidateAttributesResolved(XmlSchemaObjectTable attributesResolved, ValidationEventHandler h, XmlSchema schema, XmlSchemaObjectCollection attributes, XmlSchemaAnyAttribute anyAttribute, ref XmlSchemaAnyAttribute anyAttributeUse, XmlSchemaAttributeGroup redefined, bool skipEquivalent) { int num = 0; if (anyAttribute != null && anyAttributeUse == null) { anyAttributeUse = anyAttribute; } ArrayList arrayList = new ArrayList(); foreach (XmlSchemaObject xmlSchemaObject in attributes) { XmlSchemaAttributeGroupRef xmlSchemaAttributeGroupRef = xmlSchemaObject as XmlSchemaAttributeGroupRef; if (xmlSchemaAttributeGroupRef != null) { XmlSchemaAttributeGroup xmlSchemaAttributeGroup = null; if (redefined != null && xmlSchemaAttributeGroupRef.RefName == redefined.QualifiedName) { xmlSchemaAttributeGroup = redefined; } else { xmlSchemaAttributeGroup = schema.FindAttributeGroup(xmlSchemaAttributeGroupRef.RefName); } if (xmlSchemaAttributeGroup == null) { if (!schema.missedSubComponents) { xmlSchemaAttributeGroupRef.error(h, "Referenced attribute group " + xmlSchemaAttributeGroupRef.RefName + " was not found in the corresponding schema."); } } else if (xmlSchemaAttributeGroup.AttributeGroupRecursionCheck) { xmlSchemaAttributeGroup.error(h, "Attribute group recursion was found: " + xmlSchemaAttributeGroupRef.RefName); } else { try { xmlSchemaAttributeGroup.AttributeGroupRecursionCheck = true; num += xmlSchemaAttributeGroup.Validate(h, schema); } finally { xmlSchemaAttributeGroup.AttributeGroupRecursionCheck = false; } if (xmlSchemaAttributeGroup.AnyAttributeUse != null && anyAttribute == null) { anyAttributeUse = xmlSchemaAttributeGroup.AnyAttributeUse; } foreach (object obj in xmlSchemaAttributeGroup.AttributeUses) { XmlSchemaAttribute xmlSchemaAttribute = (XmlSchemaAttribute)((DictionaryEntry)obj).Value; if (!XmlSchemaUtil.StrictMsCompliant || xmlSchemaAttribute.Use != XmlSchemaUse.Prohibited) { if (xmlSchemaAttribute.RefName != null && xmlSchemaAttribute.RefName != XmlQualifiedName.Empty && (!skipEquivalent || !XmlSchemaUtil.AreAttributesEqual(xmlSchemaAttribute, attributesResolved[xmlSchemaAttribute.RefName] as XmlSchemaAttribute))) { XmlSchemaUtil.AddToTable(attributesResolved, xmlSchemaAttribute, xmlSchemaAttribute.RefName, h); } else if (!skipEquivalent || !XmlSchemaUtil.AreAttributesEqual(xmlSchemaAttribute, attributesResolved[xmlSchemaAttribute.QualifiedName] as XmlSchemaAttribute)) { XmlSchemaUtil.AddToTable(attributesResolved, xmlSchemaAttribute, xmlSchemaAttribute.QualifiedName, h); } } } } } else { XmlSchemaAttribute xmlSchemaAttribute2 = xmlSchemaObject as XmlSchemaAttribute; if (xmlSchemaAttribute2 != null) { num += xmlSchemaAttribute2.Validate(h, schema); if (arrayList.Contains(xmlSchemaAttribute2.QualifiedName)) { xmlSchemaAttribute2.error(h, string.Format("Duplicate attributes was found for '{0}'", xmlSchemaAttribute2.QualifiedName)); } arrayList.Add(xmlSchemaAttribute2.QualifiedName); if (!XmlSchemaUtil.StrictMsCompliant || xmlSchemaAttribute2.Use != XmlSchemaUse.Prohibited) { if (xmlSchemaAttribute2.RefName != null && xmlSchemaAttribute2.RefName != XmlQualifiedName.Empty && (!skipEquivalent || !XmlSchemaUtil.AreAttributesEqual(xmlSchemaAttribute2, attributesResolved[xmlSchemaAttribute2.RefName] as XmlSchemaAttribute))) { XmlSchemaUtil.AddToTable(attributesResolved, xmlSchemaAttribute2, xmlSchemaAttribute2.RefName, h); } else if (!skipEquivalent || !XmlSchemaUtil.AreAttributesEqual(xmlSchemaAttribute2, attributesResolved[xmlSchemaAttribute2.QualifiedName] as XmlSchemaAttribute)) { XmlSchemaUtil.AddToTable(attributesResolved, xmlSchemaAttribute2, xmlSchemaAttribute2.QualifiedName, h); } } } else if (anyAttribute == null) { anyAttributeUse = (XmlSchemaAnyAttribute)xmlSchemaObject; anyAttribute.Validate(h, schema); } } } return(num); }