private void ValidateStartElement() {
if (context.ElementDecl != null) {
if (context.ElementDecl.SchemaType != null) {
reader.SchemaTypeObject = context.ElementDecl.SchemaType;
}
else {
reader.SchemaTypeObject = context.ElementDecl.Datatype;
}
if (reader.IsEmptyElement && !context.IsNill && context.ElementDecl.DefaultValueTyped != null) {
reader.TypedValueObject = context.ElementDecl.DefaultValueTyped;
context.IsNill = true; // reusing IsNill
}
if (this.context.ElementDecl.HasRequiredAttribute) {
attPresence.Clear();
}
}
if (reader.MoveToFirstAttribute()) {
do {
if ((object)reader.NamespaceURI == (object)SchemaNames.NsXmlNs) {
continue;
}
try {
reader.SchemaTypeObject = null;
SchemaAttDef attnDef = schemaInfo.GetAttributeXdr(context.ElementDecl, QualifiedName(reader.LocalName, reader.NamespaceURI));
if (attnDef != null) {
if (context.ElementDecl != null && context.ElementDecl.HasRequiredAttribute) {
attPresence.Add(attnDef.Name, attnDef);
}
reader.SchemaTypeObject = (attnDef.SchemaType != null) ? (object)attnDef.SchemaType : (object)attnDef.Datatype;
if (attnDef.Datatype != null) {
string attributeValue = reader.Value;
// need to check the contents of this attribute to make sure
// it is valid according to the specified attribute type.
CheckValue(attributeValue, attnDef);
}
}
}
catch (XmlSchemaException e) {
e.SetSource(reader.BaseURI, PositionInfo.LineNumber, PositionInfo.LinePosition);
SendValidationEvent(e);
}
} while(reader.MoveToNextAttribute());
reader.MoveToElement();
}
}