Leafref to a grouping

Hi,

In a submodule i want to be able to create a leafref from one grouping to
the other. I tried the following but it gave errors which are not meaningful.
Is this even allowed to do that or is there a better approach, please suggest.

submodule foo {
    belongs-to bar {
        prefix "bar";
    }

    grouping g-one {
        list l-one {
            leaf f-one {
            }
        }
    }

    grouping show {
        tailf:cli-show-template "test";

        list detail {
            leaf l-two {
                type leafref {
                    path "/foo/g-one/f-one/";
                }
            }
        }
    }
}

groupings are just structured types.
You can’t leafref a type. You will need a leaf node to leafref.

Thanks Nabil. I’ve created a typedef for the leaf present in grouping. I still get errors elsewhere
for the file. can a submodule (foo) be referred like this ?

-> path “/foo/g-one/f-one”;

submodule foo {
    belongs-to bar {
        prefix "bar";
    }   

    grouping g-one {
        list l-one {
            leaf f-one {
            }   
        }   
    }   

    typedef g-one-leaf {
        type leafref {
            path "/foo/g-one/f-one";
        }   
    }   

    grouping show {
        tailf:cli-show-template "test";

        list detail {
            leaf l-two {
                type g-one-leaf;
            }   
        }   
    }   
}

Yes, you have to use path in leafref that is part of the data model. The grouping itself is not part of the data model (e.g. you cannot configure values) until you use (instantiate) it with uses (e.g. uses g-one).

Grouping name cannot be part of the path. Grouping can be seen as if the content of the grouping is pasted
to the place where uses <grouping name> is used. Grouping name is not part of data model hierarchy.

Regarding module and submodule statements, they are just YANG identifiers. They are not used in the node hierarchy that you refer to from your absolute or relative path statement.

https://tools.ietf.org/html/rfc7950#section-9.9.2
https://tools.ietf.org/html/rfc7950#section-14