Subject: analysis of YANG vs. RELAX NG

From: "Rohan Mahy" <[email-masked]>
Date: Mon, 26 Nov 2007 21:48:37 -0800

Hi,

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.

Below is a comparison of YANG integral types and common idioms to integral
types/idioms available in RELAX NG. I seems pretty clear to me that
expressing any of the idioms in YANG should be straightforward in RELAX NG
and very easy to read and write.

Writing a schema language is a lot of work, and I can't imagine the IETF
designing one that would only be used by NETCONF. RELAX NG has existing
tools and parsers, has additional integral types (ex: URI, dates, and
times), and was written by a large group of folks who have tons of
experience designing schema languages.

thanks,
-rohan

BUILT IN TYPES
yang:    relax:
int8     byte
int16    short
int32    int
int64    long
uint8    unsignedByte
uint16   unsignedShort
uint32   unsignedInt
uint64   unsignedLong
float32  float
float64  double

string   string
boolean  boolean
binary   base64Binary

empty    <empty/>
anyxml   <anyName/>
union    <choice>  or    <interleaved>

enumeration, <text><choice>
bits           <value>foo</value>
               <value>bar</value>
             </choice></text>

keyref and instance-identifier are probably better served by referencing an
'id' attribute and using the 'ID' type, but doing exactly what is done in
YANG could still be handled easily using an anyURI restricted to be an XPath
expression.

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.

LEAF
yang:
leaf host-name {
  type string;
  description "Hostname for this system";
}

netconf:
<host-name>my.example.com</host-name>

relax:
<element name="host-name">
  <other:description>Hostname for this system</other:description>
  <data type="string"/>
</element>

LEAF-LIST
yang:
leaf-list domain-search {
  type string;
}

netconf:
<domain-search>example.com</domain-search>
<domain-search> example.org</domain-search>

relax:
<zeroOrMore> <!-- could be oneOrMore instead -->
  <element name="domain-search">
    <text/>  <!-- this is an alias for data type="string" -->
  </element>
</zeroOrMore>

CONTAINER
yang:
container system {
  container login {
    leaf message {
      type string;
    }
  }
}

netconf:
<system>
  <login>
    <message>Hello Dave</message>
  </login>
</system>

relax:
<element name="system">
  <element name="login">
    <element name="message">
      <text/>
    </element>
  </element>
</element>

LIST
yang:
list user {
  key "name";
  leaf name {
    type string;
  }
  leaf class {
    type string;
  }
}

netconf:
<user>
  <name>alice</name>
  <class>human</class>
</user>
<user>
  <name>cheshire</name>
  <class>cat</class>
</user>

relax:
<zeroOrMore>
  <element name="user">
    <other:key>name</other:key>
    <element name="name">
      <text/>
    </element>
    <element name="class">
      <text/>
    </element>
  </element>
</zeroOrMore>

---

From: Paul Hoffman <[email-masked]>
Date: Tue, 27 Nov 2007 08:54:45 -0800

At 9:48 PM -0800 11/26/07, Rohan Mahy wrote:
>Writing a schema language is a lot of work, and I can't imagine the 
>IETF designing one that would only be used by NETCONF. RELAX NG has 
>existing tools and parsers, has additional integral types (ex: URI, 
>dates, and times), and was written by a large group of folks who 
>have tons of experience designing schema languages.

FWIW, I bought a copy of the book "RELAX NG" by van der Vlist and 
found it to be quite easy to understand. After reading it (well, 
about half of it), I found RELAX NG much less threatening than after 
reading a bunch of web resources.

---

From: "Natale, Bob" <[email-masked]>
Date: Tue, 27 Nov 2007 13:37:40 -0500

Hi Paul,

And online access to the book is available via
http://books.xmlschemata.org/relaxng/.

(I have not checked whether any newer print version of the book might
be available.)

Cheers,
BobN

---

From: Andrew Newton <[email-masked]>
Date: Tue, 27 Nov 2007 12:23:48 -0500

> reading a bunch of web resources.

If it is the O'Reilly book, it can also be found on-line here:
http://books.xmlschemata.org/relaxng/page2.html

And yes, that is a good book on the subject.

-andy