Fold yang-model-util-ut
[yangtools.git] / yang / yang-model-util / 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 indirect-with-current {
33       type leafref {
34         path "../../../n[n-id=current()/../node]/tp/tp-id";
35       }
36     }
37
38     leaf absolute {
39       type leafref {
40         // direct path to an instantiation
41         path /foo/id;
42       }
43     }
44
45     leaf indirect {
46       type leafref {
47         // deref through absolute to prop
48         path deref(../absolute)/../prop;
49       }
50     }
51
52     leaf non-existent-abs {
53       type leafref {
54         path /xyzzy;
55       }
56     }
57
58     leaf non-existent-rel {
59       type leafref {
60         path ../xyzzy;
61       }
62     }
63
64     leaf deref-non-existent {
65       type leafref {
66         path deref(../non-existent-rel)/../absolute;
67       }
68     }
69
70     leaf non-existent-deref {
71       type leafref {
72         path deref(../absolute)/../xyzzy;
73       }
74     }
75   }
76
77   list foo {
78     key id;
79
80     leaf id {
81       type str-type;
82     }
83
84     leaf id-copy {
85       type leafref {
86         path ../id;
87       }
88     }
89
90     leaf prop {
91       type int-type;
92     }
93
94     container bar {
95       uses grp;
96     }
97   }
98 }
99