public static void CheckDefaultValue(
string value,
SchemaAttDef attdef,
SchemaInfo sinfo,
XmlNamespaceManager nsManager,
XmlNameTable NameTable,
object sender,
ValidationEventHandler eventhandler,
string baseUri,
int lineNo,
int linePos
) {
try {
XmlSchemaDatatype dtype = attdef.Datatype;
if (dtype == null) {
return; // no reason to check
}
if (dtype.TokenizedType != XmlTokenizedType.CDATA) {
value = value.Trim();
}
if (value.Length == 0) {
return; // don't need to check
}
object typedValue = dtype.ParseValue(value, NameTable, nsManager);
// Check special types
XmlTokenizedType ttype = dtype.TokenizedType;
if (ttype == XmlTokenizedType.ENTITY) {
if (dtype.Variety == XmlSchemaDatatypeVariety.List) {
string[] ss = (string[])typedValue;
foreach(string s in ss) {
ProcessEntity(sinfo, s, sender, eventhandler, baseUri, lineNo, linePos);
}
}
else {
ProcessEntity(sinfo, (string)typedValue, sender, eventhandler, baseUri, lineNo, linePos);
}
}
else if (ttype == XmlTokenizedType.ENUMERATION) {
if (!attdef.CheckEnumeration(typedValue)) {
XmlSchemaException e = new XmlSchemaException(Res.Sch_EnumerationValue, typedValue.ToString(), baseUri, lineNo, linePos);
if (eventhandler != null) {
eventhandler(sender, new ValidationEventArgs(e));
}
else {
throw e;
}
}
}
attdef.DefaultValueTyped = typedValue;
}
#if DEBUG
catch (XmlSchemaException ex) {
Debug.WriteLineIf(DiagnosticsSwitches.XmlSchema.TraceError, ex.Message);
#else
catch {
#endif
XmlSchemaException e = new XmlSchemaException(Res.Sch_AttributeDefaultDataType, attdef.Name.ToString(), baseUri, lineNo, linePos);
if (eventhandler != null) {
eventhandler(sender, new ValidationEventArgs(e));
}
else {
throw e;
}
}
}