Re: [netmod] [yang-doctors] Question on yang?

Andy Bierman <andy@yumaworks.com> Mon, 12 January 2015 16:10 UTC

Return-Path: <andy@yumaworks.com>
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 8B2191AC3BA for <netmod@ietfa.amsl.com>; Mon, 12 Jan 2015 08:10:56 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.979
X-Spam-Level:
X-Spam-Status: No, score=-1.979 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, FM_FORGED_GMAIL=0.622, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001] autolearn=unavailable
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 g9HOhrMLTX0T for <netmod@ietfa.amsl.com>; Mon, 12 Jan 2015 08:10:54 -0800 (PST)
Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com [209.85.217.181]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 6ECDC1AC3B1 for <netmod@ietf.org>; Mon, 12 Jan 2015 08:10:54 -0800 (PST)
Received: by mail-lb0-f181.google.com with SMTP id l4so18440509lbv.12 for <netmod@ietf.org>; Mon, 12 Jan 2015 08:10:52 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=y9C5jPFyyV+fXh5FBQhQwyah6eGX0aZ010JdJlQedyc=; b=JUYuru8geFFJ/rKhoY/uFT4TKrzD6pYjWoxa9ARg0p6cI8gDweXG7n1jQXijp2SMk3 hiIze3ZolEcUniKcVh6cRd1vvh2slIlKLDqBaUq7dRSNEHFF8s0kmyf+t+/x/D1ERsDb qiYaNa/kdERU+aKoYIzxBZz66C1XKgWpDFF1VP+MKLt9/oaP4EHrGHZKrJgMCeOGfCrG aZyZtwm5YSQ0BRKyeYk2GXpqr+akEMQoXq5lhScx2Iu19fwxh66PAymqyJjjHODMVhSw mfYUVkflD8VFjlgxYuL4yLKDR2bX1hH7275EMW0ILUck3d6fvvVHBlsKMIPtuXHwVid+ vI8w==
X-Gm-Message-State: ALoCoQn3eHbjU7MgRPT3KGMlm/zKs+SoE+yZzSUKQ3/+5qynwFf+/PlI4KvhKgVQMRUmKdYfLRkN
MIME-Version: 1.0
X-Received: by 10.112.25.7 with SMTP id y7mr37170122lbf.94.1421079052760; Mon, 12 Jan 2015 08:10:52 -0800 (PST)
Received: by 10.112.160.41 with HTTP; Mon, 12 Jan 2015 08:10:52 -0800 (PST)
In-Reply-To: <CC0A2D3A-87AE-4556-8AE9-7A4F8AD20900@nic.cz>
References: <FE19DA4E-059A-4E18-A180-8C9CFCF77ED7@rawdofmt.org> <CAC790A1-02FB-4D24-987F-CD729E489640@lucidvision.com> <CABCOCHRmsKRoBL9Scb5-WNYF_Sv6q+k9puHNr1dj62NmabPiYQ@mail.gmail.com> <A3A207E2-99C1-4E10-AE8E-3BB80E8CA68C@rawdofmt.org> <m2oaq4xl97.fsf@nic.cz> <CABCOCHT2Un9BdECaf257E4PjTehOv-YSDzOe+RS=4wsOhnomMA@mail.gmail.com> <D4194D5F-DE96-413F-966D-C084691066E3@nic.cz> <CABCOCHSKre2KKJPgvZjWAYh-b7R-SaBOS0w0wF-3qSPL41yixw@mail.gmail.com> <CC0A2D3A-87AE-4556-8AE9-7A4F8AD20900@nic.cz>
Date: Mon, 12 Jan 2015 08:10:52 -0800
Message-ID: <CABCOCHQrfos=j-KBQB=QOCmNWLoqKgxLYtjNwkSwONXSGdMfNw@mail.gmail.com>
From: Andy Bierman <andy@yumaworks.com>
To: Ladislav Lhotka <lhotka@nic.cz>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Archived-At: <http://mailarchive.ietf.org/arch/msg/netmod/X4UmzyusC8k-t143ttlwOE0UhmE>
Cc: YANG Doctors <yang-doctors@ietf.org>, NETMOD Working Group <netmod@ietf.org>
Subject: Re: [netmod] [yang-doctors] Question on yang?
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, 12 Jan 2015 16:10:56 -0000

On Mon, Jan 12, 2015 at 6:22 AM, Ladislav Lhotka <lhotka@nic.cz> wrote:
>
>> On 12 Jan 2015, at 15:05, Andy Bierman <andy@yumaworks.com> wrote:
>>
>> On Mon, Jan 12, 2015 at 5:34 AM, Ladislav Lhotka <lhotka@nic.cz> wrote:
>>>
>>>> On 12 Jan 2015, at 13:42, Andy Bierman <andy@yumaworks.com> wrote:
>>>>
>>>> On Mon, Jan 12, 2015 at 3:59 AM, Ladislav Lhotka <lhotka@nic.cz> wrote:
>>>>> Hi Christian,
>>>>>
>>>>> Christian Hopps <chopps@rawdofmt.org> writes:
>>>>>
>>>>>>
>>>>>> Sorry I trimmed it down as the site def is much larger, the list contains a key:
>>>>>>
>>>>>>   list site {
>>>>>>     key "site-id";
>>>>>>     leaf site-id {
>>>>>>       type site-id;
>>>>>>     }
>>>>>>     leaf site-type {
>>>>>>       mandatory true;
>>>>>>       type site-type;
>>>>>>     }
>>>>>>     // [..cut..]
>>>>>>     leaf-list router {
>>>>>>       // The combination of when and min-elms appears to allow 0 elements
>>>>>>       // for the when matching site types
>>>>>>       min-elements 1;
>>>>>>       when "../site-type = 'ots' or ../site-type = 'odws'";
>>>>>>       type leafref {
>>>>>>         path "../../../router/router-id";
>>>>>>       }
>>>>>>     }
>>>>>>
>>>>>> I’m using yang2dsdl with (both -t data and -t config) to
>>>>>> validate. Both ways (config or data) accept XML with no routers
>>>>>> specified in ‘ots’ or ‘odws’ sites. Both ways correctly reject a
>>>>>> router specified in a non-ots/odws site.
>>>>>
>>>>> This has to do with YANG 1.1 ussue Y18:
>>>>>
>>>>> https://svn.tools.ietf.org/svn/wg/netmod/yang-1.1/issues.html#sec-19
>>>>>
>>>>
>>>> This does not appear to be related to Y18.
>>>
>>> It is exactly the substance of Y18: If no <router> element is present in the instance document, the XPath expression cannot be evaluated (if we abide by XPath rules) to decide whether the “router” node is in the schema or not. That’s where Y18-01 proposes to insert a tentative <router> element and use it as the context node.
>>>
>>
>>
>> OK - you are right -- this is Y18.
>> Our code creates a dummy context node in this case.
>> If the when-stmt is true, the min-elements violation
>> would be generated.
>
> Right, but this is really difficult to do via DSDL mapping because the RELAX NG schema generated from the YANG data model doesn’t depend on a particular instance document, and RELAX NG doesn’t do XPath evaluation.
>

You would have to generate a new config document with the context node in it.
This is actually one of the easier aspects of implementing when-stmt
correctly within a real server.  (For some definition of "correct", depending on
the evaluation order and other details).


> Lada
>
>>
>> Andy
>


Andy