private void PreprocessSimpleType(XmlSchemaSimpleType simpleType, bool local) {
if (local) {
if (simpleType.Name != null) {
SendValidationEvent(Res.Sch_ForbiddenAttribute, "name", simpleType);
}
}
else {
if (simpleType.Name != null) {
ValidateNameAttribute(simpleType);
simpleType.SetQualifiedName(new XmlQualifiedName(simpleType.Name, this.targetNamespace));
}
else {
SendValidationEvent(Res.Sch_MissRequiredAttribute, "name", simpleType);
}
if (simpleType.Final == XmlSchemaDerivationMethod.All) {
simpleType.SetFinalResolved(XmlSchemaDerivationMethod.All);
}
else if (simpleType.Final == XmlSchemaDerivationMethod.None) {
if (this.finalDefault == XmlSchemaDerivationMethod.All) {
simpleType.SetFinalResolved(XmlSchemaDerivationMethod.All);
}
else {
simpleType.SetFinalResolved(this.finalDefault & simpleTypeFinalAllowed);
}
}
else {
if ((simpleType.Final & ~simpleTypeFinalAllowed) != 0) {
SendValidationEvent(Res.Sch_InvalidSimpleTypeFinalValue, simpleType);
}
simpleType.SetFinalResolved(simpleType.Final & simpleTypeFinalAllowed);
}
}
if (simpleType.Content == null) {
SendValidationEvent(Res.Sch_NoSimpleTypeContent, simpleType);
}
else if (simpleType.Content is XmlSchemaSimpleTypeRestriction) {
XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction)simpleType.Content;
//SetParent
SetParent(restriction, simpleType);
foreach(XmlSchemaObject facetObj in restriction.Facets) {
SetParent(facetObj, restriction);
}
if (restriction.BaseType != null) {
if (!restriction.BaseTypeName.IsEmpty) {
SendValidationEvent(Res.Sch_SimpleTypeRestRefBase, restriction);
}
PreprocessSimpleType(restriction.BaseType, true);
}
else {
if (restriction.BaseTypeName.IsEmpty) {
SendValidationEvent(Res.Sch_SimpleTypeRestRefBaseNone, restriction);
}
else {
ValidateQNameAttribute(restriction, "base", restriction.BaseTypeName);
}
}
PreprocessAnnotation(restriction); //set parent of annotation child of simple type restriction
ValidateIdAttribute(restriction);
}
else if (simpleType.Content is XmlSchemaSimpleTypeList) {
XmlSchemaSimpleTypeList list = (XmlSchemaSimpleTypeList)simpleType.Content;
SetParent(list, simpleType);
if (list.ItemType != null) {
if (!list.ItemTypeName.IsEmpty) {
SendValidationEvent(Res.Sch_SimpleTypeListRefBase, list);
}
SetParent(list.ItemType, list);
PreprocessSimpleType(list.ItemType, true);
}
else {
if (list.ItemTypeName.IsEmpty) {
SendValidationEvent(Res.Sch_SimpleTypeListRefBaseNone, list);
}
else {
ValidateQNameAttribute(list, "itemType", list.ItemTypeName);
}
}
PreprocessAnnotation(list); //set parent of annotation child of simple type list
ValidateIdAttribute(list);
}
else { // union
XmlSchemaSimpleTypeUnion union1 = (XmlSchemaSimpleTypeUnion)simpleType.Content;
SetParent(union1, simpleType);
int baseTypeCount = union1.BaseTypes.Count;
if (union1.MemberTypes != null) {
baseTypeCount += union1.MemberTypes.Length;
foreach(XmlQualifiedName qname in union1.MemberTypes) {
ValidateQNameAttribute(union1, "memberTypes", qname);
}
}
if (baseTypeCount == 0) {
SendValidationEvent(Res.Sch_SimpleTypeUnionNoBase, union1);
}
foreach(XmlSchemaSimpleType type in union1.BaseTypes) {
SetParent(type, union1);
PreprocessSimpleType(type, true);
}
PreprocessAnnotation(union1); //set parent of annotation child of simple type union
ValidateIdAttribute(union1);
}
ValidateIdAttribute(simpleType);
}