Re: [netmod] evaluating 'when' statements with unconfigured leafs

Andy Bierman <andy@yumaworks.com> Wed, 25 September 2019 16:20 UTC

Return-Path: <andy@yumaworks.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 AC519120013 for <netmod@ietfa.amsl.com>; Wed, 25 Sep 2019 09:20:44 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.899
X-Spam-Level:
X-Spam-Status: No, score=-1.899 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=yumaworks-com.20150623.gappssmtp.com
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 Xoe11jI6eDgs for <netmod@ietfa.amsl.com>; Wed, 25 Sep 2019 09:20:42 -0700 (PDT)
Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 20DF2120824 for <netmod@ietf.org>; Wed, 25 Sep 2019 09:20:42 -0700 (PDT)
Received: by mail-io1-xd2a.google.com with SMTP id j4so192301iog.11 for <netmod@ietf.org>; Wed, 25 Sep 2019 09:20:42 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yumaworks-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=l0zi10mlUjm7gb12xDNsUyxofUNSpc8El/IB5DwWQX0=; b=jX6n2Muz3Hd/ak4Qn/+AtbOr3sYdSjOJKnh5J+iuVKfybxDq1He9ULS6/h5hVdO9u/ xpDIhUmUEkxFCxlqMkwkfnniG8ASceE8ZOB1Ku7mBS/AW4M6+VsD/PBP8ynAe4FTKnX8 A5MPvDreNPO2vIn5E4kn16Lcqht87PcrigBIJUf6+SOmCISXwLmYILqKUXHfPVdTAs8p ytZPCKxFqMiD2WR6TFS5ZdDBQO4S8/fpkpqUYsxWfr0osqZAzcKFnRs3PAYu8obWDdxX XyVHgCL07NJ8zh8hRuTjfU/eqY8xBdJC/c9z0H6665w6PkYRklUz5ZH744tJFdTD873x 7NjA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=l0zi10mlUjm7gb12xDNsUyxofUNSpc8El/IB5DwWQX0=; b=CzhjSLEcp4b9AUSPGjbf46+JeVR9jO5Tyx4/AbIZ74s/hTz9Ye+2OECtvjE+7wlUOq 031dTKxgHsHMUeavDJzu8/pmD7zfALXkTZPeH7aRnwMqY6ZhX44baE581KeiOuVRhdjK RPKe5siAw69LUgOaA4iDyysYd4vRJIqtLs9JcGiFL5QvdFduD1tOpgcHLtLHPYrpnqhK LEDIVwj/2qTNuSEgg8urzK961LWWsaDFguFteCO/RqlGcUHGilft6JOMzohzrbn5Maqm VDRshXcpZZ7+hakxwtUCtOai/0JSuKZhYIXy4c7eZNR+qqjaKELHunLCEzk4FnYEEDf5 DJ7w==
X-Gm-Message-State: APjAAAUpJ0LDrrztAwntVq4RPQ1+f0NlbVaG55GQpeBeVVr+H29P4b86 X5XQGjKnUGKKPswk9ScC3ki3WdbhRzvX+7il+RULSg==
X-Google-Smtp-Source: APXvYqwFBqPJ2HfG2P9DM8QXojBljJ8dJWHcVzvic9sl14C5iT0BtodddPycELo3HuAIgodHgEBwNV07WwcCBTg2CXY=
X-Received: by 2002:a6b:9109:: with SMTP id t9mr211228iod.16.1569428440981; Wed, 25 Sep 2019 09:20:40 -0700 (PDT)
MIME-Version: 1.0
References: <VI1PR07MB3981888B6E7B657DD0E97F219B870@VI1PR07MB3981.eurprd07.prod.outlook.com>
In-Reply-To: <VI1PR07MB3981888B6E7B657DD0E97F219B870@VI1PR07MB3981.eurprd07.prod.outlook.com>
From: Andy Bierman <andy@yumaworks.com>
Date: Wed, 25 Sep 2019 09:20:29 -0700
Message-ID: <CABCOCHT6yAtQ+tvzAUGLK77GDZJmjY+j809GTFTNswUaQXnjXQ@mail.gmail.com>
To: "Sterne, Jason (Nokia - CA/Ottawa)" <jason.sterne@nokia.com>
Cc: "netmod@ietf.org" <netmod@ietf.org>
Content-Type: multipart/alternative; boundary="000000000000b9c2e805936308b4"
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/5lu9SSNdsiaSOHvuP4zzh18s7sk>
Subject: Re: [netmod] evaluating 'when' statements with unconfigured leafs
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.29
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, 25 Sep 2019 16:20:55 -0000

On Wed, Sep 25, 2019 at 8:37 AM Sterne, Jason (Nokia - CA/Ottawa) <
jason.sterne@nokia.com> wrote:

> Hi all,
>
>
>
> I saw some recent questions about 'when' statements. I had another one
> related to evaluating 'when' statements that involve leafs that don't
> currently have a value at all.
>
>
>
> leaf foo {
>
>     type enumeration {
>
>         enum val1;
>
>         enum val2;
>
>     }
>
> }
>
>
>
> leaf bar {
>
>     when "../foo != 'val2'";
>
>     type uint8;
>
> }
>
>
>
> Notice that foo does not have a default statement. So if no manager has
> set leaf foo, it doesn't exist in the config.
>
>
>
> In that case, does the "when" statement evaluate to 'true'  (i.e. leaf bar
> is allowed to have a value) ?
>
>
>

no


> i.e. assuming leaf foo is not set at all, is this accepted?
>
> <bar>23</bar>
>
>
>
> Or is there something special here because of the non-existence of leaf
> foo?
>
>
>

 correct.
An empty node-set does not always convert to am empty string.
So easy to tell XPath to do the wrong thing...

    when "../foo != 'val2'";

is not equivalent to

  when "string(../foo) != 'val2'";


If one object to be compared is a node-set and the other is a string, then
the comparison will be true if and only if there is a node in the node-set
such that the result of performing the comparison on the string-value
<https://www.w3.org/TR/1999/REC-xpath-19991116/#dt-string-value> of the
node and the other string is true.


Andy

If the "when" evaluates to 'false', then does the following "when" evaluate
> differently than the one above?
>
>     when "not(../foo = 'val2')";
>
>
>
> Jason
> _______________________________________________
> netmod mailing list
> netmod@ietf.org
> https://www.ietf.org/mailman/listinfo/netmod
>