Annotate special case of choice

Hi,

I’m trying to annotate this “special” construct:

                container s-vlan {                    
                    choice mode {
                        leaf c-vlan {
                            type vlan-list;
                        }
                        case default-case {
                            leaf default {
                                type empty;
                            }
                        }
                    }
                }

`

    tailf:annotate "/avif:s-vlan/avif:mode/avif:c-vlan" {
        tailf:info "Set the C-VLANs to map to the S-VLAN";
    }

I get
error: The statement tailf-common:info cannot be annotated into a case.

I do not know why the source yang is using such logic for c-vlan leaf. Is it possible to annotate this thing? What is the outcome of such choice definition?

BRj

I made it work by using annotate-statement and a “position predicate”.
Is there a way with “tailf:annotate” ?

This is the “shorthand” usage for case that is described in RFC 7950 - The YANG 1.1 Data Modeling Language - if there is only a single node in the case, you don’t have to actually write the case statement. Effectively, the compiler or other tool synthesizes a case statement with the same name as the node. I.e. in this snippet, the leaf c-vlan is actually inside an “invisible” case c-vlan.

This is handy since “single node in a case” is quite common - the strange thing with the snippet is that it isn’t used consistently - they could have omitted the case default-case too (which would have resulted in the “shorthand” case being called default, maybe they didn’t “like” that…).

Yes, but you need to spell out the “invisible” case in the path: /avif:s-vlan/avif:mode/avif:c-vlan/avif:c-vlan.

See above.

1 Like

Using annotate-statement is fine, but there is no need for a “position predicate” as far as I can see - i.e. annotate-statement leaf[name='c-vlan'] should work. And this way you are saying that you want to annotate the leaf and not the “invisible” case.

It was under the augmentation statement. I ommited it for readability.