# Must statement to make lists mutually exclusive in a contaniner

**URL:** <https://dmap-community.ductus.global/t/must-statement-to-make-lists-mutually-exclusive-in-a-contaniner/2041>\
**Category:** YANG\
**Created:** [August 24, 2018, 2:33pm UTC](https://dmap-community.ductus.global/t/must-statement-to-make-lists-mutually-exclusive-in-a-contaniner/2041 "2018-08-24T14:33:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shant](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@shant](https://dmap-community.ductus.global/u/shant)\
**Post date:** [August 24, 2018, 2:33pm UTC](https://dmap-community.ductus.global/t/must-statement-to-make-lists-mutually-exclusive-in-a-contaniner/2041/1 "2018-08-24T14:33:44Z")

</div>

i’m trying the following ‘must’ statement. I want to block configuring elements in both of the lists together.  
At a time either of the lists must be configured. I added a must statement as shown below, but it doesn’t  
work. Is the statement wrong?

container test {  
list one {  
key one\_leaf\_1;  
leaf one\_leaf\_1 {  
type string;  
}  
leaf one\_leaf\_2 {  
type string;  
}  
}

```
list two {
    key two_leaf_1;

    leaf two_leaf_1 {
        type string;
    }
    leaf two_leaf_2 {
        type string;
    }
}

must "('one/one_leaf_1' and 'two/two_leaf_1')" {
    error-message "cannot configure list one and two together";
}

```

}

---

<div class="post-metadata">

**Author:** ![bkannadassan](https://avatars.discourse-cdn.com/v4/letter/b/f6c823/32.png) [@bkannadassan](https://dmap-community.ductus.global/u/bkannadassan)\
**Post date:** [August 25, 2018, 12:57am UTC](https://dmap-community.ductus.global/t/must-statement-to-make-lists-mutually-exclusive-in-a-contaniner/2041/2 "2018-08-25T00:57:07Z")

</div>

Hi,

Why you need a must here ?. Can’t we do with choice ?. With choice case you are sure that only one would be configurable.

rgds  
Balaji Kamal Kannadassan

---

<div class="post-metadata">

**Author:** ![shant](https://avatars.discourse-cdn.com/v4/letter/s/a183cd/32.png) [@shant](https://dmap-community.ductus.global/u/shant)\
**Post date:** [August 25, 2018, 4:21am UTC](https://dmap-community.ductus.global/t/must-statement-to-make-lists-mutually-exclusive-in-a-contaniner/2041/3 "2018-08-25T04:21:06Z")

</div>

list\_one is already present and i’m adding list\_two now. For compatibility reasons i cannot change the container. nevertheless, is the must statement wrong?

---

<div class="post-metadata">

**Author:** ![cohult](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/cohult/32/221_2.png) [@cohult](https://dmap-community.ductus.global/u/cohult)\
**Post date:** [August 25, 2018, 8:31am UTC](https://dmap-community.ductus.global/t/must-statement-to-make-lists-mutually-exclusive-in-a-contaniner/2041/4 "2018-08-25T08:31:26Z")

</div>

Try something like:

```
$ confd_cli -u admin -C
# devtools true
# config
(config)# show full-configuration test
% No entries found.
(config)# xpath must "not(/test/one/one_leaf_1 and /test/two/two_leaf_1)"
true
(config)# test one hello
(config)# test two hello
(config)# top
(config)# xpath must "not(/test/one/one_leaf_1 and /test/two/two_leaf_1)"
false

```

So  
`must "not(one/one_leaf_1 and two/two_leaf_1)"`  
may be the statement you are looking for.

Or if you meant to not allow any list-entries in one list if there are list entries in the other you can use something like:  
`must "not(one and two)"`

You will also find that enabling the xpath trace log in confd.conf will be helpful to make sure your xpath expressions are performing well and are doing what you intend them to do:

```xml
    <xpathTraceLog>
      <enabled>true</enabled>
      <filename>./xpath.trace</filename>
    </xpathTraceLog>

```
