Re: [netmod] xpath expressions in JSON

Vladimir Vassilev <vladimir@transpacket.com> Mon, 15 October 2018 19:53 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 CCF50130F0D for <netmod@ietfa.amsl.com>; Mon, 15 Oct 2018 12:53:34 -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, KHOP_DYNAMIC=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] 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 ZKH8ZalGicCP for <netmod@ietfa.amsl.com>; Mon, 15 Oct 2018 12:53:31 -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 C1E45130EE2 for <netmod@ietf.org>; Mon, 15 Oct 2018 12:53:30 -0700 (PDT)
Received: from localhost (localhost [127.0.0.1]) by mail.transpacket.com (Postfix) with ESMTP id A79861443EF5; Mon, 15 Oct 2018 21:53:28 +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 63BZU7EgyTaW; Mon, 15 Oct 2018 21:53:28 +0200 (CEST)
Received: from localhost (localhost [127.0.0.1]) by mail.transpacket.com (Postfix) with ESMTP id 7B3A61443EDD; Mon, 15 Oct 2018 21:53:28 +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 14VUqqAIEttc; Mon, 15 Oct 2018 21:53:28 +0200 (CEST)
Received: from [192.168.209.177] (s1853520235.blix.com [185.35.202.35]) by mail.transpacket.com (Postfix) with ESMTPSA id 5192E1443EA0; Mon, 15 Oct 2018 21:53:28 +0200 (CEST)
To: Ladislav Lhotka <lhotka@nic.cz>, netmod@ietf.org
References: <3B614CF4-9545-4C31-BEF4-CDFBF72AA045@cisco.com> <CABCOCHT32pSP3raNj6pP3BY9ji4DnOoOAaKVY7QyfV4tqqp9KA@mail.gmail.com> <74ab4ac248f1933ba7a3a095eb7bb1865325588e.camel@nic.cz> <20181011.084242.2147348417024315805.mbj@tail-f.com> <87zhvfi8wj.fsf@nic.cz>
From: Vladimir Vassilev <vladimir@transpacket.com>
Message-ID: <82c86e19-e626-a4c3-b1d4-e803bc0fd05c@transpacket.com>
Date: Mon, 15 Oct 2018 21:53:28 +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: <87zhvfi8wj.fsf@nic.cz>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: quoted-printable
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/ZaRgfu2_L06H-lU5UBizRzVvgD8>
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: Mon, 15 Oct 2018 19:53:41 -0000

On 10/15/18 4:25 PM, Ladislav Lhotka wrote:

> Martin Bjorklund <mbj@tail-f.com> writes:
>
>> Ladislav Lhotka <lhotka@nic.cz> wrote:
>>> On Wed, 2018-10-10 at 19:23 -0700, Andy Bierman wrote:
>>>>
>>>> On Wed, Oct 10, 2018 at 6:59 PM, Reshad Rahman (rrahman) <rrahman@cisco.com>
>>>> wrote:
>>>>> On 2018-10-10, 9:59 AM, "netmod on behalf of Martin Bjorklund" <
>>>>> netmod-bounces@ietf.org on behalf of mbj@tail-f.com> wrote:
>>>>>
>>>>>      Ladislav Lhotka <lhotka@nic.cz> wrote:
>>>>>      > Martin Bjorklund <mbj@tail-f.com> writes:
>>>>>      >
>>>>>      > > Hi,
>>>>>      > >
>>>>>      > > While reviewing restconf-notif, I saw this example:
>>>>>      > >
>>>>>      > >    {
>>>>>      > >       "ietf-subscribed-notifications:input": {
>>>>>      > >          "stream": "NETCONF",
>>>>>      > >          "stream-xpath-filter": "/ds:foo/",
>>>>>      > >          "dscp": "10"
>>>>>      > >       }
>>>>>      > >    }
>>>>>      > >
>>>>>      > > Note the "stream-xpath-filter".  It has a prefix in the XPath
>>>>> string.
>>>>>      > > How are prefixes declared when JSON is used?
>>>>>      > >
>>>>>      > > The leaf "stream-xpath-filter" says:
>>>>>      > >
>>>>>      > >               o  The set of namespace declarations are those in
>>>>> scope on
>>>>>      > >                  the 'stream-xpath-filter' leaf element.
>>>>>      > >
>>>>>      > > (I think I provided that text...)
>>>>>      > >
>>>>>      > > This assumes that the encoding is XML, or at leas that the encoding
>>>>>      > > can somehow transfer namespace declarations.
>>>>>      >
>>>>>      > It can't. There are two options:
>>>>>      >
>>>>>      > 1. have different representations of this value in XML and JSON,
>>>>>      >    analogically to instance indentifiers (sec. 6.11 in RFC 7951).
>>>>>      >
>>>>>      > 2. use a module name rather than a prefix in XML, too.
>>>>>      >
>>>>>      > I would suggest #2.
>>>>> <RR> But that means making non-backwards compatible change to the XML
>>>>> representation?
>>>> Not really. It means NETMOD WG would be creating its own special variant of
>>>> XPath.
>>> The thing is that XPath is "XML Path Language", so using it outside XML is
>>> problematic.
>> Not necessarily.  Section 5 of the XPath 1.0 spec defins the "data
>> model" where an XPath expression is applied.  We could make a formal
>> specification of how a YANG data tree maps to this data model (pretty
>> straightforward...).  I think experience from implementations over the
>> last 8 years show that this in fact works quite well.
> Except some parts that don't apply. For example, siblings nodes in XPath
> are ordered, whereas in YANG 'foo[1]' may give unpredictable results.

