Lada, thanks for the feedback.

Any specific reason why you say that this would be more efficient when used
in the context of the parent container and not in the grouping?

Regards, Bart

-----Original Message-----
From: Ladislav Lhotka [mailto:[email protected]] 
Sent: 29 March 2017 14:37
To: Bogaert, Bart (Nokia - BE/Antwerp) <[email protected]>; Bogaert,
Bart (Nokia - BE/Antwerp) <[email protected]>; [email protected]
Subject: Re: [netmod] Question about must statement in grouping

"Bogaert, Bart (Nokia - BE/Antwerp)" <[email protected]> writes:

> Changing "count(.) != 1" into "count(../a-list) != 1" in the grouping 
> does the job as expected.  So it seems that count(.) within the 
> context of the a-list applies to each element in the list and rather 
> than to the list itself?

Both versions of the XPath expression are evaluated once for each entry of
the list, and the entry's 'a-list' node is the context node. By definition,
'.'  selects the context node, so 'count(.)' is always 1. After the change,
'..' selects the parent node and 'a-list' then selects all nodes of that
name, which are the entries of the list.

Note that it would be more efficient to verify the constraint on the parent
container, with 'count(a-list) != 1'.

Lada

>
>  
>
> Regards, Bart
>
>  
>
> From: netmod [mailto:[email protected]] On Behalf Of Bogaert, 
> Bart (Nokia - BE/Antwerp)
> Sent: 29 March 2017 12:47
> To: [email protected]
> Subject: [netmod] Question about must statement in grouping
>
>  
>
> Hi,
>
>  
>
> We have a question on the usage of a must statement within a grouping.
>
>  
>
> Assume the following grouping
>
>  
>
> grouping a-group {
>
>   list a-list {
>
>     must "count(.) != 1" {
>
>       description
>
>         "This list must either be empty or have at least 2 elements";
>
>     }
>
>     key "entry";
>
>     leaf entry {
>
>       type uint16;
>
>     }
>
>     leaf another-entry {
>
>       type uint32;
>
>     }
>
>   }
>
> }
>
>  
>
> And used in another module
>
>  
>
> container a-container {
>
>   uses a-group;
>
> }
>
>  
>
> The uses actually results in a data-tree like below
>
>  
>
>   +--rw a-container
>
>       +--rw a-list* [entry]
>
>            +--rw entry           uint16
>
>            +--rw another-entry   uint32
>
>  
>
> Does the usage of the grouping usage also result in the expected 
> behavior for the must statement when configuring /a-container/a-list?  
> The '.' in the must statement in the grouping refers to 'a-list' so 
> will that return 2 in case we have configured 2 elements in 
> /a-container/a-list or should we write the must statement at the level 
> of 'a-container' stating that "count(a-list) != 1" (as below)?
>
>  
>
> grouping a-group {
>
>   list a-list {
>
>     key "entry";
>
>     leaf entry {
>
>       type uint16;
>
>     }
>
>   }
>
> }
>
>  
>
> And used in another module
>
>  
>
> container a-container {
>
>   uses a-group;
>
>   must "count(a-list) != 1" {
>
>     description
>
>       "This list must either be empty or have at least 2 elements";
>
>   }
>
> }
>
>  
>
> Best regards - Vriendelijke groeten,
>
> Bart Bogaert
>
> _______________________________________________
> netmod mailing list
> [email protected]
> https://www.ietf.org/mailman/listinfo/netmod

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

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
netmod mailing list
[email protected]
https://www.ietf.org/mailman/listinfo/netmod

Reply via email to