Re: [yang-doctors] YANG must statement constraints

Ladislav Lhotka <ladislav.lhotka@nic.cz> Mon, 22 March 2021 16:44 UTC

Return-Path: <ladislav.lhotka@nic.cz>
X-Original-To: yang-doctors@ietfa.amsl.com
Delivered-To: yang-doctors@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id DF6E73A0CC4 for <yang-doctors@ietfa.amsl.com>; Mon, 22 Mar 2021 09:44:16 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: 0
X-Spam-Level:
X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[NICE_REPLY_A=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hGvVImCOnWmS for <yang-doctors@ietfa.amsl.com>; Mon, 22 Mar 2021 09:44:12 -0700 (PDT)
Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 58AB73A0CBE for <yang-doctors@ietf.org>; Mon, 22 Mar 2021 09:44:12 -0700 (PDT)
Received: from [IPv6:2a01:5e0:29:ffff:fc73:fa64:57e6:2115] (unknown [IPv6:2a01:5e0:29:ffff:fc73:fa64:57e6:2115]) by mail.nic.cz (Postfix) with ESMTPSA id 470671409CA; Mon, 22 Mar 2021 17:44:05 +0100 (CET)
To: "Acee Lindem (acee)" <acee@cisco.com>, YANG Doctors <yang-doctors@ietf.org>
References: <27FBDC6F-0D23-4D18-9764-42E4F1826952@cisco.com> <4c68b8ea-dad7-5097-7b31-09045463da5d@nic.cz> <0CAB260B-C636-440C-913C-234EECC3DA7D@cisco.com> <104c7fed-ff01-2e66-6da3-b56bbfc87176@nic.cz> <F5E3037B-55D8-480D-9B21-FEAA2E3CF9F0@cisco.com>
From: Ladislav Lhotka <ladislav.lhotka@nic.cz>
Organization: CZ.NIC
Message-ID: <5160b0a2-6c61-b2c1-1fff-9abc2530f03e@nic.cz>
Date: Mon, 22 Mar 2021 17:44:05 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1
MIME-Version: 1.0
In-Reply-To: <F5E3037B-55D8-480D-9B21-FEAA2E3CF9F0@cisco.com>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 8bit
X-Virus-Scanned: clamav-milter 0.102.2 at mail
X-Virus-Status: Clean
Archived-At: <https://mailarchive.ietf.org/arch/msg/yang-doctors/VGcczGNdhkW0seos8qLOq8xZzOo>
Subject: Re: [yang-doctors] YANG must statement constraints
X-BeenThere: yang-doctors@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Email list of the yang-doctors directorate <yang-doctors.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/yang-doctors>, <mailto:yang-doctors-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/yang-doctors/>
List-Post: <mailto:yang-doctors@ietf.org>
List-Help: <mailto:yang-doctors-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/yang-doctors>, <mailto:yang-doctors-request@ietf.org?subject=subscribe>
X-List-Received-Date: Mon, 22 Mar 2021 16:44:17 -0000

On 22. 03. 21 14:44, Acee Lindem (acee) wrote:
> Hi Lada, at 
> 
> One more thing to confirm (at least for now). A predicate for a list can reference non-key items in that list - right? For example:
> 
>        list foo {
>               key "key";
>               string key;
>               string non-key;
>        }
> 
> This is still valid - correct? 
> 
>     /some/xpath/foo[non-key="acee"]


Yes, no problem. Lada

> 
> 
> Thanks,
> Acee
> 
> 
> On 3/19/21, 11:40 AM, "Ladislav Lhotka" <ladislav.lhotka@nic.cz> wrote:
> 
>     On 19. 03. 21 16:17, Acee Lindem (acee) wrote:
>     > Hi Lada, 
>     > 
>     > I guess the corollary would be that: 
>     > 
>     >    must "list/non-key-leaf != 42";
>     > 
>     > Is satisfied if there is at least one list entry with a non-key-leaf other than 42.
> 
>     Yes.
> 
>     > 
>     > And,
>     > 
>     >      must not("list/non-key-leaf = 42)";
>     > 
>     > Requires all leaf entries to have non-key-leaf not equal to 42.
> 
>     Yes.
> 
>     > 
>     > What if non-key-leaf is optional and not specified? Would this be equivalent to "!= 42" in the constraint evaluation?
> 
>     This is another tricky point of XPath. Either of the conditions "= 42"
>     and "!= 42" is satisfied only if an instance exists and satisfies the
>     condition. In other words, if no instance exists, then neither of the
>     two conditions is true.
> 
>     Lada
> 
>     > 
>     > Thanks much, 
>     > Acee
>     > 
>     > On 3/19/21, 11:08 AM, "Ladislav Lhotka" <ladislav.lhotka@nic.cz> wrote:
>     > 
>     >     Hi Acee,
>     > 
>     >     On 19. 03. 21 15:25, Acee Lindem (acee) wrote:
>     >     > When the constraint references a non-key leaf in a list, do all members
>     >     > of the list have to satisfy the constraint or only one of the list entries?
>     > 
>     >     It depends on how the constraint is written.
>     > 
>     >     If you have e.g.
>     > 
>     >         must "list/non-key-leaf = 42";
>     > 
>     >     then it is sufficient that at least one instance on non-key-leaf exist
>     >     with that value. In contrast,
>     > 
>     >         must "not(list/non-key-leaf != 42)";
>     > 
>     >     requires all instances to have that value.
>     > 
>     >     Lada
>     > 
>     >     > 
>     >     >  
>     >     > 
>     >     > Thanks,
>     >     > Acee
>     >     > 
>     >     > 
>     >     > _______________________________________________
>     >     > yang-doctors mailing list
>     >     > yang-doctors@ietf.org
>     >     > https://www.ietf.org/mailman/listinfo/yang-doctors
>     >     > 
>     > 
>     >     -- 
>     >     Ladislav Lhotka
>     >     Head, CZ.NIC Labs
>     >     PGP Key ID: 0xB8F92B08A9F76C67
>     > 
> 
>     -- 
>     Ladislav Lhotka
>     Head, CZ.NIC Labs
>     PGP Key ID: 0xB8F92B08A9F76C67
> 

-- 
Ladislav Lhotka
Head, CZ.NIC Labs
PGP Key ID: 0xB8F92B08A9F76C67