System.Xml.DocumentSchemaValidator.ValidateAttributes C# (CSharp) Méthode

ValidateAttributes() private méthode

private ValidateAttributes ( XmlElement elementNode ) : void
elementNode XmlElement
Résultat void
        private void ValidateAttributes(XmlElement elementNode)
        {
            XmlAttributeCollection attributes = elementNode.Attributes;
            XmlAttribute attr = null;

            for (int i = 0; i < attributes.Count; i++)
            {
                attr = attributes[i];
                _currentNode = attr; //For nodeValueGetter to pick up the right attribute value
                if (Ref.Equal(attr.NamespaceURI, _nsXmlNs))
                { //Do not validate namespace decls
                    continue;
                }
                _validator.ValidateAttribute(attr.LocalName, attr.NamespaceURI, _nodeValueGetter, _attributeSchemaInfo);
                if (_psviAugmentation)
                {
                    attr.XmlName = _document.AddAttrXmlName(attr.Prefix, attr.LocalName, attr.NamespaceURI, _attributeSchemaInfo);
                }
            }

            if (_psviAugmentation)
            {
                //Add default attributes to the attributes collection
                if (_defaultAttributes == null)
                {
                    _defaultAttributes = new ArrayList();
                }
                else
                {
                    _defaultAttributes.Clear();
                }
                _validator.GetUnspecifiedDefaultAttributes(_defaultAttributes);
                XmlSchemaAttribute schemaAttribute = null;
                XmlQualifiedName attrQName;
                attr = null;
                for (int i = 0; i < _defaultAttributes.Count; i++)
                {
                    schemaAttribute = _defaultAttributes[i] as XmlSchemaAttribute;
                    attrQName = schemaAttribute.QualifiedName;
                    Debug.Assert(schemaAttribute != null);
                    attr = _document.CreateDefaultAttribute(GetDefaultPrefix(attrQName.Namespace), attrQName.Name, attrQName.Namespace);
                    SetDefaultAttributeSchemaInfo(schemaAttribute);
                    attr.XmlName = _document.AddAttrXmlName(attr.Prefix, attr.LocalName, attr.NamespaceURI, _attributeSchemaInfo);
                    attr.AppendChild(_document.CreateTextNode(schemaAttribute.AttDef.DefaultValueRaw));
                    attributes.Append(attr);
                    XmlUnspecifiedAttribute defAttr = attr as XmlUnspecifiedAttribute;
                    if (defAttr != null)
                    {
                        defAttr.SetSpecified(false);
                    }
                }
            }
        }