Re: [netmod] YANG XPath usage guidelines (6087bis)

Ladislav Lhotka <lhotka@nic.cz> Mon, 07 July 2014 09:11 UTC

Return-Path: <lhotka@nic.cz>
X-Original-To: netmod@ietfa.amsl.com
Delivered-To: netmod@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 624001B27F0 for <netmod@ietfa.amsl.com>; Mon, 7 Jul 2014 02:11:06 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.9
X-Spam-Level:
X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9] autolearn=ham
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 PM1g_tSPW2cV for <netmod@ietfa.amsl.com>; Mon, 7 Jul 2014 02:11:00 -0700 (PDT)
Received: from trail.lhotka.name (trail.lhotka.name [77.48.224.143]) (using TLSv1.1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 39FC51A00FD for <netmod@ietf.org>; Mon, 7 Jul 2014 02:11:00 -0700 (PDT)
Received: from localhost (localhost [127.0.0.1]) by trail.lhotka.name (Postfix) with ESMTP id C2C1A540143; Mon, 7 Jul 2014 11:10:57 +0200 (CEST)
Received: from trail.lhotka.name ([127.0.0.1]) by localhost (trail.lhotka.name [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Wxn4zlwb2OHm; Mon, 7 Jul 2014 11:10:52 +0200 (CEST)
Received: from localhost (unknown [172.29.2.201]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by trail.lhotka.name (Postfix) with ESMTPSA id 59DA3540138; Mon, 7 Jul 2014 11:10:52 +0200 (CEST)
From: Ladislav Lhotka <lhotka@nic.cz>
To: Jernej Tuljak <jernej.tuljak@mg-soft.si>, NETMOD Working Group <netmod@ietf.org>
In-Reply-To: <53B53A2C.7010607@mg-soft.com>
References: <53B53A2C.7010607@mg-soft.com>
User-Agent: Notmuch/0.18 (http://notmuchmail.org) Emacs/24.3.50.2 (x86_64-apple-darwin13.0.0)
Date: Mon, 07 Jul 2014 11:10:51 +0200
Message-ID: <m2vbr9sfdw.fsf@nic.cz>
MIME-Version: 1.0
Content-Type: text/plain
Archived-At: http://mailarchive.ietf.org/arch/msg/netmod/W43Ecwwjlc9PfebCnLDSUiH_PtE
Subject: Re: [netmod] YANG XPath usage guidelines (6087bis)
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.15
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: <http://www.ietf.org/mail-archive/web/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: Mon, 07 Jul 2014 09:11:06 -0000

Jernej Tuljak <jernej.tuljak@mg-soft.si> writes:

> Hi,
>
> some questions about YANG XPath expressions in general and as observed 
> by 6087bis [1].
>
> Does it make sense to use the 'id(object)' and 'lang(string)' XPath 
> functions in YANG XPath expressions? They both imply existence of XML 
> attributes, which cannot be modeled in pure YANG. Shouldn't RFC6087bis 
> include a guideline for those in Section 4.5.? Is there a case where the 
> mentioned XPath functions could be used?

Now that there are several proposals for standardizing (global)
attributes for use with YANG data, it might actually be useful to refer
to attributes in XPath expressions. One use case could be: "Nodes X and
Y can both be present only if at least one of them is tagged as
inactive".

But in order to be able to do this, one needs to be able to include an
attribute's namespace in the context of the XPath expression - this is
another case where the "attribute" statement (issue Y33) would be useful.
 
>
> 'local-name(node-set?)', 'namespace-uri(node-set?)', 'name(node-set?)', 
> 'string(object?)' and 'number(object?)' are all directly reliant on 
> document order when the argument evaluates to a node-set with size > 1 
> and may therefore return different results for different 
> implementations, like the case with 'position' and 'last'. Other 
> functions may also be indirectly reliant on document order when they are 
> supplied with a node-set argument which then needs to be converted into 
> a string or a number as if by calling 'string(object?)' or  
> 'number(object?)' respectively [2]. Shouldn't this also be mentioned in 
> the guidelines, since some other cases are?
>
> Axes 'preceding-sibling' and 'following-sibling' should not be used 
> unless dealing with user ordered lists or leaf-lists and I agree with 
> 6087bis, however document order may not be relevant when using those two 
> axes (uniqueness checks). There's an example in ietf-routing module [3]:
> not(/routing/ribs/rib[name=current()/preceding-sibling::connected-rib/rib-name 
> and 
> address-family=/routing/ribs/rib[name=current()/rib-name]/address-family])
> where current() evaluates to a non-user ordered list instance. Shouldn't 
> this also be mentioned in the guidelines as an acceptable corner case, 
> like it is for 'preceding' and 'following'?

I think the following text in 6087bis should be extended to cover
"preceding-sibling" and "following-sibling" as well:

"The 'preceding' and 'following' axes MAY be used if document order is
not relevant to the outcome of the expression (e.g., check for global
uniqueness of a parameter value)."

>
> 6087bis specifies:
>
>     XPath expressions for 'when' statements MUST NOT reference the
>     context node or any descendant nodes of the context node.
>
> yet ietf-ipv4-unicast-routing [3] clearly does so, with it's
> conditional

The example in sec. 3.3 of RFC 7223 does it, too.
 
> augments of rpc methods, where it references 'rt:address-family' which 
> is a descendant of the initial context node (augmentation target or 
> nearest data node ancestor). Shouldn't conditional augmentation be an 
> exception to this paragraph?

Yes. In fact, many of the concerns regarding "when" (see e.g. issue Y18)
don't apply if it is used under "augment" because the result of "when"
evaluation doesn't affect the context node.

>
> 6087bis specifies:
>
>     Data nodes that use the 'int64' and 'uint64' built-in type SHOULD NOT
>     be used within numeric expressions.  There are boundary conditions in
>     which the translation from the YANG 64-bit type to an XPath number
>     can cause incorrect results.  Specifically, an XPath 'double'
>     precision floating point number cannot represent very large positive
>     or negative 64-bit numbers because it only provides a total precision
>     of 53 bits.  The 'int64' and 'uint64' data types MAY be used in
>     numeric expressions if the value can be represented with no more than
>     53 bits of precision.
>
> In XPath specification [4], term "numeric expressions" refers to 
> additive (+, -), multiplicative (*, mod, div) or unary expressions 
> (sign) and does not include relational or equality expressions, so 
> comparisons of int64 and uint64 data nodes do not seem to be discouraged 
> by the current text. Was this intentional? Shouldn't all such numeric 
> conversions be avoided?
>
> Ladislav once mentioned [5] that YANG XPath is able to "break out of 
> module containment" with an expression like
> /*[local-name()='foo']
> which is quite dangerous and IMO deserves mention in the guidelines. It 
> should be clear that an expression is only able to reference names 
> defined within the scope of a module, right? Or was "breaking out of
> module containment" intended as a feature of RFC6020 (seems more like a 
> bug to me)? Completely unrelated modules should not cause unwanted side 
> effects when implemented together.

+1

Lada

>
> [1] 
> http://tools.ietf.org/html/draft-bierman-netmod-rfc6087bis-00#section-4.5
> [2] http://www.w3.org/TR/1999/REC-xpath-19991116/#section-Function-Calls
> [3] http://tools.ietf.org/html/draft-ietf-netmod-routing-cfg-15
> [4] http://www.w3.org/TR/1999/REC-xpath-19991116/#numbers
> [5] http://www.ietf.org/mail-archive/web/netmod/current/msg09623.html
>
> Jernej
>
> _______________________________________________
> netmod mailing list
> netmod@ietf.org
> https://www.ietf.org/mailman/listinfo/netmod

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