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

ValidateElement() private méthode

private ValidateElement ( ) : void
Résultat void
        private void ValidateElement()
        {
            _nsManager.PushScope();
            XmlElement elementNode = _currentNode as XmlElement;
            Debug.Assert(elementNode != null);

            XmlAttributeCollection attributes = elementNode.Attributes;
            XmlAttribute attr = null;

            //Find Xsi attributes that need to be processed before validating the element
            string xsiNil = null;
            string xsiType = null;

            for (int i = 0; i < attributes.Count; i++)
            {
                attr = attributes[i];
                string objectNs = attr.NamespaceURI;
                string objectName = attr.LocalName;
                Debug.Assert(_nameTable.Get(attr.NamespaceURI) != null);
                Debug.Assert(_nameTable.Get(attr.LocalName) != null);

                if (Ref.Equal(objectNs, _nsXsi))
                {
                    if (Ref.Equal(objectName, _xsiType))
                    {
                        xsiType = attr.Value;
                    }
                    else if (Ref.Equal(objectName, _xsiNil))
                    {
                        xsiNil = attr.Value;
                    }
                }
                else if (Ref.Equal(objectNs, _nsXmlNs))
                {
                    _nsManager.AddNamespace(attr.Prefix.Length == 0 ? string.Empty : attr.LocalName, attr.Value);
                }
            }
            _validator.ValidateElement(elementNode.LocalName, elementNode.NamespaceURI, _schemaInfo, xsiType, xsiNil, null, null);
            ValidateAttributes(elementNode);
            _validator.ValidateEndOfAttributes(_schemaInfo);

            //If element has children, drill down
            for (XmlNode child = elementNode.FirstChild; child != null; child = child.NextSibling)
            {
                ValidateNode(child);
            }
            //Validate end of element
            _currentNode = elementNode; //Reset current Node for validation call back
            _validator.ValidateEndElement(_schemaInfo);
            //Get XmlName, as memberType / validity might be set now
            if (_psviAugmentation)
            {
                elementNode.XmlName = _document.AddXmlName(elementNode.Prefix, elementNode.LocalName, elementNode.NamespaceURI, _schemaInfo);
                if (_schemaInfo.IsDefault)
                { //the element has a default value
                    XmlText textNode = _document.CreateTextNode(_schemaInfo.SchemaElement.ElementDecl.DefaultValueRaw);
                    elementNode.AppendChild(textNode);
                }
            }

            _nsManager.PopScope(); //Pop current namespace scope
        }