System.Xml.Schema.XsdValidator.ValidateStartElement C# (CSharp) Méthode

ValidateStartElement() private méthode

private ValidateStartElement ( ) : void
Résultat void
        private void ValidateStartElement() {
            if (context.ElementDecl != null) {
                if (context.ElementDecl.IsAbstract) {
                    SendValidationEvent(Res.Sch_AbstractElement, XmlSchemaValidator.QNameString(context.LocalName, context.Namespace));
                }
                
                reader.SchemaTypeObject =  context.ElementDecl.SchemaType;

                if (reader.IsEmptyElement && !context.IsNill && context.ElementDecl.DefaultValueTyped != null) {
                    reader.TypedValueObject = UnWrapUnion(context.ElementDecl.DefaultValueTyped);
                    context.IsNill = true; // reusing IsNill
                }
                else {
                    reader.TypedValueObject = null; //Typed value cleanup 
                }
                if (this.context.ElementDecl.HasRequiredAttribute || HasIdentityConstraints) {
                    attPresence.Clear();
                }
            }

            if (reader.MoveToFirstAttribute()) {
                do {
                    if ((object)reader.NamespaceURI == (object)NsXmlNs) {
                        continue;
                    }
                    if ((object)reader.NamespaceURI == (object)NsXsi) {
                        continue;
                    }

                    try {
                        reader.SchemaTypeObject = null;
                        XmlQualifiedName attQName = new XmlQualifiedName(reader.LocalName, reader.NamespaceURI);
                        bool skipContents = (processContents == XmlSchemaContentProcessing.Skip);
                        SchemaAttDef attnDef = schemaInfo.GetAttributeXsd(context.ElementDecl, attQName, ref skipContents);

                        if (attnDef != null) {
                            if (context.ElementDecl != null && (context.ElementDecl.HasRequiredAttribute || this.startIDConstraint != -1)) {
                                attPresence.Add(attnDef.Name, attnDef);
                            }
                            Debug.Assert(attnDef.SchemaType != null);
                            reader.SchemaTypeObject = attnDef.SchemaType;
                            if (attnDef.Datatype != null) {

                                // need to check the contents of this attribute to make sure
                                // it is valid according to the specified attribute type.
                                CheckValue(reader.Value, attnDef);
                            }
                            if (HasIdentityConstraints) {
                                AttributeIdentityConstraints(reader.LocalName, reader.NamespaceURI, reader.TypedValueObject, reader.Value, attnDef);
                            }
                        }
                        else if (!skipContents) {
                            if (context.ElementDecl == null 
                                && processContents == XmlSchemaContentProcessing.Strict 
                                && attQName.Namespace.Length != 0
                                && schemaInfo.Contains(attQName.Namespace) 
                                ) {
                                SendValidationEvent(Res.Sch_UndeclaredAttribute, attQName.ToString());
                            }
                            else {
                                SendValidationEvent(Res.Sch_NoAttributeSchemaFound, attQName.ToString(), XmlSeverityType.Warning);
                            }
                        }
                    }
                    catch (XmlSchemaException e) {
                        e.SetSource(reader.BaseURI, PositionInfo.LineNumber, PositionInfo.LinePosition);
                        SendValidationEvent(e);
                    }
                } while(reader.MoveToNextAttribute());
                reader.MoveToElement();
            }
        }