Re: analysis of YANG vs. RELAX NG

Martin Bjorklund <mbj@tail-f.com> Tue, 27 November 2007 12:02 UTC

Return-path: <discuss-bounces@apps.ietf.org>
Received: from [127.0.0.1] (helo=stiedprmman1.va.neustar.com) by megatron.ietf.org with esmtp (Exim 4.43) id 1Iwz9S-0008Eb-QX; Tue, 27 Nov 2007 07:02:54 -0500
Received: from discuss by megatron.ietf.org with local (Exim 4.43) id 1Iwz9R-00085Z-G1 for discuss-confirm+ok@megatron.ietf.org; Tue, 27 Nov 2007 07:02:53 -0500
Received: from [10.91.34.44] (helo=ietf-mx.ietf.org) by megatron.ietf.org with esmtp (Exim 4.43) id 1Iwz9R-00085B-5f for discuss@apps.ietf.org; Tue, 27 Nov 2007 07:02:53 -0500
Received: from [213.180.94.162] (helo=mail.tail-f.com) by ietf-mx.ietf.org with esmtp (Exim 4.43) id 1Iwz9Q-0006wm-HT for discuss@apps.ietf.org; Tue, 27 Nov 2007 07:02:53 -0500
Received: from localhost (138.162.241.83.in-addr.dgcsystems.net [83.241.162.138]) by mail.tail-f.com (Postfix) with ESMTP id B533A1B80C3; Tue, 27 Nov 2007 13:02:50 +0100 (CET)
Date: Tue, 27 Nov 2007 13:03:55 +0100
Message-Id: <20071127.130355.18118495.mbj@tail-f.com>
To: rohan.mahy@gmail.com
Subject: Re: analysis of YANG vs. RELAX NG
From: Martin Bjorklund <mbj@tail-f.com>
X-Mailer: Mew version 5.1.51 on Emacs 22.1 / Mule 5.0 (SAKAKI)
Mime-Version: 1.0
Content-Type: Text/Plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.0 (/)
X-Scan-Signature: 6cca30437e2d04f45110f2ff8dc1b1d5
Cc: discuss@apps.ietf.org
X-BeenThere: discuss@apps.ietf.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: general discussion of application-layer protocols <discuss.apps.ietf.org>
List-Unsubscribe: <https://www1.ietf.org/mailman/listinfo/discuss>, <mailto:discuss-request@apps.ietf.org?subject=unsubscribe>
List-Post: <mailto:discuss@apps.ietf.org>
List-Help: <mailto:discuss-request@apps.ietf.org?subject=help>
List-Subscribe: <https://www1.ietf.org/mailman/listinfo/discuss>, <mailto:discuss-request@apps.ietf.org?subject=subscribe>
Errors-To: discuss-bounces@apps.ietf.org

Hi,

"Rohan Mahy" <rohan.mahy@gmail.com> wrote:
> I read through the YANG I-D (draft-bjorklund-netconf-yang-00) and
> thought immediately that all of the problems the draft is trying to
> address looked very suitable to use RELAX NG as a schema language.
> Looking at section F.2 (Why not RELAX NG) I did not see any specific
> examples motivating the apparently contradictory statements that Relax
> is not expressive enough and Relax is too expressive.

What we mean with this is that generic XML schema languages such as
RelaxNG and XSD are designed to specify the grammar for (almost) any
XML instance document.  For example they both support mixed content
and XML attributes, neither of which we use in YANG.  You could of
course just state that these constructs MUST NOT be used.

None of these languages support important configuration management
concepts like default values (XSD has a default construct, but it is
not the same); you cannot see if a parameter represents configuration
or state data (since it's very domain specific).  In RelaxNG there is
not support (by design) for integrity contraints and keys.  None of
the languages have support for specific augmentation (this is
important e.g. for vendors to add vendor-specific stuff to standard
data models).

We also note in the draft that both languages are extensible, and with
an extensible language you can add whatever you want.

All this means that the existing tools might not be that simple to
use.  These tools are not aware of any restrictions on the usage
imposed by NETCONF, and they do not understand the NETCONF-specific
extensions.

Another question regarding existing tools is what exactly these tools
are supposed to be used for?  Probably not instance document (NETCONF
PDU) validation, unless all elements are defined as optional, since
e.g. in an edit-config request you just include the elements you want
to modify.

> keyref and instance-identifier are probably better served by referencing
> an 'id' attribute and using the 'ID' type

The problem with the ID type is that its value is global to a
document.  If the document is the entire configuration datastore, all
IDs will have to be unique.  Since you can reference any key (or maybe
even any leaf), every key (or leaf) will have to have it's own unique
ID.  This won't scale and would be very difficult to maintain.

> Below, I also show examples of the YANG concepts of leaf node,
> leaf-list, container, and list expressed in YANG, how it would be
> expressed in NETCONF, and expressed in RELAX NG.

Here's another one:

in module foo:
   
   rpc my-rpc {
     input {
       leaf foo { type string; }
     }
     output {
       leaf-list bar { type int32; }
       leaf baz      { type int32; }
     }
   }

in module bar:

  augment /foo:my-rpc/foo:output {
     leaf data { type int32; }
  }


How would this translate to RelaxNG?



/martin