private void AddIdentityConstraints() {
context.Constr = new ConstraintStruct[context.ElementDecl.Constraints.Length];
int id = 0;
foreach (CompiledIdentityConstraint constraint in context.ElementDecl.Constraints) {
context.Constr[id++] = new ConstraintStruct (constraint);
} // foreach constraint /constraintstruct
// added on June 19, make connections between new keyref tables with key/unique tables in stack
// i can't put it in the above loop, coz there will be key on the same level
foreach (ConstraintStruct keyrefconstr in context.Constr) {
if ( keyrefconstr.constraint.Role == CompiledIdentityConstraint.ConstraintRole.Keyref ) {
bool find = false;
// go upwards checking or only in this level
for (int level = this.validationStack.Length - 1; level >= ((this.startIDConstraint >= 0) ? this.startIDConstraint : this.validationStack.Length - 1); level --) {
// no constraint for this level
if (((ValidationState)(this.validationStack[level])).Constr == null) {
continue;
}
// else
foreach (ConstraintStruct constr in ((ValidationState)(this.validationStack[level])).Constr) {
if (constr.constraint.name == keyrefconstr.constraint.refer) {
find = true;
if (constr.keyrefTable == null) {
constr.keyrefTable = new Hashtable();
}
keyrefconstr.qualifiedTable = constr.keyrefTable;
break;
}
}
if (find) {
break;
}
}
if (!find) {
// didn't find connections, throw exceptions
SendValidationEvent(Res.Sch_RefNotInScope, XmlSchemaValidator.QNameString(context.LocalName, context.Namespace));
}
} // finished dealing with keyref
} // end foreach
// initial set
if (this.startIDConstraint == -1) {
this.startIDConstraint = this.validationStack.Length - 1;
}
}