ConfD User Community

Need something like a display-when for xpath that references current object


Continuing the discussion from Adding conditional parts of models using 'when' statements:

The tailf:display-when statement can be used for conditional display of an object, and it can reference an xpath that points to some other object, or the parent (or some other path relative to the current object).

We have a list of leaf nodes, in which one of the leaf nodes is called “elementType”, and it is an enum that can be (for example) FOO or BAR. The list has other leaf nodes as well. Some of these other leaf nodes should be displayed iff the elementType=FOO, and other leaf nodes should appear iff the elementType=BAR.

We are trying to use tailf:display-when to conditionally display these leaf nodes. However, we cannot reference the xpath of the elementType leaf node, since it is within the object itself. We can reference a parent of the list, but that doesn’t help us, since the elementType value may be different for each element of the list.

In short, how can we conditionally display leaf nodes in a list, if the display is dependent on the value of one of the other leaf nodes in the list? Is it even possible?
Thank you.


I have tried following (inside some list) and it seems to work:

list elements {
        key value;
        leaf value {
            type uint32;
        leaf element-type {
            type enumeration {
                enum FOO;
                enum BAR;
        leaf other {
            tailf:display-when "../element-type = \"FOO\"";  // display in CLI or WebUI only if element-type is FOO
            type string;

leaf other is only displayed when element-type is FOO.


Thank you. This solution appears to work for us.