[netmod] YANG XPath usage guidelines (6087bis)

Jernej Tuljak <jernej.tuljak@mg-soft.si> Thu, 03 July 2014 11:10 UTC

Return-Path: <jernej.tuljak@mg-soft.si>
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 D2CCE1B286B for <netmod@ietfa.amsl.com>; Thu, 3 Jul 2014 04:10:43 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.151
X-Spam-Level:
X-Spam-Status: No, score=-1.151 tagged_above=-999 required=5 tests=[BAYES_05=-0.5, RP_MATCHES_RCVD=-0.651] 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 f4_hi-W62Jii for <netmod@ietfa.amsl.com>; Thu, 3 Jul 2014 04:10:41 -0700 (PDT)
Received: from gate.mg-soft.si (gate.mg-soft.si [212.30.73.66]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 007EF1B2883 for <netmod@ietf.org>; Thu, 3 Jul 2014 04:10:40 -0700 (PDT)
Received: from [10.0.0.222] (tp-x61t.mg-soft.si [10.0.0.222]) by gate.mg-soft.si (8.13.8/8.13.8) with ESMTP id s63BAcCg012925 for <netmod@ietf.org>; Thu, 3 Jul 2014 13:10:38 +0200
Message-ID: <53B53A2C.7010607@mg-soft.com>
Date: Thu, 03 Jul 2014 13:10:36 +0200
From: Jernej Tuljak <jernej.tuljak@mg-soft.si>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0
MIME-Version: 1.0
To: NETMOD Working Group <netmod@ietf.org>
Content-Type: text/plain; charset="ISO-8859-1"; format="flowed"
Content-Transfer-Encoding: 7bit
Archived-At: http://mailarchive.ietf.org/arch/msg/netmod/yD_S6zbGiEzgMEHCN5SkYLdgND4
Subject: [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: Thu, 03 Jul 2014 11:10:44 -0000

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?

'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'?

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 
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?

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] 
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