public static bool ValidateAttribute( XmlSchemaAttribute attribute, string value, SchemaValidationResult errors )
{
bool isValid = true;
XmlSchemaSimpleType attributeSchemaType = attribute.AttributeSchemaType;
XmlSchemaUse use = attribute.Use;
string name = attribute.Name;
bool required = ( use == XmlSchemaUse.Required );
if (required && string.IsNullOrEmpty( value ))
{
isValid = false;
errors.AddError( string.Format( "{0} is required\n", name ) );
}
if (attributeSchemaType.Content is XmlSchemaSimpleTypeRestriction)
{
XmlQualifiedName qname = attributeSchemaType.BaseXmlSchemaType.QualifiedName;
String typeName = qname.Name;
var restriction = (XmlSchemaSimpleTypeRestriction) attributeSchemaType.Content;
isValid &= ProcessRestrictions( value, errors, restriction, typeName, name );
}
return isValid;
}