public SchemaAttDef GetAttributeXsd(SchemaElementDecl ed, XmlQualifiedName qname, XmlSchemaObject partialValidationType, out AttributeMatchState attributeMatchState) {
SchemaAttDef attdef = null;
attributeMatchState = AttributeMatchState.UndeclaredAttribute;
if (ed != null) {
attdef = ed.GetAttDef(qname);
if (attdef != null) {
attributeMatchState = AttributeMatchState.AttributeFound;
return attdef;
}
XmlSchemaAnyAttribute any = ed.AnyAttribute;
if (any != null) {
if (!any.NamespaceList.Allows(qname)) {
attributeMatchState = AttributeMatchState.ProhibitedAnyAttribute;
}
else if (any.ProcessContentsCorrect != XmlSchemaContentProcessing.Skip) {
attdef = (SchemaAttDef)attributeDecls[qname];
if (attdef != null) {
if (attdef.Datatype.TypeCode == XmlTypeCode.Id) { //anyAttribute match whose type is ID
attributeMatchState = AttributeMatchState.AnyIdAttributeFound;
}
else {
attributeMatchState = AttributeMatchState.AttributeFound;
}
}
else if (any.ProcessContentsCorrect == XmlSchemaContentProcessing.Lax) {
attributeMatchState = AttributeMatchState.AnyAttributeLax;
}
}
else {
attributeMatchState = AttributeMatchState.AnyAttributeSkip;
}
}
else if (ed.ProhibitedAttributes[qname] != null) {
attributeMatchState = AttributeMatchState.ProhibitedAttribute;
}
}
else if (partialValidationType != null) {
XmlSchemaAttribute attr = partialValidationType as XmlSchemaAttribute;
if (attr != null) {
if (qname.Equals(attr.QualifiedName)) {
attdef = attr.AttDef;
attributeMatchState = AttributeMatchState.AttributeFound;
}
else {
attributeMatchState = AttributeMatchState.AttributeNameMismatch;
}
}
else {
attributeMatchState = AttributeMatchState.ValidateAttributeInvalidCall;
}
}
else {
attdef = (SchemaAttDef)attributeDecls[qname];
if (attdef != null) {
attributeMatchState = AttributeMatchState.AttributeFound;
}
else {
attributeMatchState = AttributeMatchState.UndeclaredElementAndAttribute;
}
}
return attdef;
}