A question about the "when" merge usage

Hi,
I hava a question about the “when” usage, using below example to show it.

  1. The yang file test1.yang, the name exists when the prefix=ABC
# cat test1.yang 
module test1{
  namespace "http://complex/test1";
  prefix "test1";

  container test1 {
    leaf name{
        type string;
        when "/test1:test2/test1:prefix='ABC'";
        }
  }

  container test2 {
    leaf prefix{
        type string;
        }
  }
}

2. The test1.xml can be written to the db successfully
# cat test1.xml
<test1 xmlns="http://complex/test1">
<name>abc</name>
</test1>
<test2 xmlns="http://complex/test1">
<prefix>ABC</prefix>
</test2>

# /root/confd1/bin/netconf-console --edit-config test1.xml --db running
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
  <ok/>
</rpc-reply>

# /root/confd1/bin/netconf-console --get-config
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
  <data>
    <test1 xmlns="http://complex/test1">
      <name>abc</name>
    </test1>
    <test2 xmlns="http://complex/test1">
      <prefix>ABC</prefix>
    </test2>
</data>
</rpc-reply>

3. The test2.xml which doesn't meet the when, but it is also written to the db successfully and the leaf name is removed??? Whether it is right and whether there is RFC describe the usage? I think the "when condition isn't met" error should be reported when writted test.xml.

# cat test2.xml
<test1 xmlns="http://complex/test1">
<name>abc</name>
</test1>
<test2 xmlns="http://complex/test1">
<prefix>BC</prefix>
</test2>

# /root/confd1/bin/netconf-console --edit-config test2.xml --db running
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
  <ok/>
</rpc-reply>

# /root/confd1/bin/netconf-console --get-config
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
  <data>
    <test2 xmlns="http://complex/test1">
      <prefix>BC</prefix>
    </test2>
  </data>
</rpc-reply>
> Blockquote

Whether it is right and whether there is RFC describe the usage?

As an edit-config is applied as one transaction (not per operation), a NETCONF server will process that transaction and after that processing, if any node’s “when” expression becomes false, then the node in the data tree with the “when” expression is deleted by the server.

“when” expression section:

You can read about deletion you observe here:

Read about the order things are done in section 8.3. “NETCONF Constraint Enforcement Model”:

Hi @cohult,
Thanks very much, I got it.