r1 - 2010-05-26 - 14:25:19 - LadaLhotkaYou are here: TWiki >  Main Web > YangTools > DSDLMappingTutorial

DSDL Mapping Tutorial


One of the functions implemented in [[http://code.google.com/p/pyang] [pyang]] is the mapping of YANG data models to DSDL schemas – RELAX NG, Schematron and DSRL. The resulting schemas may be used with off-the-shelf XML tools for validating NETCONF datastores and PDUs and other related purposes.

The mapping procedure is described in draft-ietf-netmod-dsdl-map.

This tutorial works with a very simple data model consisting of two YANG modules. We will first show how to perform the DSDL mapping procedure with the yang2dsdl script that is a part of pyang distribution, and then experiment with validating configuration datastore contents and a NETCONF protocol data unit (PDU).

Finally, we will dissect the yang2dsdl script and discuss other possible setups and applications of the DSDL mapping procedure.

The Data Model

As an example, we use the YANG module acme-system shown at the bottom of WebHome (see also acme-system.yang). To make things slightly more interesting, we augment this module by adding three new nodes to the entries of the "interface" list. This is accomplished by the following module (see also extra-interface-data.yang):

module extra-interface-data {
  namespace "http://foo.example.com/extra-if-data";
  prefix eid;
  import acme-system {
    prefix acme;
  import ietf-inet-types {
    prefix inet;
  augment "/acme:system/acme:interface" {
    leaf enabled {
      type boolean;
      default "false";
      must ".='false' or ../ipv4-address and ../subnet-mask-length" {
        error-message "IP address and mask must be configured " +
                      "for enabled interfaces.";
    leaf ipv4-address {
      type inet:ipv4-address;
    leaf subnet-mask-length {
      type uint8 {
        range "0..32";

Our data model now defines a compound document which contains nodes in the namespaces of both contributing modules, acme-system and extra-interface-data.

Generating the Schemas

The DSDL schemas can be generated quite easily (at least on Linux and Unix systems) from the two YANG modules by using the yang2dsdl shell script which is provided with the pyang distribution. The details about its usage can be found in the manual page or by running yang2dsdl -h.

But before we start, we need to decide which target document type the generated schemas are to address. Currently, yang2dsdl supports the following targets that are selected via the -t command line option:

raw datastore content;
a complete NETCONF message containing a reply to operation;
a complete NETCONF message containing a reply to <get-config> operation;
An RPC request defined in the input YANG module(s);
An RPC reply defined in the input YANG module(s);
An event notification defined in the input YANG module(s).

Only the first three targets make sense in our case as our YANG modules define neither RPC operations nor event notifications. Moreover, there are no operational state data or statistics in our modules, so the replies to and <get-config> are bound to be identical.

Another technical detail to consider are the file names in which the output schemas will be stored.

All right, let's begin with the "dstore" target. We needn't use the -t option here as "dstore" is the default:

$ yang2dsdl -b aug-acme-system acme-system.yang extra-interface-data.yang
== Generating RELAX NG schema './aug-acme-system-dstore.rng'

== Generating Schematron schema './aug-acme-system-dstore.sch'

== Generating DSRL schema './aug-acme-system-dstore.dsrl'

An Instance Configuration Datastore


Looking under the Hood

Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r12 | r4 < r3 < r2 < r1 | More topic actions...
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback