private void PreprocessIdentityConstraint(XmlSchemaIdentityConstraint constraint) {
bool valid = true;
PreprocessAnnotation(constraint); //Set parent of annotation child of key/keyref/unique
if (constraint.Name != null) {
ValidateNameAttribute(constraint);
constraint.SetQualifiedName(new XmlQualifiedName(constraint.Name, this.targetNamespace));
}
else {
SendValidationEvent(Res.Sch_MissRequiredAttribute, "name", constraint);
valid = false;
}
if (this.schema.IdentityConstraints[constraint.QualifiedName] != null) {
SendValidationEvent(Res.Sch_DupIdentityConstraint, constraint.QualifiedName.ToString(), constraint);
valid = false;
}
else {
this.schema.IdentityConstraints.Add(constraint.QualifiedName, constraint);
}
if (constraint.Selector == null) {
SendValidationEvent(Res.Sch_IdConstraintNoSelector, constraint);
valid = false;
}
if (constraint.Fields.Count == 0) {
SendValidationEvent(Res.Sch_IdConstraintNoFields, constraint);
valid = false;
}
if (constraint is XmlSchemaKeyref) {
XmlSchemaKeyref keyref = (XmlSchemaKeyref)constraint;
if (keyref.Refer.IsEmpty) {
SendValidationEvent(Res.Sch_IdConstraintNoRefer, constraint);
valid = false;
}
else {
ValidateQNameAttribute(keyref, "refer", keyref.Refer);
}
}
if (valid) {
ValidateIdAttribute(constraint);
ValidateIdAttribute(constraint.Selector);
SetParent(constraint.Selector, constraint);
foreach (XmlSchemaXPath field in constraint.Fields) {
SetParent(field, constraint);
ValidateIdAttribute(field);
}
}
}