Пример #1
0
        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);
        }