Populate data/ hierarchy
[yangtools.git] / data / yang-data-impl / src / test / resources / leafref-validation / leafref-validation.yang
1 module leafref-validation {
2     namespace "leafref.validation";
3     prefix val;
4
5     leaf l1 {
6         type leafref {
7             path "../l2";
8         }
9     }
10
11     leaf l2 {
12         type string;
13     }
14
15     container odl-contributor {
16         list contributor {
17             key "login";
18             leaf login {
19                 type string;
20             }
21             leaf contributor-name {
22                 type string;
23             }
24             leaf odl-group-id {
25                 type string;
26             }
27             leaf odl-project-name {
28                 type leafref {
29                     path "../../../odl-project/project/name";
30                 }
31             }
32             leaf odl-project-desc {
33                 type leafref {
34                     path "/odl-project/project[name = current()/../odl-project-name]/desc";
35                 }
36                 // type string;                                    
37             }
38         }
39         list noleafref-contributor {
40             leaf foo {
41                 type string;
42             }
43         }
44     }
45
46     container odl-project {
47         list project {
48             key "name";
49             leaf name {
50                 type string;
51             }
52             leaf desc {
53                 type string;
54             }
55             leaf project-lead {
56                 type leafref {
57                     path "../../../odl-contributor/contributor/login";
58                 }
59             }
60             leaf project-owner {
61                 type leafref {
62                     path "/odl-contributor/contributor/login";
63                 }
64             }
65         }
66
67         choice ch1 {
68             case c1 {
69                 choice ch2 {
70                     case c1 {
71                         list list-in-choice {
72                             key "list-in-choice-key";
73                             leaf list-in-choice-key {
74                                 type string;
75                             }
76                             leaf leafref-in-choice {
77                                 type leafref {
78                                     path "../../con1/l1";
79                                 }
80                             }
81                             leaf leafref-in-choice-to-choice {
82                                 type leafref {
83                                     path "../../con3/list3-in-choice/l3";
84                                 }
85                             }
86                         }
87                     }
88                     case c2 {
89                     }
90                 }
91             }
92             case c2 {
93             }
94         }
95
96         list noleafref-project {
97             leaf foo {
98                 type string;
99             }
100         }
101         container con1 {
102             leaf l1 {
103                 type string;
104             }
105         }
106
107         container con3 {
108             choice choice-in-con3 {
109                 case one {
110                     list list3-in-choice {
111                         key "k";
112                         leaf k {
113                             type string;
114                         }
115                         leaf-list l3 {
116                             type string;
117                         }
118                     }
119                 }
120                 case two {
121                     list list3-in-choice-2 {
122                         key "l3-2";
123                         leaf l3-2 {
124                             type string;
125                         }
126                     }
127                 }
128             }
129         }
130
131         leaf-list leafref-leaf-list {
132             type leafref {
133                 path "../con3/list3-in-choice/k";
134             }
135         }
136     }
137
138     container no-leafrefcontainer {
139         list no-leafreflist {
140             leaf bar {
141                 type string;
142             }
143         }
144         container no-leafrefcontainer2 {
145             leaf baz {
146                 type string;
147             }
148         }
149     }
150 }