private void ValidateStartElement() {
if (context.ElementDecl != null) {
Reader.SchemaTypeObject = context.ElementDecl.SchemaType;
if (Reader.IsEmptyElement && context.ElementDecl.DefaultValueTyped != null) {
Reader.TypedValueObject = context.ElementDecl.DefaultValueTyped;
context.IsNill = true; // reusing IsNill - what is this flag later used for??
}
if ( context.ElementDecl.HasRequiredAttribute ) {
attPresence.Clear();
}
}
if (Reader.MoveToFirstAttribute()) {
do {
try {
reader.SchemaTypeObject = null;
SchemaAttDef attnDef = context.ElementDecl.GetAttDef( new XmlQualifiedName( reader.LocalName, reader.Prefix) );
if (attnDef != null) {
if (context.ElementDecl != null && context.ElementDecl.HasRequiredAttribute) {
attPresence.Add(attnDef.Name, attnDef);
}
Reader.SchemaTypeObject = attnDef.SchemaType;
if (attnDef.Datatype != null && !reader.IsDefault) { //Since XmlTextReader adds default attributes, do not check again
// set typed value
CheckValue(Reader.Value, attnDef);
}
}
else {
SendValidationEvent(Res.Sch_UndeclaredAttribute, reader.Name);
}
}
catch (XmlSchemaException e) {
e.SetSource(Reader.BaseURI, PositionInfo.LineNumber, PositionInfo.LinePosition);
SendValidationEvent(e);
}
} while(Reader.MoveToNextAttribute());
Reader.MoveToElement();
}
}