Correct deref() leafref handling
[yangtools.git] / yang / yang-model-util-ut / src / test / resources / leafrefs.yang
1 module leafrefs {
2   yang-version 1.1;
3   namespace "leafrefs";
4   prefix "lrs";
5
6   typedef str-type {
7     type string {
8       length 1..max;
9     }
10   }
11
12   typedef int-type {
13     type int8 {
14       range min..0;
15     }
16   }
17
18   grouping grp {
19     leaf outer-id {
20       type leafref {
21         // points outside of the grouping
22         path ../../id;
23       }
24     }
25
26     leaf outer-indirect-prop {
27       type leafref {
28         path deref(../outer-id)/../prop;
29       }
30     }
31
32     leaf absolute {
33       type leafref {
34         // direct path to an instantiation
35         path /foo/id;
36       }
37     }
38
39     leaf indirect {
40       type leafref {
41         // deref through absolute to prop
42         path deref(../absolute)/../prop;
43       }
44     }
45
46     leaf non-existent-abs {
47       type leafref {
48         path /xyzzy;
49       }
50     }
51
52     leaf non-existent-rel {
53       type leafref {
54         path ../xyzzy;
55       }
56     }
57
58     leaf deref-non-existent {
59       type leafref {
60         path deref(../non-existent-rel)/../absolute;
61       }
62     }
63
64     leaf non-existent-deref {
65       type leafref {
66         path deref(../absolute)/../xyzzy;
67       }
68     }
69   }
70
71   list foo {
72     key id;
73
74     leaf id {
75       type str-type;
76     }
77
78     leaf id-copy {
79       type leafref {
80         path ../id;
81       }
82     }
83
84     leaf prop {
85       type int-type;
86     }
87
88     container bar {
89       uses grp;
90     }
91   }
92 }
93