How ConfD would evaluate an XPath expression with absolute path traversing a list?

Hi All,

Considering a yang module defined as follow:

module module1
{
	container a {
		list b {
			key name;
			
			leaf name {
				type string;
			}
			
			leaf x {
				type uint32;
			}
			
			leaf y {
				type uint32;
			}
			
			container c {
				when "(/a/b/x = 0) and  (/a/b/y = 1)";
				leaf cx {
					type uint32;
					mandatory true;
				}
			}
		}
	}
}

Everytime a new element is inserted into the list /a/b, I’ve noticed that ConfD always evaluates the condition statement “when” by iterating over all the entries of the list /a/b (sorted in crescent order) trying to match first /a/b/x = 0 and then /a/b/y = 1. The values x and y of the entry being inserted are ignored.

Can you please confirm if this is a correct behavior? If yes, can you kindly point me to the right XPath documentation explaining how to proceed when evaluating an absolute XPath value?

If relative paths (../x = 0) and (../y = 1), the evaluation is done using the values (x and y) of the new entry. This behavior sounds ok to me.

I would just like to confirm my understanding or have clarification about the meaning of the when condition in my example or how ConfD would evaluate it.

Thanks for your help.

When using an absolute path, you don’t want the when XPath expression to iterate over the entire list b, and only the current list entry x and y values. So you want to use current() (See RFC 7950). Example:

when "(/a/b[name=current()/../name]/x = 0) and  (/a/b[name=current()/../name]/y = 1)";

Ok, now it is clear. Thank you!