Re: [netmod] YANG 'must' Xpaths, predicates and wildcards
Martin Bjorklund <mbj@tail-f.com> Wed, 28 March 2018 06:26 UTC
Return-Path: <mbj@tail-f.com>
X-Original-To: netmod@ietfa.amsl.com
Delivered-To: netmod@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 4D52B126DC2 for <netmod@ietfa.amsl.com>; Tue, 27 Mar 2018 23:26:28 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.911
X-Spam-Level:
X-Spam-Status: No, score=-1.911 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] 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 wjrP9AF6U64F for <netmod@ietfa.amsl.com>; Tue, 27 Mar 2018 23:26:26 -0700 (PDT)
Received: from mail.tail-f.com (mail.tail-f.com [46.21.102.45]) by ietfa.amsl.com (Postfix) with ESMTP id A77FE126D73 for <netmod@ietf.org>; Tue, 27 Mar 2018 23:26:26 -0700 (PDT)
Received: from localhost (h-80-27.A165.priv.bahnhof.se [212.85.80.27]) by mail.tail-f.com (Postfix) with ESMTPSA id 9C3151AE00A0; Wed, 28 Mar 2018 08:26:24 +0200 (CEST)
Date: Wed, 28 Mar 2018 08:26:24 +0200
Message-Id: <20180328.082624.24188104780598722.mbj@tail-f.com>
To: jason.sterne@nokia.com
Cc: netmod@ietf.org
From: Martin Bjorklund <mbj@tail-f.com>
In-Reply-To: <AM3PR07MB112461BED4C88FDC4343C4F39BA30@AM3PR07MB1124.eurprd07.prod.outlook.com>
References: <AM3PR07MB112461BED4C88FDC4343C4F39BA30@AM3PR07MB1124.eurprd07.prod.outlook.com>
X-Mailer: Mew version 6.7 on Emacs 24.5 / Mule 6.0 (HANACHIRUSATO)
Mime-Version: 1.0
Content-Type: Text/Plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/CcjTI7rR1BsnMsg58-GBOEJ0eaE>
Subject: Re: [netmod] YANG 'must' Xpaths, predicates and wildcards
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: NETMOD WG list <netmod.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/netmod>, <mailto:netmod-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/netmod/>
List-Post: <mailto:netmod@ietf.org>
List-Help: <mailto:netmod-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/netmod>, <mailto:netmod-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 28 Mar 2018 06:26:28 -0000
Hi, "Sterne, Jason (Nokia - CA/Ottawa)" <jason.sterne@nokia.com> wrote: > Hi all, > > I'm pretty sure that this xpath (e.g. in a must statement) isn't > correct: > > (A) ../container-a/list-b[name=*]/some-leaf > > and should just be this instead: > > (B) ../container-a/list-b/some-leaf Assuming all list entries has a 'name', yes, it is the same. > Or is the * an allowable wildcard for a key value in a predicate ? "*" is syntactically legal, but is not a wildcard on all values of the node; it is a wildcard for all nodes. So if all list entries has a name, A will evaluate to the same nodeset as B, since "name = *" is a node-set comparison, and the node "name" will be present in the node set from "*" (node set comparisons are not always intuitive; read the spec for all details ;-) > I also had a question about whether the following "must" correctly > checks that at least one entry exists in a-list. > > container c1 { > leaf foo { > must "a-list"; > type uint16; > } > list a-list { > key "entry"; > leaf entry { > type uint16; > } > leaf another-entry { > type uint32; > } > } > } > > I think I could also replace that must with the following: > must "count(a-list) > 1"; > but does must "a-list"; achieve the same thing ? Yes, but if the list is big, the simple "a-list" may be more efficient, since "count()" will actually count all instances (modulo existance of optimizations in the evaluator). /martin
- [netmod] YANG 'must' Xpaths, predicates and wildc… Sterne, Jason (Nokia - CA/Ottawa)
- Re: [netmod] YANG 'must' Xpaths, predicates and w… Alex Campbell
- Re: [netmod] YANG 'must' Xpaths, predicates and w… Martin Bjorklund
- Re: [netmod] YANG 'must' Xpaths, predicates and w… Martin Bjorklund
- Re: [netmod] YANG 'must' Xpaths, predicates and w… Sterne, Jason (Nokia - CA/Ottawa)
- Re: [netmod] YANG 'must' Xpaths, predicates and w… Sterne, Jason (Nokia - CA/Ottawa)
- Re: [netmod] YANG 'must' Xpaths, predicates and w… Ladislav Lhotka
- Re: [netmod] YANG 'must' Xpaths, predicates and w… Martin Bjorklund
- Re: [netmod] YANG 'must' Xpaths, predicates and w… Sterne, Jason (Nokia - CA/Ottawa)
- Re: [netmod] YANG 'must' Xpaths, predicates and w… Martin Bjorklund
- Re: [netmod] YANG 'must' Xpaths, predicates and w… Alex Campbell