Re: [netmod] xpath expressions in JSON

Andy Bierman <andy@yumaworks.com> Thu, 18 October 2018 21:05 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 B27B8130E19 for <netmod@ietfa.amsl.com>; Thu, 18 Oct 2018 14:05:34 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.901
X-Spam-Level:
X-Spam-Status: No, score=-1.901 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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 WFc82EcXbtKp for <netmod@ietfa.amsl.com>; Thu, 18 Oct 2018 14:05:32 -0700 (PDT)
Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) (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 59BD212F1AC for <netmod@ietf.org>; Thu, 18 Oct 2018 14:05:31 -0700 (PDT)
Received: by mail-lj1-x229.google.com with SMTP id j17-v6so29030033lja.1 for <netmod@ietf.org>; Thu, 18 Oct 2018 14:05:31 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yumaworks-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=9MPtxdUNieloSa4HliUC3CR2lYJRsdAGVbr24xVqfZg=; b=tszmA+G3CqaPMK/CW0HLdZr8rUz/clQ7I+qLPX42aL7p+qgXbSf6ykxb6g6MYXZeAF jZo8dWCQ0vp01KF32tZdKlRmA+Qte+TMbi3czqnAc1MMAf47OFy1MVRIrUk4se4Fnl/h 1qNkAIwwYVkTSX3Xx3HLjv9k9ifGTazuo07BnFsVDiuap+WLaawLk6Tu+9ld3G+u0pv6 r4YGuWwy+fkUfN+Exl8/qCFoI8e5Im5zqVCyBcF9eQDI/PWwhvkbZTa5okBuLNfcFKNK BnqwlHca5VhEWkAdLltXP2aUWCiyIvfINpdRW1tWu9mZtMrEgdAHaCinBKGLOaa/rNFg liKg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=9MPtxdUNieloSa4HliUC3CR2lYJRsdAGVbr24xVqfZg=; b=OFpJxYSev2FnxSJQMjr3/EupeVnVi0AQmeUPeoeMT8cMF6cROrUhr/gdTnV9Z7T/Y2 569E7gIxacFwlKPibdJ1AsiX+Hx8mX5LK+eqOnhED2MpfUsrihnlfmoRIMykcqQV7KoZ 0GFube3scxknHxLhhHtb6Poy82MBukmAXe7dOrF0fF9rEfLZgbXPwR6Q6u6QqTLFqHgx jLk4+E+xe++HJ1R6wh9/mMBur2pCd1EFfZRSN/LbDhGMCbZpO9+zJu79nXLyG6F6os7P Qw387O3Iu2oLMpUApuoQBnLoMdWIZ74D969WdT/J5w/K7bG0fUGtvNweHepKzw29F9aq gUfw==
X-Gm-Message-State: ABuFfoh9kIK7JDfOLZUA5f0i+V4ys6jbmUnmH9TkII7vc/S3RNolIH60 mRmVGz8DK5TeHgd+WppVz1AoeuhBtlRTAFO/OaIU1J8I
X-Google-Smtp-Source: ACcGV635gID0ry4qnx3ukM7YQtbYZYK2VxxuMTWyw1K2M3ndiK9xkK8omNsoN4FWHjvvqxB0GwU6HhtJ48AYPy3OXHo=
X-Received: by 2002:a2e:9796:: with SMTP id y22-v6mr8467119lji.20.1539896729417; Thu, 18 Oct 2018 14:05:29 -0700 (PDT)
MIME-Version: 1.0
Received: by 2002:a19:1f87:0:0:0:0:0 with HTTP; Thu, 18 Oct 2018 14:05:28 -0700 (PDT)
In-Reply-To: <20181018.223248.2170782709410525886.mbj@tail-f.com>
References: <CABCOCHRufR6S8NCp5n+UXgG0Y_OJ368XZZmzFR8wEHc0CLw+HQ@mail.gmail.com> <20181018.215826.2271077466982765895.mbj@tail-f.com> <CABCOCHQRtE_qxSA_LbetRE21=NiCrfDh1NJ-M=t2PDvZPmpXMA@mail.gmail.com> <20181018.223248.2170782709410525886.mbj@tail-f.com>
From: Andy Bierman <andy@yumaworks.com>
Date: Thu, 18 Oct 2018 14:05:28 -0700
Message-ID: <CABCOCHR3npOLUF-U0gHeYsWkFz+ZRS6z34JHrn-BPd9qKv6H6g@mail.gmail.com>
To: Martin Bjorklund <mbj@tail-f.com>
Cc: Vladimir Vassilev <vladimir@transpacket.com>, NetMod WG <netmod@ietf.org>
Content-Type: multipart/alternative; boundary="0000000000008c54360578872532"
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/v2c73BwDmbVQJj0dOJ5j5OL1Ozs>
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 21:05:35 -0000

On Thu, Oct 18, 2018 at 1:32 PM, Martin Bjorklund <mbj@tail-f.com> wrote:

> Andy Bierman <andy@yumaworks.com> wrote:
> > On Thu, Oct 18, 2018 at 12:58 PM, Martin Bjorklund <mbj@tail-f.com>
> wrote:
> >
> > > Andy Bierman <andy@yumaworks.com> wrote:
> > > > Hi,
> > > >
> > > > I strongly agree that a new data type is needed (ypath1.0 or just
> ypath
> > > is
> > > > fine)
> > > > Adding new semantics or requirements to published data types is
> > > > unacceptable.
> > > >
> > > > Also, we must get the type and module containing the data type right
> on
> > > the
> > > > first try.
> > > > No moving it later because the import looks bad. That said, a "quick
> > > > 6991-bis" is unrealistic,
> > > > and a multi-year 6991-bis is unhelpful.
> > > >
> > > > Should there be a canonical format, based on module-names as
> prefixes?
> > > > Consider how to compare 2 values using this data type.
> > >
> > > Ok.  So which alternative do you prefer for stream-xpath-filter, which
> > > is supposed to work also for JSON?  The current definition doesn't
> > > work for JSON.
> > >
> > >
> >
> > I don't like calling it xpath when it is not XPath any more.
>
> But stream-xpath-filter *is* XPath.  The alternative solutions differ
> only in how the prefix mapping is defined.
>


I don't think it should be called XPath if module-names are used as
prefixes.
Alternative A using a special data type is the least objectionable I guess


Andy


> > It should be as clear as possible to readers and designers that xpath
> > means XPath and ypath is not XPath.
> >
> > I would prefer a new encoding that allows the parent node module-name to
> be
> > used somehow,
> > consistent with the JSON encoding used now.
> >
> > Perhaps each absolute-path expression starts with a module-name step and
> > relative-path
> > expressions assume the module name of the context node if there is no
> > module-name.
> >
> > Neither alternative below is a good long-term solution.
>
> Agreed, but we need to find a solution for stream-xpath-filter, or
> else we should remove it from SN.
>
> > The old problems come up again:
> >
> >   Client A writes the /foo node in XML.
> >   Client B reads the /foo node returned in JSON
> >
> > Which format is returned? Does the server magically convert the value for
> > each encoding type?
>
> Yes, just like it does with i-i and identityref.
>
> > If we bother to fix this problem at all, then we should get rid of
> reliance
> > on prefix to namespace mappings.
>
> Long-term, yes!
>
>
> /martin
>
>
> >
> >
> >
> >
> >
> > > /martin
> > >
> > >
> >
> > Andy
> >
> >
> > >
> > > >
> > > >
> > > > Andy
> > > >
> > > >
> > > > On Thu, Oct 18, 2018 at 10:42 AM, Vladimir Vassilev <
> > > > vladimir@transpacket.com> wrote:
> > > >
> > > > > 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
> > > > >>
> > > > >
> > > > > _______________________________________________
> > > > > netmod mailing list
> > > > > netmod@ietf.org
> > > > > https://www.ietf.org/mailman/listinfo/netmod
> > > > >
> > >
>