Re: [netmod] false() vs 'false' in 'when' statements

"Ivory, William" <william.ivory@intl.att.com> Wed, 08 August 2018 07:27 UTC

Return-Path: <william.ivory@intl.att.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 71D3C130DCF for <netmod@ietfa.amsl.com>; Wed, 8 Aug 2018 00:27:37 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.6
X-Spam-Level:
X-Spam-Status: No, score=-2.6 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7] 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 b8qTFqNVCDoa for <netmod@ietfa.amsl.com>; Wed, 8 Aug 2018 00:27:35 -0700 (PDT)
Received: from mx0a-00191d01.pphosted.com (mx0b-00191d01.pphosted.com [67.231.157.136]) (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 5D1E8130E5C for <netmod@ietf.org>; Wed, 8 Aug 2018 00:27:35 -0700 (PDT)
Received: from pps.filterd (m0049462.ppops.net [127.0.0.1]) by m0049462.ppops.net-00191d01. (8.16.0.22/8.16.0.22) with SMTP id w787PSHn033329; Wed, 8 Aug 2018 03:27:34 -0400
Received: from alpi155.enaf.aldc.att.com (sbcsmtp7.sbc.com [144.160.229.24]) by m0049462.ppops.net-00191d01. with ESMTP id 2kqut3gadu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 08 Aug 2018 03:27:34 -0400
Received: from enaf.aldc.att.com (localhost [127.0.0.1]) by alpi155.enaf.aldc.att.com (8.14.5/8.14.5) with ESMTP id w787RXWx000410; Wed, 8 Aug 2018 03:27:33 -0400
Received: from zlp27130.vci.att.com (zlp27130.vci.att.com [135.66.87.38]) by alpi155.enaf.aldc.att.com (8.14.5/8.14.5) with ESMTP id w787RSJY000373; Wed, 8 Aug 2018 03:27:28 -0400
Received: from zlp27130.vci.att.com (zlp27130.vci.att.com [127.0.0.1]) by zlp27130.vci.att.com (Service) with ESMTP id 3C86440F6CE9; Wed, 8 Aug 2018 07:27:28 +0000 (GMT)
Received: from gbcdccas01.intl.att.com (unknown [135.76.180.9]) by zlp27130.vci.att.com (Service) with ESMTPS id E4D534000527; Wed, 8 Aug 2018 07:27:27 +0000 (GMT)
Received: from GBCDCMBX03.intl.att.com ([135.76.31.134]) by gbcdccas01.intl.att.com ([135.76.180.9]) with mapi id 14.03.0399.000; Wed, 8 Aug 2018 08:27:26 +0100
From: "Ivory, William" <william.ivory@intl.att.com>
To: "Sterne, Jason (Nokia - CA/Ottawa)" <jason.sterne@nokia.com>, "netmod@ietf.org" <netmod@ietf.org>
Thread-Topic: [netmod] false() vs 'false' in 'when' statements
Thread-Index: AdQudRPPuaY7IZR/R5mIg6eZugDJwA==
Date: Wed, 08 Aug 2018 07:27:25 +0000
Message-ID: <E3378E0605547F4E854DEE0CB1116AB03A8BA8@gbcdcmbx03.intl.att.com>
References: <VI1PR07MB3981A0DC1F7069AFC5BE72AD9B270@VI1PR07MB3981.eurprd07.prod.outlook.com>
Accept-Language: en-GB, en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-originating-ip: [135.76.180.249]
Content-Type: text/plain; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-08-08_02:, , signatures=0
X-Proofpoint-Spam-Details: rule=outbound_policy_notspam policy=outbound_policy score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808080078
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/J-D51ERBN83D4fGu_72j0PB_MsQ>
Subject: Re: [netmod] false() vs 'false' in 'when' statements
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.27
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, 08 Aug 2018 07:27:38 -0000

On 07/08/18 18:37, Sterne, Jason (Nokia - CA/Ottawa) wrote:
Hi all,

When comparing the value of a boolean leaf in a 'when' statement (or a 'must' statement), is an equality comparison to 'true' or 'false' the same as a check against true() or false() ?

For example:

leaf a {
    type boolean;
}
leaf b {
    type uint32;
    when ".../a = 'true'";
}
leaf c {
    type uint32;
    when ".../a = 'false'";
}
(note that neither b nor c can be configured if leaf a isn't explicitly configured with a value since there is no default)

If I replace the two 'when' statements above with the following instead, is the behavior the same ?
    …
    when ".../a = true()";
    …
    when ".../a = false()";
    …

Or does "../a = true()" behave as an existence check on leaf a and would be enabled whether a is configured as true or false ?

Regards,
Jason



See https://www.w3.org/TR/1999/REC-xpath-19991116/#booleans

(a) "../a = 'true'"

Compares 'string-value' (same as value of node if a leaf, rather more interesting if a list / container!) of each node in nodeset generated by '../a' and if any node in the nodeset matches 'true', expression is true.

(b) "../a = true()"

Similar to above but after getting the string-value, this is converted to a boolean before comparing with the boolean true.

(c) '../a'

True if the nodeset generated by this expression is not empty.

---

Caveats alluded to above are that if '../a' matches multiple nodes, then only one of these nodes needs to pass the test for the test to be true.  Separately, if any of the nodes are not leaves, the 'string-value' is a concatenated string of the values of the node's child / grandchild leaves.

Hope that helps.  You wouldn't believe the number of unit tests I have to make sure we get this logic right!  Using '!=' when comparing a nodeset with >1 node with other values is very likely not to give the answer you expect (-:

Regards,

William