Not all XPath expressions map to something meaningful in the context of 
YANG data.  However a subset of them do.

IMO introducing yang:ypath1.0 makes sense but it is practical to define 
it as a subset of yang:xpath1.0. Martins proposal 2) for an encoding 
independent solution where the prefixes are restricted to be module 
names works. Proposal 1) seems to be a step back clogging YANG with 
encoding specific details.

Vladimir

>
> This is probably OK in YANG modules but not so much if XPath expressions
> are used as configuration data.
>
> Lada
>
>>
>> /martin
>>
>>
>>
>>> Lada
>>>
>>>>>      Hmm, so you mean change the leaf "stream-xpath-filter" to say:
>>>>>
>>>>>               o  The set of namespace declarations has one member for each
>>>>>                  YANG module supported by the server.  This member maps
>>>>>                  from the YANG module name to the YANG module namespace.
>>>>>
>>>>>                  This means that in the XPath expression, the module name
>>>>>                  serves as the prefix.
>>>>>
>>>>>      .... and then also give an example of this.
>>>>>
>>>>>      This is probably what we need to do in all places where yang:xpath1.0
>>>>>      is used, going forward.  Maybe even define a new type
>>>>>      yang:xpath1.0-2 (name?) with the set of namespace declarations
>>>>>      built-in.
>>>>
>>>> We should avoid making off-the-shelf implementations of standards like XPath
>>>> unusable.
>>>> At the very least this should be only available if the server supports it
>>>> (with a capability URI)
>>>>
>>>>   
>>>>> <RR> So we need an update to RFC7951?
>>>>>
>>>>> Regards,
>>>>> Reshad.
>>>>>
>>>>
>>>> Andy
>>>>   
>>>>>      /martin
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>      >
>>>>>      > Lada
>>>>>      >
>>>>>      > >
>>>>>      > > How is this supposed to work with JSON?
>>>>>      > >
>>>>>      > >
>>>>>      > > /martin
>>>>>      > >
>>>>>      > > _______________________________________________
>>>>>      > > netmod mailing list
>>>>>      > > netmod@ietf.org
>>>>>      > > https://www.ietf.org/mailman/listinfo/netmod
>>>>>      >
>>>>>      > --
>>>>>      > Ladislav Lhotka
>>>>>      > Head, CZ.NIC Labs
>>>>>      > PGP Key ID: 0xB8F92B08A9F76C67
>>>>>      >
>>>>>
>>>>>      _______________________________________________
>>>>>      netmod mailing list
>>>>>      netmod@ietf.org
>>>>>      https://www.ietf.org/mailman/listinfo/netmod
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> netmod mailing list
>>>>> netmod@ietf.org
>>>>> https://www.ietf.org/mailman/listinfo/netmod
>>>>
>>> -- 
>>> Ladislav Lhotka
>>> Head, CZ.NIC Labs
>>> PGP Key ID: 0xB8F92B08A9F76C67
>>>