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

ValidateSingleElement() private méthode

private ValidateSingleElement ( XmlElement elementNode, bool skipToEnd, XmlSchemaInfo newSchemaInfo ) : void
elementNode XmlElement
skipToEnd bool
newSchemaInfo System.Xml.Schema.XmlSchemaInfo
Résultat void
        private void ValidateSingleElement(XmlElement elementNode, bool skipToEnd, XmlSchemaInfo newSchemaInfo)
        {
            _nsManager.PushScope();
            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, newSchemaInfo, xsiType, xsiNil, null, null);
            //Validate end of element
            if (skipToEnd)
            {
                _validator.ValidateEndOfAttributes(newSchemaInfo);
                _validator.SkipToEndElement(newSchemaInfo);
                _nsManager.PopScope(); //Pop current namespace scope
            }
        }