I have separate two lists A and B with key a1 and b1 respectively of type string. I want that a1 and b1 should not have anything in common means i should not be able to add a1 as xyz if in list B b1 has a key xyz or vice versa
How to add that
one easy approach can be using the must statement in the key elements of the lists.
Something like:
module test1 {
namespace "http://tail-f.com/ns/example/test1";
prefix test1;
list A {
key "a1";
leaf a1 {
must "not(../../B[b1=current()])" {
error-message "Same key already exists in list B!";
}
type string;
}
}
list B {
key "b1";
leaf b1 {
must "not(../../A[a1=current()])" {
error-message "Same key already exists in list A!";
}
type string;
}
}
}
This should prevent you from adding any specific key value to both of the lists…