Re: [netmod] xpath expressions in JSON

Vladimir Vassilev <vladimir@transpacket.com> Thu, 18 October 2018 17:42 UTC

Return-Path: <vladimir@transpacket.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 74702130DCB for <netmod@ietfa.amsl.com>; Thu, 18 Oct 2018 10:42:05 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: 0.098
X-Spam-Level:
X-Spam-Status: No, score=0.098 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, KHOP_DYNAMIC=1.999, SPF_PASS=-0.001] autolearn=no 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 lAjYmUJh_RZy for <netmod@ietfa.amsl.com>; Thu, 18 Oct 2018 10:42:03 -0700 (PDT)
Received: from mail.transpacket.com (s91205186171.blix.com [91.205.186.171]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 215CD130DC6 for <netmod@ietf.org>; Thu, 18 Oct 2018 10:42:02 -0700 (PDT)
Received: from localhost (localhost [127.0.0.1]) by mail.transpacket.com (Postfix) with ESMTP id B78A21541824; Thu, 18 Oct 2018 19:42:00 +0200 (CEST)
Received: from mail.transpacket.com ([127.0.0.1]) by localhost (mail.transpacket.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id quqIKB55Dcjc; Thu, 18 Oct 2018 19:42:00 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1]) by mail.transpacket.com (Postfix) with ESMTP id 81D281541821; Thu, 18 Oct 2018 19:42:00 +0200 (CEST)
Received: from mail.transpacket.com ([127.0.0.1]) by localhost (mail.transpacket.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id gjVvY90lOqen; Thu, 18 Oct 2018 19:42:00 +0200 (CEST)
Received: from [192.168.209.177] (s1853520235.blix.com [185.35.202.35]) by mail.transpacket.com (Postfix) with ESMTPSA id 579F91541753; Thu, 18 Oct 2018 19:42:00 +0200 (CEST)
To: Martin Bjorklund <mbj@tail-f.com>, netmod@ietf.org
References: <20181011.181150.1840683183107627057.mbj@tail-f.com> <329f67ff-0774-0fd7-f630-7a01c7e7d3be@cisco.com> <20181012.103727.731509761734796510.mbj@tail-f.com> <20181018.123036.731934458688841323.mbj@tail-f.com>
From: Vladimir Vassilev <vladimir@transpacket.com>
Message-ID: <70e76afa-59bd-249f-6b7c-4e5788806fc6@transpacket.com>
Date: Thu, 18 Oct 2018 19:42:00 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0
MIME-Version: 1.0
In-Reply-To: <20181018.123036.731934458688841323.mbj@tail-f.com>
Content-Type: text/plain; charset="utf-8"; format="flowed"
Content-Language: nb
Content-Transfer-Encoding: quoted-printable
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/-Ut7VaUZwtSam2z8aM02hpUvipQ>
Subject: Re: [netmod] xpath expressions in JSON
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: Thu, 18 Oct 2018 17:42:06 -0000

Hi,

Seems this discussion affects 10 draft modules using the xpath1.0 type. 
The proposed boilerplate description text that was not added to some RFC 
modules like ietf-netconf-monitoring@2010-10-04.yang

should be as consistent as possible (or skipped based on the 
ietf-netconf-monitoring precedent) until a better alternative is 
available. Here is an example of a better alternative.

    typedef ypath1.0 {
     type xpath1.0;
     description
      "This type represents subset of XPATH 1.0 expressions
       that apply to a data tree conforming to a YANG model.

       Each encoding should allow conversion to an encoding
       independent lexical representation where data node
       prefixes are resolved to and substituted with module
       names.

       When a schema node is defined that uses this type, the
       description of the schema node MUST specify the
       context in which the expression is evaluated if it
       is different from the default context.

       The default context is as follows:

         o  The set of variable bindings is empty.

         o  The function library is the core function library, and
            the XPath functions defined in section 10 in RFC 7950.

         o  The context node is the leaf node.

       ";
     reference
      "XPATH: XML Path Language (XPath) Version 1.0";
   }

That said I do not object to short-term application of alternative A as 
long as a long-term solution is on its way for future modules.

Vladimir

On 10/18/18 12:30 PM, Martin Bjorklund wrote:
> Hi,
>
> Going back to the most urgent issue, what is this WG's recommendation
> for the subscribed-notifications draft in NETCONF wrt/ their usage of
> yang:xpath1.0 in filters?
>
> To summarize:
>
> We already have
>
>    o  instance-identifier in XML uses prefixes from the XML document
>    o  instance-identifier in JSON uses module names as prefixes
>    o  XPath in NETCONF filter uses prefixes from the XML document
>    o  XPath in JSON query filter uses module names as prefixes
>
>
> Alternative A:
> --------------
>
> Use different encodings for "stream-xpath-filter" as well, depending
> on if it is XML or JSON.
>
> We would do in SN:
>
>      o  If the node is encoded in XML, the set of namespace
>         declarations are those in scope on the
>         'stream-xpath-filter' leaf element.
>
>      o  If the node is encoded in JSON, the set of namespace
>         declarations is the set of prefix and namespace pairs
>         for all supported YANG modules, where the prefix is
>         the YANG module name and the namespace is as defined
>         by the "namespace" statement in the YANG module.
>
> Pro: the format is consistent within each encoding.
>
> Con: unclear how to handle other encodings.
> Con: we keep using context-depending encodings.
>
> We could probably add that CBOR uses the same representation as JSON.
>
> Example in XML:
>
>    <stream-xpath-filter
>        xmlns:if="urn:ietf:params:xml:ns:yang:ietf-interfaces"
>        xmlns:ip="urn:ietf:params:xml:ns:yang:ietf-ip">
>      /if:interfaces/if:interface/ip:ipv4
>    </stream-xpath-filter>
>
> Example in JSON:
>
>    "stream-xpath-filter":
>      "/ietf-interfaces:interfaces/ietf-interfaces:interface/ietf-ip:ipv4"
>
>
>
> Alternative B:
> --------------
>
> Use a non-context depending encoding, with the module name as prefix.
>
> We would do in SN:
>
>      o  The set of namespace
>         declarations is the set of prefix and namespace pairs
>         for all supported YANG modules, where the prefix is
>         the YANG module name and the namespace is as defined
>         by the "namespace" statement in the YANG module.
>
> Pro: the format is independent from the protocol encoding
>
> Con: in XML, this leaf is treated differently from other XPath
>       expressions, such as get-config filter and nacm rules.
>
> Example in XML:
>
>    <stream-xpath-filter>
>      /ietf-interfaces:interfaces/ietf-interfaces:interface/ietf-ip:ipv4
>    </stream-xpath-filter>
>
> Example in JSON:
>
>    "stream-xpath-filter":
>      "/ietf-interfaces:interfaces/ietf-interfaces:interface/ietf-ip:ipv4"
>
>
> My proposal is A.  I think it is more important with consistency
> within each encoding than across encodings.
>
> (This said, I would like to have a context-independent encoding of all
> YANG types in the future.  But not now.)
>
>
>
>
> /martin
>
> _______________________________________________
> netmod mailing list
> netmod@ietf.org
> https://www.ietf.org/mailman/listinfo/netmod