Subject: [YANG] FW: analysis of YANG vs. RELAX NG

From: "Romascanu, Dan (Dan)" <[email-masked]>
Date: Tue, 27 Nov 2007 12:13:07 +0100

FYI, from the applications discussions list. 
 
As David pointed it would be good if folks involved with NETCONF and
yang joined [email-masked].
 
Dan

________________________________

From: Rohan Mahy [mailto:[email-masked]] 
Sent: Tuesday, November 27, 2007 7:49 AM
To: [email-masked]
Subject: analysis of YANG vs. RELAX NG

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>

_______________________________________________
YANG mailing list
[email-masked]
https://www1.ietf.org/mailman/listinfo/yang