TOC |
|
This Internet-Draft is submitted to IETF in full conformance with the provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering Task Force (IETF), its areas, and its working groups. Note that other groups may also distribute working documents as Internet-Drafts.
Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as “work in progress.”
The list of current Internet-Drafts can be accessed at http://www.ietf.org/ietf/1id-abstracts.txt.
The list of Internet-Draft Shadow Directories can be accessed at http://www.ietf.org/shadow.html.
This Internet-Draft will expire on August 16, 2009.
Copyright (c) 2009 IETF Trust and the persons identified as the document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents in effect on the date of publication of this document (http://trustee.ietf.org/license-info). Please review these documents carefully, as they describe your rights and restrictions with respect to this document.
This draft describes the mapping rules for translating YANG data models into XML schemas using Document Schema Definition Languages (DSDL).
1.
Introduction
2.
Objectives and Motivation
3.
DSDL Schema Languages
3.1.
RELAX NG
3.2.
Schematron
3.3.
Document Schema Renaming Language (DSRL)
4.
Additional Annotations
4.1.
Dublin Core Metadata Elements
4.2.
RELAX NG DTD Compatibility Annotations
4.3.
NETMOD-specific Annotations
5.
Overview of the Mapping
6.
Design Considerations
6.1.
Conceptual Data Tree
6.2.
Modularity
6.3.
Granularity
7.
Mapping Data Model Structure to the Conceptual Tree Schema
7.1.
Optional and Mandatory Content
7.2.
Mapping YANG Groupings and Typedefs
7.2.1.
YANG Refinements and Augments
7.2.2.
Type derivation chains
7.3.
Translation of XPath Expressions
7.4.
YANG Language Extensions
7.5.
RPC Signatures and Notifications
8.
Mapping Conceptual Tree Schema to DSDL
8.1.
Mapping Semantic Constraints to Schematron
8.1.1.
Library of Schema-independent Schematron Patterns
8.2.
Mapping Default Values to DSRL
9.
NETCONF Content Validation
9.1.
Validation Phases
10.
Mapping YANG Statements to Annotated RELAX NG
10.1.
The anyxml Statement
10.2.
The argument Statement
10.3.
The augment Statement
10.4.
The base Statement
10.5.
The belongs-to Statement
10.6.
The bit Statement
10.7.
The case Statement
10.8.
The choice Statement
10.9.
The config Statement
10.10.
The contact Statement
10.11.
The container Statement
10.12.
The default Statement
10.13.
The description Statement
10.14.
The enum Statement
10.15.
The error-app-tag Statement
10.16.
The error-message Statement
10.17.
The extension Statement
10.18.
The grouping Statement
10.19.
The identity Statement
10.20.
The import Statement
10.21.
The include Statement
10.22.
The input Statement
10.23.
The key Statement
10.24.
The leaf Statement
10.25.
The leaf-list Statement
10.26.
The length Statement
10.27.
The list Statement
10.28.
The mandatory Statement
10.29.
The max-elements Statement
10.30.
The min-elements Statement
10.31.
The module Statement
10.32.
The must Statement
10.33.
The namespace Statement
10.34.
The notification Statement
10.35.
The ordered-by Statement
10.36.
The organization Statement
10.37.
The output Statement
10.38.
The path Statement
10.39.
The pattern Statement
10.40.
The position Statement
10.41.
The prefix Statement
10.42.
The presence Statement
10.43.
The range Statement
10.44.
The reference Statement
10.45.
The require-instance Statement
10.46.
The revision Statement
10.47.
The rpc Statement
10.48.
The status Statement
10.49.
The submodule Statement
10.50.
The type Statement
10.50.1.
The empty Type
10.50.2.
The boolean and binary Types
10.50.3.
The bits Type
10.50.4.
The enumeration and union Types
10.50.5.
The identityref Type
10.50.6.
The instance-identifier Type
10.50.7.
The leafref Type
10.50.8.
The numeric Types
10.50.9.
The string Type
10.50.10.
Derived Types
10.51.
The typedef Statement
10.52.
The unique Statement
10.53.
The units Statement
10.54.
The uses Statement
10.55.
The value Statement
10.56.
The when Statement
10.57.
The yang-version Statement
10.58.
The yin-element Statement
11.
Mapping NETMOD-specific annotations to Schematron
and DSRL
12.
IANA Considerations
13.
References
Appendix A.
RELAX NG Schema for NETMOD-specific Annotations
A.1.
XML Syntax
A.2.
Compact Syntax
Appendix B.
Schematron Library
Appendix C.
Translation of the DHCP Data Model
C.1.
XML Syntax
C.2.
Compact Syntax
§
Authors' Addresses
TOC |
The NETCONF Working Group has completed a base protocol used for configuration management [1] (Enns, R., “NETCONF Configuration Protocol,” December 2006.). This base specification defines protocol bindings and an XML container syntax for configuration and management operations, but does not include a modeling language or accompanying rules for how to model configuration and status information (in XML syntax) carried by NETCONF. The IETF Operations Area has a long tradition of defining data for SNMP Management Information Bases (MIBs) [2] (Case, J., Fedor, M., Schoffstall, M., and J. Davin, “Simple Network Management Protocol (SNMP),” May 1990.) using the SMI language [3] (McCloghrie, K., Ed., Perkins, D., Ed., and J. Schoenwaelder, Ed., “Structure of Management Information Version 2 (SMIv2),” April 1999.) to model its data. While this specific modeling approach has a number of well-understood problems, most of the data modeling features provided by SMI are still considered extremely important. Simply modeling the valid syntax rather than additional semantic relationships has caused significant interoperability problems in the past.
The NETCONF community concluded that a data modeling framework is needed to support ongoing development of IETF and vendor-defined management information modules. The NETMOD Working Group was chartered to address this problem, by defining a new human-friendly modeling language based on SMIng [4] (Elliott, C., Harrington, D., Jason, J., Schoenwaelder, J., Strauss, F., and W. Weiss, “SMIng Objectives,” December 2001.) and called YANG [5] (Bjorklund, M., Ed., “YANG - A data modeling language for NETCONF,” January 2009.).
Since NETCONF uses XML for encoding its protocol data units (PDU), it is natural to express the constraints on NETCONF content using standard XML schema languages. For this purpose, the NETMOD WG selected the Document Schema Definition Languages (DSDL) that is being standardized as ISO/IEC 19757 [6] (ISO/IEC, “Document Schema Definition Languages (DSDL) - Part 1: Overview,” 11 2004.). The DSDL framework comprises a set of XML schema languages that address grammar rules, semantic constraints and other data modeling aspects but also, and more importantly, do it in a coordinated and consistent way. While it is true that some DSDL parts have not been standardized yet and are still work in progress, the three parts that the YANG-to-DSDL mapping relies upon - RELAX NG, Schematron and DSRL - already have the status of an ISO/IEC International Standard and are supported in a number of software tools.
This document contains the specification of a mapping that translates YANG data models to XML schemas utilizing a subset of the DSDL schema languages. The mapping procedure is divided into two steps: In the first step, the structure of the data tree, RPC signatures and notifications is expressed as a single RELAX NG grammar with simple annotations representing additional data model information (metadata, documentation, semantic constraints, default values etc.). The second step then generates a coordinated set of DSDL schemas that can validate specific XML documents such as client requests, server responses or notifications, perhaps also taking into account additional context such as active capabilities.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [7] (Bradner, S., “Key words for use in RFCs to Indicate Requirement Levels,” March 1997.).
In the text, we also use the following typographic conventions:
XML elements names are always written with explicit namespace prefixes corresponding to the following XML vocabularies:
- a
- DTD compatibility annotations [8] (Clark, J., Ed. and M. Murata, Ed., “RELAX NG DTD Compatibility,” December 2001.)
- dc
- Dublin Core metadata elements
- nc
- NETCONF protocol [1] (Enns, R., “NETCONF Configuration Protocol,” December 2006.)
- nma
- NETMOD-specific schema annotations
- nmt
- Conceptual tree
- dsrl
- Document Schema Renaming Language[9] (ISO/IEC, “Information Technology - Document Schema Definition Languages (DSDL) - Part 8: Document Semantics Renaming Language - DSRL,” 12 2008.)
- rng
- RELAX NG[10] (ISO/IEC, “Information Technology - Document Schema Definition Languages (DSDL) - Part 2: Regular-Grammar-Based Validation - RELAX NG. Second Edition.,” 12 2008.)
- sch
- ISO Schematron[11] (ISO/IEC, “Information Technology - Document Schema Definition Languages (DSDL) - Part 3: Rule-Based Validation - Schematron,” 6 2006.)
- xsd
- W3C XML Schema[12] (Thompson, H., Beech, D., Maloney, M., and N. Mendelsohn, “XML Schema Part 1: Structures Second Edition,” October 2004.)
The following table shows the mapping of these prefixes to namespace URIs.
Prefix | Namespace URI |
---|---|
a | http://relaxng.org/ns/compatibility/annotations/1.0 |
dc | http://purl.org/dc/terms |
nc | urn:ietf:params:xml:ns:netconf:base:1.0 |
nma | urn:ietf:params:xml:ns:netmod:dsdl-annotations:1 |
nmt | urn:ietf:params:xml:ns:netmod:conceptual-tree:1 |
dsrl | http://purl.oclc.org/dsdl/dsrl |
rng | http://relaxng.org/ns/structure/1.0 |
sch | http://purl.oclc.org/dsdl/schematron |
xsd | http://www.w3.org/2001/XMLSchema |
Table 1: Used namespace prefixes and corresponding URIs |
TOC |
The main objective of this work is to complement YANG as a data modeling language by validation capabilities of DSDL schema languages, primarily RELAX NG and Schematron. This document describes the correspondence between grammatical, semantic and data type constraints expressed in YANG and equivalent DSDL constructs. The ultimate goal is to be able to capture all substantial information contained in YANG modules and express it in DSDL schemas. While the mapping from YANG to DSDL described in this document is in principle invertible, the inverse mapping from DSDL to YANG is not in its scope.
XML-encoded data appear in several different forms in various phases of the NETCONF workflow - configuration datastore contents, RPC requests and replies, and notifications. Moreover, RPC methods are characterized by an inherent diversity resulting from selective availability of capabilities and features. YANG modules can also define new RPC methods. The mapping should be able to accommodate this variability and generate schemas that are specifically tailored to a particular situation and thus considerably more efficient than generic all-encompassing schemas.
In order to cope with this variability, we assume that the schemas can be generated on demand from the available collection of YANG modules and their lifetime will be relatively short. In other words, we don't envision that any collection of DSDL schemas will be created and maintained over extended periods of time in parallel to YANG modules.
The generated schemas are primarily intended as input to the existing XML schema validators and other off-the-shelf tools. However, the schemas may also be perused by developers and users as a formal representation of constraints on a particular XML-encoded data object. Consequently, our secondary goal is to keep the schemas as readable as possible. To this end, the complexity of the mapping is distributed into two steps:
TOC |
The mapping described in this document uses three of the DSDL schema languages, namely RELAX NG, Schematron and DSRL.
TOC |
RELAX NG (pronounced "relaxing") is an XML schema language for grammar-based validation and Part 2 of the ISO/IEC DSDL family of standards [10] (ISO/IEC, “Information Technology - Document Schema Definition Languages (DSDL) - Part 2: Regular-Grammar-Based Validation - RELAX NG. Second Edition.,” 12 2008.). Like the W3C XML Schema language [12] (Thompson, H., Beech, D., Maloney, M., and N. Mendelsohn, “XML Schema Part 1: Structures Second Edition,” October 2004.), it is able to describe constraints on the structure and contents of XML documents. However, unlike the DTD [13] (Bray, T., Paoli, J., Sperberg-McQueen, C., Maler, E., and F. Yergeau, “Extensible Markup Language (XML) 1.0 (Fourth Edition),” August 2006.) and XSD schema languages, RELAX NG intentionally avoids any infoset augmentation such as defining default values. In the DSDL architecture, the particular task of defining and applying default values is delegated to another schema language, DSRL (see Section 3.3 (Document Schema Renaming Language (DSRL))).
As its base datatype library, RELAX NG uses the W3C XML Schema Datatype Library [14] (Biron, P. and A. Malhotra, “XML Schema Part 2: Datatypes Second Edition,” October 2004.), but unlike XSD, other datatype libraries may be used along with it or even replace it if necessary.
RELAX NG is very liberal in accepting annotations from other namespaces. With few exceptions, such annotations may be placed anywhere in the schema and need no encapsulating element such as <xsd:annotation> in XSD.
RELAX NG schema can be represented using two equivalent syntaxes: XML and compact. The compact syntax is described in Annex C of the RELAX NG specification [15] (ISO/IEC, “Information Technology - Document Schema Definition Languages (DSDL) - Part 2: Regular-Grammar-Based Validation - RELAX NG. AMENDMENT 1: Compact Syntax,” 1 2006.), which was added to the standard in 2006 (Amendment 1). Automatic bidirectional conversions between the two syntaxes can be accomplished using for example Trang.
For its terseness and readability, the compact syntax is often the preferred form for publishing RELAX NG schemas whereas validators and other software tools generally require the XML syntax. However, the compact syntax has two drawbacks:
For these reasons, the mapping specification in this document use exclusively the XML syntax. Where appropriate, though, the schemas resulting from the translation may be presented in the equivalent compact syntax.
RELAX NG elements are qualified with the namespace URI "http://relaxng.org/ns/structure/1.0". The namespace of the W3C Schema Datatype Library is "http://www.w3.org/2001/XMLSchema-datatypes".
TOC |
Schematron is Part 3 of DSDL that reached the status of a full ISO/IEC standard in 2006 [11] (ISO/IEC, “Information Technology - Document Schema Definition Languages (DSDL) - Part 3: Rule-Based Validation - Schematron,” 6 2006.). In contrast to the traditional schema languages such as DTD, XSD or RELAX NG, which are based on the concept of a formal grammar, Schematron utilizes a rule-based approach. Its rules may specify arbitrary conditions involving data from different parts of an XML document. Each rule consists of three essential parts:
The difference between the assert and report condition is that the former is positive in that it states a condition that a valid document has to satisfy, whereas the latter specifies an error condition. The mapping described in this document uses exclusively the positive (assert) form.
Schematron draws most of its expressive power from XPath [16] (Clark, J. and S. DeRose, “XML Path Language (XPath) Version 1.0,” November 1999.) and XSLT [17] (Clark, J., “XSL Transformations (XSLT) Version 1.0,” November 1999.). ISO Schematron allows for dynamic query language binding so that the following XML query languages can be used: STX, XSLT 1.0, XSLT 1.1, EXSLT, XSLT 2.0, XPath 1.0, XPath 2.0 and XQuery 1.0 (this list may be extended in future).
The human-readable error messages are another feature that distinguishes Schematron from other schema languages such as RELAX NG or XSD. The messages may even contain XPath expressions that are evaluated in the actual context and thus refer to existing XML document nodes and their content.
ISO Schematron introduced the concept of abstract patterns whose purpose is similar to functions in programming languages. The mapping described in this document uses a library of abstract patterns for specifying generic constraints such as uniqueness of certain leaf values in list items.
The rules defined by a Schematron schema may be divided into several subsets known as phases. Validations may then be set up to include only selected phases. In the context of NETCONF data validation, this is useful for relaxing constraints that may not always apply. For example, the reference integrity may not be enforced for a candidate configuration.
Schematron elements are qualified with namespace URI "http://purl.oclc.org/dsdl/schematron".
TOC |
DSRL (pronounced "disrule") is Part 8 of DSDL that reached the status of a full ISO/IEC standard in 2008 [9] (ISO/IEC, “Information Technology - Document Schema Definition Languages (DSDL) - Part 8: Document Semantics Renaming Language - DSRL,” 12 2008.). Unlike RELAX NG and Schematron, it is specifically designed to modify XML information set of the validated document. The primary application for DSRL is renaming XML elements and attributes. DSRL can also define default values for XML attributes and elements so that elements or attributes with these default values are inserted if they are missing in the validated documents. The latter feature is used by the YANG-to-DSDL mapping for representing YANG defaults for leaf nodes.
DSRL elements are qualified with namespace URI "http://purl.oclc.org/dsdl/dsrl".
TOC |
In addition to the DSDL schema languages, the mapping uses three sets of annotations that are added as foreign-namespace elements and attributes to RELAX NG schemas. Two of the annotation sets - Dublin Core elements and DTD compatibility annotations - are standard vocabularies for representing metadata and documentation, respectively. While these data model items may not be used for formal validation, they quite often carry important information. Therefore, they SHOULD be included in the conceptual tree schema and MAY also appear in the final validation schemas.
The third set are NETMOD-specific annotations conveying semantic constraints and other information that cannot be expressed natively in RELAX NG. These annotations are only used in the first step of the mapping, i.e., in the conceptual tree schema. In the second mapping step, these annotations are converted to Schematron and DSRL rules.
TOC |
Dublin Core is a system of metadata elements that was originally created for describing metadata of World Wide Web resources in order to facilitate their automated lookup. Later it was accepted as a standard for describing metadata of arbitrary resources. This specification uses the definition found in [18] (Kunze, J., “The Dublin Core Metadata Element Set,” August 2007.).
Dublin Core elements are qualified with namespace URI "http://purl.org/dc/terms".
TOC |
DTD compatibility annotations are part of the RELAX NG DTD Compatibility specification [8] (Clark, J., Ed. and M. Murata, Ed., “RELAX NG DTD Compatibility,” December 2001.). The YANG-to-DSDL mapping uses only the <a:documentation> annotation for representing YANG 'description' and 'reference' texts.
Note that there is no intention to make the resulting schemas DTD-compatible, the main reason for using these annotations is technical: it is well supported and adequately interpreted by several RELAX NG tools.
DTD compatibility annotations are qualified with namespace URI "http://relaxng.org/ns/compatibility/annotations/1.0".
TOC |
NETMOD-specific annotations are XML elements and attributes qualified with the namespace URI "urn:ietf:params:xml:ns:netmod:dsdl-annotations:1" that appear in various locations in the conceptual tree schema. YANG statements are mapped to these annotations in a very straightforward way. In particular, the annotation attributes and elements always have the same name as the corresponding YANG statement.
Table 2 (NETMOD-specific annotations) lists alphabetically the names of NETMOD-specific annotation elements (in angle brackets) and attributes (prefixed with "@") along with a reference to the section where their use is described. Appendix A (RELAX NG Schema for NETMOD-specific Annotations) then contains the RELAX NG schema of this annotation vocabulary.
annotation | section | note |
---|---|---|
@nma:config | 10.9 (The config Statement) | |
@nma:default | 10.12 (The default Statement) | |
@nma:default-case | 10.7 (The case Statement) | |
<nma:error-app-tag> | 10.15 (The error-app-tag Statement) | 1 |
<nma:error-message> | 10.16 (The error-message Statement) | 1 |
<nma:instance-identifier> | 10.50.6 (The instance-identifier Type) | 2 |
@nma:key | 10.23 (The key Statement) | |
<nma:leafref> | 10.50.7 (The leafref Type) | 2 |
@nma:min-elements | 10.25 (The leaf-list Statement) | |
@nma:max-elements | 10.25 (The leaf-list Statement) | |
<nma:must> | 10.32 (The must Statement) | 3 |
@nma:ordered-by | 10.35 (The ordered-by Statement) | |
@nma:status | 10.48 (The status Statement) | |
@nma:unique | 10.48 (The status Statement) | |
@nma:units | 10.48 (The status Statement) | |
@nma:when | 10.56 (The when Statement) |
Table 2: NETMOD-specific annotations |
Notes:
TOC |
This section gives an overview of the YANG-to-DSDL mapping, its inputs and outputs. Figure 1 (Structure of the mapping) presents an overall structure of the mapping:
+----------------+ | YANG module(s) | +----------------+ | |T | +---------------------------------+ | DSDL schema for conceptual tree | +---------------------------------+ / | | \ +-------+ / | | \ |library| Td/ Ts| |Tc \ +-------+ / | | \ +---------+ +------+ +------+ +------+ |datastore| |server| |client| | .... | +---------+ +------+ +------+ +------+
Figure 1: Structure of the mapping |
The mapping procedure is divided into two steps:
An implementation of the mapping algorithm accepts one or more valid YANG modules as its input. It is important to be able to process multiple YANG modules together since multiple modules may be negotiated for a NETCONF session and the contents of the configuration datastore is then obtained as the union of data trees specified by the individual modules, perhaps with multiple root nodes. In addition, the input modules may be further coupled by the 'augment' statement in which one module augments the data tree of another module.
It is also assumed that the algorithm has access, perhaps on demand, to all YANG modules that the module(s) imports (transitively).
The output of the first mapping step is an annotated RELAX NG schema for the conceptual tree, which represents a virtual XML document containing, in its different subtrees, the entire datastore, all RPC requests and replies, and notifications defined by the input YANG modules. By "virtual" we mean that such an XML document need not correspond to the actual layout of the configuration database in a NETCONF agent, and will certainly never appear on the wire as the content of a NETCONF PDU. Hence, the RELAX NG schema for the conceptual tree is not intended for any direct validations but rather as a representation of a particular data model expressed in RELAX NG and the common starting point for subsequent transformations that will typically produce validation schemas. The conceptual tree is further described in Section 6.1 (Conceptual Data Tree).
Other information contained in input YANG modules, such as semantic constraints or default values, are recorded as annotations - XML elements or attributes qualified with namespace URI "urn:ietf:params:xml:ns:netmod:dsdl-annotations:1". Metadata describing the YANG modules are mapped to annotations utilizing Dublin Core elements (Section 4.1 (Dublin Core Metadata Elements)). Finally, documentation strings are mapped to the <a:documentation> element belonging to the DTD compatibility vocabulary (Section 4.2 (RELAX NG DTD Compatibility Annotations)).
The output from the second step is is a coordinated set of three DSDL schemas corresponding to a specific data object and context:
An implementation SHOULD allow for selecting a subset of schema languages and annotation types to be used for output. For example, a user might want to select pure RELAX NG without any annotations.
TOC |
YANG modules could be mapped to DSDL schemas in a number of ways. The mapping procedure described in this document uses several specific design decisions that are discussed in the following subsections.
TOC |
DSDL schemas generated from YANG modules using the procedure described in this document are intended to be used for validating XML-encoded NETCONF data in various forms (full datastore and several types of PDUs): every YANG-based model represents the contents of a full datastore but also implies an array of schemas for all types of NETCONF PDUs. For a reasonably strict validation of a given data object, the schemas have to be quite specific. To begin with, effective validation of NETCONF PDU content requires separation of client and server schemas. However, the decision about proper structuring of all PDU-validating schemas is beyond the scope of this document. However, the mapping procedure described in this document is designed to accommodate any foreseeable validation needs.
An essential part of the YANG-to-DSDL mapping procedure is nonetheless common to all validation approaches: the schemas for the datastore, RPCs and notifications expressed by one or more YANG modules have to be translated to RELAX NG. In order to be able to separate this common step, we introduce the notion of conceptual data tree: it is a virtual XML tree that contains full datastore, RPC requests with corresponding replies and notifications. The schema for the conceptual tree - a single RELAX NG schema with annotations - therefore has a quite similar logic as the input YANG module(s), the only major difference being the RELAX NG schema language.
The conceptual data tree may be schematically represented as follows:
<nmt:netmod-tree xmlns:nmt="urn:ietf:params:xml:ns:netmod:conceptual-tree:1"> <nmt:main> ... configuration and status data ... </nmt:main> <nmt:rpc-methods> <nmt:rpc-method name="..."> <nmt:input> ... </nmt:input> <nmt:output> ... </nmt:output> </nmt:rpc-method> ... </nmt:rpcs> <nmt:notifications> <nmt:notification name="..."> ... </nmt:notification> ... </nmt:notifications> </nmt:netmod>
The namespace URI "urn:ietf:params:xml:ns:netmod:tree:1" identifies a simple vocabulary consisting of a few elements that encapsulate and separate the various parts of the conceptual data tree.
The conceptual tree schema is not intended for direct validation but rather serves as a well-defined starting point for subsequent transformations that generate various validation schemas. Such transformations should be relatively simple, they will typically extract one or several subtrees from the conceptual tree schema, modify them as necessary and add encapsulating elements such as those from the NETCONF RPC layer.
Additional information contained in the source YANG module(s), such as semantic constraints and default values, is represented in the form of interim annotations that are included as foreign-namespace elements or attributes in the RELAX NG schema for the conceptual tree. In the second phase of the mapping, the interim annotations are extracted and translated to equivalent Schematron and DSRL rules.
As a useful side effect, by introducing the conceptual data tree we are also able to resolve the difficulties stemming from the fact that a single configuration repository may consist of multiple parallel data hierarchies defined in one or more YANG modules, which cannot be mapped to a valid XML document. In the conceptual data tree, such multiple hierarchies appear under the single <nmt:main> element.
TOC |
Both YANG and RELAX NG offer means for modularity, i.e., for splitting the contents into separate modules (schemas) and combining or reusing them in various ways. However, the approaches taken by YANG and RELAX NG differ. Modularity in RELAX NG is suitable for ad hoc combinations of a small number of schemas whereas YANG assumes a large set of modules similar to SNMP MIBs. The following differences are important:
So the conclusion is that the modularity mechanisms of YANG and RELAX NG, albeit similar, are not directly compatible. Therefore, the corresponding design decision for the mapping algorithm is to collect all information in a single schema for the conceptual tree, even if it comes from multiple YANG modules or submodules. In other words, translations of imported groupings and typedefs are installed in the translation of importing module - but only if they are really used there.
NOTE: The 'include' statement that is used in YANG for including submodules has in fact the same semantics as the <rng:include> pattern. However, since we don't map the modular structure for YANG modules, it seems to have little sense to do it for submodules. Consequently, the contents of submodules appear directly in the conceptual tree schema, too.
TOC |
RELAX NG supports different styles of schema structuring: One extreme, often called "Russian Doll", specifies the structure of an XML instance document in a single hierarchy. The other extreme, the flat style, uses a similar approach as the Data Type Definition (DTD) schema language - every XML element is introduced inside a new named pattern. In practice, some compromise between the two extremes is usually chosen.
YANG supports both styles in principle, too, but in most cases the modules are organized in a way that's closer to the "Russian Doll" style, which provides a better insight into the structure of the configuration data. Groupings are usually defined only for contents that are prepared for reuse in multiple places via the 'uses' statement. In contrast, RELAX NG schemas tend to be much flatter, because finer granularity is also needed in RELAX NG for extensibility of the schemas - it is only possible to replace or modify schema fragments that are factored out as named patterns. For YANG this is not an issue since its 'augment' and 'refine' statements can delve, by using path expressions, into arbitrary depths of existing structures.
In general, it not feasible to map YANG extension mechanisms to those of RELAX NG. For this reason, the mapping essentially keeps the granularity of the original YANG data model: definitions of named patterns in the resulting RELAX NG schema usually have direct counterparts in YANG groupings and definitions of derived types.
TOC |
This section explains the main principles underlying the first step of the mapping. Details about mapping individual YANG statements are contained in Section 10 (Mapping YANG Statements to Annotated RELAX NG).
TOC |
In YANG, all leaf nodes are optional unless they contain substatement
mandatory true;
or unless they are declared as list keys.
Lists or leaf-lists are optional unless they contain 'min-elements' substatement with argument value greater than zero.
A slightly more complicated situation arises for YANG containers. First, containers with the 'presence' substatement are always optional since their presence or absence carries specific information. On the other hand, non-presence containers may be omitted if they are empty. For the purposes of the YANG-to-DSDL mapping, we declare a non-presence container as optional if and only if the following two conditions hold:
In RELAX NG, all elements that are optional must be explicitly wrapped in the <rng:optional> element. The mapping algorithm thus uses the above rules to determine whether a YANG node is optional and if so, insert the <rng:optional> element in the RELAX NG schema.
TOC |
YANG groupings and typedefs are generally mapped to RELAX NG named patterns. There are, however, several caveats that the mapping has to take into account.
First of all, YANG typedefs and groupings may appear at all levels of the module hierarchy and are subject to lexical scoping, see [5] (Bjorklund, M., Ed., “YANG - A data modeling language for NETCONF,” January 2009.), Section 5.5. Moreover, top-level symbols from external modules are imported as qualified names represented using the external module namespace prefix and the name of the symbol. In contrast, named patterns in RELAX NG (both local and imported via the <rng:include> pattern) share the same namespace and within a grammar they are always global - their definitions may only appear at the top level as children of the <rng:grammar> element. Consequently, whenever YANG groupings and typedefs are mapped to RELAX NG named pattern definitions, their names MUST be disambiguated in order to avoid naming conflicts. The mapping uses the following procedure for mangling the names of groupings and type definitions:
For example, consider the following YANG module which imports the standard module "inet-types" [19] (Schoenwaelder, J., Ed., “Common YANG Data Types,” November 2008.):
module example1 { namespace "http://example.com/ns/example1"; prefix "ex1"; import "inet-types" { prefix "inet"; } typedef vowels { type string { pattern "[aeiouy]*"; } } grouping "grp1" { leaf "void" { type "empty"; } } container "cont" { grouping "grp2" { leaf "address" { type "inet:ip-address"; } } leaf foo { type vowels; } uses "grp1"; uses "grp2"; } }
The resulting RELAX NG schema will then contain the following named pattern definitions (long regular expression patterns for IPv4 and IPv6 addresses are not shown):
<rng:define name="example1__vowels"> <rng:data type="string"> <rng:param name="pattern">[aeiouy]*</param> </rng:data> </rng:define> <rng:define name="example1__grp1"> <rng:optional> <rng:element name="t:void"> <rng:empty/> </rng:element> </rng:optional> </rng:define> <rng:define name="example1__cont__grp2"> <rng:optional> <rng:element name="t:address"> <rng:ref name="inet-types__ip-address"/> </rng:element> </rng:optional> </rng:define> <rng:define name="inet-types__ip-address"> <rng:choice> <rng:ref name="inet-types__ipv4-address"/> <rng:ref name="inet-types__ipv6-address"/> </rng:choice> </rng:define> <rng:define name="inet-types__ipv4-address"> <rng:data type="string"> <rng:param name="pattern">... removed ...</param> </rng:data> </rng:define> <rng:define name="inet-types__ipv6-address"> <rng:data type="string"> <rng:param name="pattern">... removed ...</param> </rng:data> </rng:define>
TOC |
YANG groupings represent a similar concept as named pattern definitions in RELAX NG and both languages also offer mechanisms for their subsequent modification. However, in RELAX NG the definitions themselves are modified whereas YANG allows for modifying expansions of groupings. Specifically, YANG provides two statements for this purpose that may appear as substatements of 'uses':
Both 'refine' and 'augment' statements are quite powerful in that they can address, using a subset of XPath 1.0 expressions as arguments, schema nodes that are arbitrarily deep inside the grouping content. In contrast, definitions of named patterns in RELAX NG operate exclusively at the topmost level of the named pattern content. In order to achieve a modifiability of named patterns comparable to YANG, the RELAX NG schema would have to be extremely flat (cf. Section 6.3 (Granularity)) and very difficult to read.
Since the goal of the mapping described in this document is to generate ad hoc DSDL schemas, we decided to avoid these complications and instead expand the grouping and refine and/or augment it "in place". In other words, every 'uses' statement which has 'refine' and/or 'augment' substatements is virtually replaced by the content of the corresponding grouping, the changes specified in the 'refine' and 'augment' statements are applied and the resulting YANG schema fragment is mapped as if the 'uses'/'grouping' indirection wasn't there.
If there are further 'uses' statements inside the grouping content, they may require expansion, too: it is necessary if the contained 'uses'/'grouping' pair lies on the "modification path" specified in the argument of a 'refine' or 'augment' statement.
EXAMPLE. Consider the following YANG module:
module example2 { namespace "http://example.com/ns/example2"; prefix ex2; grouping leaves { uses fr; uses es; } grouping fr { leaf feuille { type string; } } grouping es { leaf hoja { type string; } } uses leaves; }
The resulting conceptual tree schema contains three named pattern definitions corresponding to the three groupings, namely
<rng:define name="example2__leaves"> <rng:ref name="example2__fr"/> <rng:ref name="example2__es"/> </rng:define> <rng:define name="example2__fr"> <rng:optional> <rng:element name="feuille"> <rng:data type="string"/> </rng:element> </rng:optional> </rng:define> <rng:define name="example2__es"> <rng:optional> <rng:element name="hoja"> <rng:data type="string"/> </rng:element> </rng:optional> </rng:define>
and the configuration data part of the conceptual tree schema will be a single named pattern reference:
<rng:ref name="example2__leaves"/>
Now assume that the "leave" expansion is refined:
uses leaves { refine "hoja" { default "alamo"; } }
The resulting conceptual tree schema now contains just one named pattern definition - "example__fr". The other two groupings "leaves" and "es" have to be expanded because they both lie on the "modification path", i.e., contain the leaf "hoja" that is being refined. The configuration data part of the conceptual tree now looks like this:
<rng:ref name="example2__fr"/> <rng:optional> <rng:element name="hoja" nma:default="alamo"> <rng:data type="string"/> </rng:element> </rng:optional>
TOC |
RELAX NG has no equivalent of the type derivation mechanism in YANG, where a base built-in type may be modified (in multiple steps) by adding new restrictions. Therefore, when mapping YANG derived types with restrictions, the derived types MUST be "unwound" all the way back to the base built-in type. At the same time, all restrictions found along the type derivation chain MUST be combined and their intersection used as facets restricting the corresponding type in RELAX NG.
When a derived YANG type is used without restrictions, the 'type' statement is mapped simply to the <rng:ref> element, i.e., a named pattern reference. However, if restrictions are specified as substatements of the 'type' statement, the type MUST be expanded at that point so that only the built-in type appears in the output schema, restricted with facets that again correspond to the combination of all restrictions found along the type derivation chain and also in the 'type' statement.
EXAMPLE. Consider this YANG module:
module example3 { namespace "http://example.com/ns/example3"; prefix ex3; typedef dozen { type uint8 { range 1..12; } } leaf month { type dozen; }
The 'type' statement in "leaf month" is mapped simply to the reference <rng:ref name="example__dozen"/> and the corresponding named pattern is defined as follows:
<rng:define name="example3__dozen"> <rng:data type="unsignedByte"> <rng:param name="minInclusive">1</param> <rng:param name="maxInclusive">12</param> </rng:data> </rng:define>
Assume now that the definition of leaf "month" is changed to
leaf month { type dozen { range 7..max; } }
The output RELAX NG schema then won't contain any named pattern definition and leaf "month" will be mapped directly to
<rng:element name="month"> <rng:data type="unsignedByte"> <rng:param name="minInclusive">7</param> <rng:param name="maxInclusive">12</param> </rng:data> </rng:element>
TOC |
YANG uses full XPath 1.0 syntax [16] (Clark, J. and S. DeRose, “XML Path Language (XPath) Version 1.0,” November 1999.) for the arguments of 'must' and 'when' statements and a subset thereof in several other statements. However, since the names of data nodes defined by YANG modules are always namespace qualified, YANG adopted a simplification similar to the concept of default namespace in XPath 2.0: node names needn't carry a namespace prefix inside the module where they are defined, in which case the module's namespace is assumed.
If an XPath expression is carried over to a NETMOD-specific annotation in the first mapping step, it MUST be translated into a fully conformant XPath 1.0 expression that also reflects the hierarchy of the conceptual data tree:
Translation rule 2 means that absolute XPath expressions appearing in the main configuration data tree always start with "nmt:netmod-tree/nmt:main/", those appearing in "my-notif" notification always start with "nmt:netmod-tree/nmt:notifications/nmt:notification[@name='my-notif']/", etc.
EXAMPLE. YANG XPath expression "/dhcp/max-lease-time" appearing in the main configuration data will be translated to "nmt:netmod-tree/nmt:main/dhcp:dhcp/dhcp:max-lease-time".
[Editor's note: We may want to introduce "$root" variable that always contains the appropriate partial path in conceptual tree. The translated XPath in the example would then become "$root/dhcp:dhcp/dhcp:max-lease-time".]
TOC |
YANG allows for extending its own language in-line by adding new statements with keywords from special namespaces. Such extensions first have to be declared using the 'extension' statement and then can be used as the native statements, only with a namespace prefix qualifying the extension keyword. RELAX NG has a similar extension mechanism - XML elements and attributes with names from foreign namespaces may be inserted at almost every place of a RELAX NG schema.
YANG language extensions may or may not have a meaning in the context of DSDL schemas. Therefore, an implementation MAY ignore any or all of the extensions. However, an extension that is not ignored MUST be mapped to XML element(s) and/or attribute(s) that exactly match the YIN form of the extension.
EXAMPLE. Consider the following extension defined by the "acme" module:
extension documentation-flag { argument number; }
This extension can then be used in the same or another module, for instance like this:
leaf folio { acme:documentation-flag 42; type string; }
If this extension is honored by the mapping, it will be mapped to
<rng:element name="folio"> <acme:documentation-flag number="42"/> <rng:data type="string"/> </rng:element>
Note that the 'extension' statement itself is not mapped in any way.
TOC |
In the conceptual tree schema, YANG definitions of RPC methods are mapped to the subtree under "/nmt:netmod-tree/nmt:rpc-methods". Each RPC method corresponds to one subelement of <nmt:rpc-methods>, namely <nmt:rpc-method name="..."> where the value of the @name attribute is set to the name of the method. In turn, the <nmt:rpc-method> element has two subelements, <nmt:input> and <nmt:output> (both are optional) that contain input and input parameters of the given RPC method, respectively.
Analogically, the content of each notification is mapped inside the element <nmt:notification name="...">, which is a subelement of "/nmt:netmod-tree/nmt:notifications".
TOC |
[Editor's note: This section is not finished yet. We need to write a mapping specification for each of the NETMOD-specific annotations.]
TOC |
TBD
TOC |
This section outlines the schema-independent library of Schematron patterns.
TBD
TOC |
TBD
TOC |
[Editor's note: This section is not finished yet. We have to figure out what are the NETCONF objects we want to validate, and also the validation contexts and modes. The concept of validation phases outlined below is just one part of the problem. However, these questions are not DSDL-specific and should be addressed by the WG. One issue is DSDL-specific though: we have to find a way for validating compound documents using both NETCONF and NETMOD schemas. NVDL is a good candidate.]
TOC |
Validation of a configuration datastore or NETCONF PDUs may occur in different logical phases, adding more tests with each phase. We use three levels or phases for validating an instance document. There is a level of validation which is appropriate even for loose XML document fragments which still maintain their hierarchy (fragment phase), another level of validation is appropriate for a cohesive XML document which may however not be able to validate relational integrity checks against some operational state (standard phase), and finally there is validation which cover everything including all relational integrity checks (full validation phase). For example, in NETCONF an edit-config operation can cause the replacement a small fragment of XML. A candidate configuration may be waiting for application but can't check the readiness of a piece of hardware that the configuration refers to.
From the NETCONF perspective, these three phases can be considered to have the following scope:
During the Fragment phase validation it is verified that the content is well-formed and appropriate to the operation.
During Standard phase validation (all rules except for leafref checking):
During Full phase validation: add leafref checks.
The mechanism how the phase specification is passed to the Schematron validator is outside the scope of this document. For example, it can be accomplished via command line parameters.
<sch:phase id="fragment"> <sch:active pattern="lease-time"/> <sch:active pattern="nonconfig"/> </sch:phase> <sch:phase id="std"> <sch:active pattern="lease-time"/> <sch:active pattern="nonconfig"/> <sch:active pattern="key"/> </sch:phase> <sch:phase id="full"> <sch:active pattern="lease-time"/> <sch:active pattern="nonconfig"/> <sch:active pattern="key"/> <sch:active pattern="keyref"/> </sch:phase>
TOC |
Each subsection in this section is devoted to one YANG statement and describes how the statement is mapped to the annotated RELAX NG schema of the conceptual tree. This is the first step of the mapping procedure, see Section 5 (Overview of the Mapping). The subsections are sorted alphabetically by the statement keyword.
Each YANG statement is mapped to an XML fragment, typically a single element or attribute but it may also be a larger structure. The mapping algorithm is inherently recursive, which means that after finishing a statement the mapping continues with its substatements, if there are any, and a certain element of the resulting fragment becomes the parent of other fragments resulting from the mapping of substatements. We use the following notation:
TOC |
This statement is mapped to <rng:element> element and ARGUMENT becomes the value of its @name attribute. The content of <rng:element> is
<rng:ref name="__anyxml__"/>
Substatements of the 'anyxml' statement are mapped to additional children of the RELAX NG element definition.
If the 'anyxml' statement occurs in any of the input YANG modules, the following pattern definition MUST be added exactly once to the RELAX NG schema as a child of the <rng:grammar> element (cf. [20] (van der Vlist, E., “RELAX NG,” 2004.), p. 172):
<rng:define name="__anyxml__"> <rng:zeroOrMore> <rng:choice> <rng:attribute> <rng:anyName/> </rng:attribute> <rng:element> <rng:anyName/> <rng:ref name="__anyxml__"/> </rng:element> <rng:text/> </rng:choice> </rng:zeroOrMore> </rng:define>
EXAMPLE: YANG statement
anyxml data { description "Any XML content allowed here."; }
maps to the following fragment:
<rng:element name="data"> <a:documentation>Any XML content allowed here</a:documentation> <rng:ref name="__anyxml__"/> </rng:element>
TOC |
This statement is not mapped to the output schema, but see the rules for extension handling in Section 7.4 (YANG Language Extensions).
TOC |
As a substatement of 'uses', this statement is handled as a part of 'uses' mapping, see Section 10.54 (The uses Statement).
At the top level of a module or submodule, the 'augment' statement is used for augmenting the schema tree of another YANG module. If the latter module is not processed within the same mapping session, the top-level 'augment' statement MUST be ignored. Otherwise, the contents of the statement are added to the foreign module with the namespace of the module where the 'augment' statement appears.
TOC |
This statement is ignored as a substatement of 'identity' and handled within the 'identityref' type if it appears as a substatement of that type definition, see Section 10.50.5 (The identityref Type).
TOC |
This statement is not used since processing of submodules is always initiated from the main module, see Section 10.21 (The include Statement).
TOC |
Handled within the "bits" type, see Section 10.50.3 (The bits Type).
TOC |
This statement is mapped to <rng:group> element. If the argument of a sibling 'default' statement equals to ARGUMENT, @nma:default-case attribute with the value of "true" is added to that <rng:group> element.
TOC |
This statement is mapped to <rng:choice> element.
Unless 'choice' has the 'mandatory' substatement with the value of "true", the <rng:choice> element MUST be wrapped in <rng:optional>.
TOC |
This statement is mapped to @nma:config attribute and ARGUMENT becomes its value.
TOC |
This statement is not used by the mapping since the output RELAX NG schema may result from multiple YANG modules created by different authors. The schema contains references to all input modules in the Dublin Core elements <dc:source>, see Section 10.31 (The module Statement). The original modules are the authoritative sources of the authorship information.
TOC |
Using the procedure outlined in Section 7.1 (Optional and Mandatory Content), the mapping algorithm MUST determine whether the statement defines an optional container, and if so, insert the <rng:optional> element and make it the new PARENT.
The container defined by this statement is then mapped to the <rng:element> element, which becomes a child of PARENT and uses ARGUMENT as the value of its @name attribute.
TOC |
If this statement is a substatement of 'typedef' or 'leaf', it is mapped to the @nma:default attribute of PARENT and ARGUMENT becomes its value.
As a substatement of 'choice', the 'default' statement identifies the default case and is handled within the 'case' statement, see Section 10.7 (The case Statement). If the default case uses the shorthand notation where the 'case' statement is omitted, an extra <rng:group> element MUST be inserted with @nma:default-case attribute set to "true". The net result is then the same as if the 'case' statement wasn't omitted for the default case.
EXAMPLE. The following 'choice' statement
choice leaves { default feuille; leaf feuille { type empty; } leaf hoja { type empty; } }
is mapped to
<rng:choice> <rng:group nma:default="true"> <rng:element name="feuille"> <rng:empty/> </rng:element> </rng:group> <rng:element name="hoja"> <rng:empty/> </rng:element/> </rng:choice>
TOC |
This statement is ignored if it appears at the top level of each input YANG module. The description can be found in the source module that is referred to by Dublin Core element <dc:source> and use ARGUMENT as its content.
Otherwise, this statement is mapped to the DTD compatibility element <a:documentation> and ARGUMENT becomes its text.
In order to get properly formatted in the RELAX NG compact syntax, this element SHOULD be inserted as the first child of PARENT.
TOC |
This statement is mapped to <rng:value> element and ARGUMENT becomes its text. All substatements except 'status' are ignored because the <rng:value> element cannot contain annotations, see [10] (ISO/IEC, “Information Technology - Document Schema Definition Languages (DSDL) - Part 2: Regular-Grammar-Based Validation - RELAX NG. Second Edition.,” 12 2008.), Section 6.
TOC |
This statement is ignored unless it is a substatement of 'must'. In the latter case it is mapped to the <nma:error-app-tag> element. See also Section 10.32 (The must Statement).
TOC |
This statement is ignored unless it is a substatement of 'must'. In the latter case it is mapped to the <nma:error-message> element. See also Section 10.32 (The must Statement).
TOC |
This statement is ignored. However, extensions to the YANG language MAY be mapped as described in Section 7.4 (YANG Language Extensions).
TOC |
This statement is mapped to a RELAX NG named pattern definition <rng:define>, but only if the grouping defined by this statement is used without refinements and augments in at least one of the input modules. In this case, the named pattern definition becomes a child of the <rng:grammar> element and its name is ARGUMENT mangled according to the rules specified in Section 7.2 (Mapping YANG Groupings and Typedefs).
Whenever a grouping is used with additional refinements and/or augments, the grouping is expanded so that the refinements and augments may be applied directly to the prescribed schema nodes. See Section 7.2.1 (YANG Refinements and Augments) for further details and an example.
An implementation MAY offer the option of recording all 'grouping' statements as named patterns in the output RELAX NG schema even if they are not referenced. This is useful for mapping YANG "library" modules containing only 'typedef' and/or 'grouping' statements.
TOC |
This statement is not specifically mapped. However, if the identity defined by this statement is used as the base for an "identityref" type in any of the input modules, ARGUMENT will appear as the text of one of the <rng:value> elements in the mapping of that "identityref" type. See Section 10.50.5 (The identityref Type) for more details and an example.
TOC |
This statement is not specifically mapped. The module whose name is in ARGUMENT has to be parsed so that the importing module be able to use its top-level groupings and typedefs and also augment the data tree of the imported module.
If the 'import' statement has the 'revision' substatement, the corresponding revision of the imported module MUST be used. The mechanism for finding a given module revision is outside the scope of this document.
TOC |
This statement is not specifically mapped. The submodule whose name is in ARGUMENT has to be parsed and its contents mapped exactly as if the submodule text was a subset of the main module text.
If the 'include' statement has the 'revision' substatement, the corresponding revision of the submodule MUST be used. The mechanism for finding a given submodule revision is outside the scope of this document.
TOC |
This statement is mapped to <rng:element> and its @name attribute is set to "nmt:input".
TOC |
This statement is mapped to @nma:key attribute and ARGUMENT becomes the value of this attribute.
TOC |
This statement is mapped to the <rng:element> element and ARGUMENT becomes the value of its @name attribute.
The leaf is optional if there is no "mandatory true;" substatement and if the leaf is not declared among the keys of an enclosing list. In this case, the <rng:element> element MUST be wrapped in <rng:optional>.
TOC |
This statement is mapped to a block enclosed by either <rng:zeroOrMore> or <rng:oneOrMore> element depending on whether the argument of 'min-elements' substatement is "0" or positive, respectively (it is zero by default). This <rng:zeroOrMore> or <rng:oneOrMore> element becomes the PARENT.
Further, if the argument of 'min-elements' is greater than one, attribute @nma:min-elements is attached to PARENT and the argument of 'min-elements' becomes the value of this attribute.
If there is the 'max-elements' substatement, attribute @nma:max-elements is attached to PARENT and the argument of 'max-elements' becomes the value of this attribute.
Then <rng:element> is added as a child element of PARENT and ARGUMENT becomes the value of its @name attribute.
EXAMPLE. YANG leaf-list
leaf-list foliage { min-elements 3; max-elements 6378; ordered-by user; type string; }
is mapped to the following RELAX NG fragment:
<rng:oneOrMore nma:max-elements="6378" nma:min-elements="3"> <rng:element name="foliage" nma:ordered-by="user"> <rng:data type="string"/> </rng:element> </rng:oneOrMore>
TOC |
Handled within the "string" type, see Section 10.50.9 (The string Type).
TOC |
This statement is mapped exactly as the 'leaf-list' statement, see Section 10.25 (The leaf-list Statement).
TOC |
This statement may appear as a substatement of 'leaf', 'choice' or 'anyxml' statement. If ARGUMENT is "true", the parent data node is mapped as mandatory, see Section 7.1 (Optional and Mandatory Content).
TOC |
This statement is handled within 'leaf-list' or 'list' statements, see Section 10.25 (The leaf-list Statement).
TOC |
This statement is handled within 'leaf-list' or 'list' statements, see Section 10.25 (The leaf-list Statement).
TOC |
This statement is not specifically mapped except that a <dc:source> element SHOULD be created as a child of <rng:grammar> and contain ARGUMENT as a reference to the input YANG module. See also Section 10.46 (The revision Statement).
With respect to the conceptual tree schema, substatements of 'module' MUST be mapped so that
TOC |
This statement is mapped to the <nma:must> element. It has one mandatory attribute @assert (with no namespace), which contains ARGUMENT transformed into a valid XPath expression (see Section 7.3 (Translation of XPath Expressions)). The <nma:must> element may get other subelements resulting from mapping 'error-app-tag' and 'error-message' substatements. Other substatements of 'must', i.e., 'description' and 'reference', are ignored.
EXAMPLE. YANG statement
must 'current() <= ../max-lease-time' { error-message "The default-lease-time must be less than max-lease-time"; }
is mapped to
<nma:must assert="current()<=../dhcp:max-lease-time"> <nma:error-message> The default-lease-time must be less than max-lease-time </nma:error-message> </nma:must>
TOC |
ARGUMENT of this statement - namespace URI of the input module - is mapped to an XML attribute of the <rng:grammar> element (the root of the RELAX NG schema) in the following way:
In case 2, names of all data nodes appearing as values of the @name attribute of the <rng:element> elements in the RELAX NG schema MUST use the given prefix whereas in case 1 the values have no prefix.
Namespace URI of all input modules MAY be mapped using the method in 2. The advantage of this approach is that the recommended prefixes are recorded in the output RELAX NG schema for all input modules.
EXAMPLE: Assume we have the following two YANG modules as input:
module foo-module { namespace "http://example.com/ns/foo"; prefix foo; ... }
and
module bar-module { namespace "http://example.com/ns/bar"; prefix bar; ... }
The <rng:grammar> element in the output schema may then be either
<rng:grammar xmlns="http://relaxng.org/ns/structure/1.0" xmlns:foo="http://example.com/ns/foo" xmlns:bar="http://example.com/ns/bar" ... > ... </rng:grammar>
or
<rng:grammar xmlns="http://relaxng.org/ns/structure/1.0" ns="http://example.com/ns/foo" xmlns:bar="http://example.com/ns/bar" ... > ... </rng:grammar>
The third possibility is analogical to the previous one, only with the roles of "foo" and "bar" exchanged.
TOC |
This element is mapped to <rng:element> and its @name attribute is set to "nmt:notification" element. This element is defined as a child of the <nmt:notifications> element in the conceptual tree.
TOC |
This statement is mapped to @nma:ordered-by attribute and ARGUMENT becomes the value of this attribute. See Section 10.25 (The leaf-list Statement) for an example.
TOC |
This statement is not used by the mapping since the output RELAX NG schema may result from multiple YANG modules authored by different parties. The schema contains references to all input modules in the Dublin Core elements <dc:source>, see Section 10.31 (The module Statement). The original modules are the authoritative sources of the authorship information.
TOC |
This statement is mapped to <rng:element> and its @name attribute is set to "nmt:output".
TOC |
Handled within "leafref" type, see Section 10.50.7 (The leafref Type).
TOC |
Handled within "string" type, see Section 10.50.9 (The string Type).
TOC |
This statement is ignored.
TOC |
ARGUMENT of this statement - the recommended namespace prefix for the input module - MAY be mapped to a namespace prefix declared using the @xmlns:xxx attribute of the <rng:grammar> element in the output schema, where "xxx" is replaced by ARGUMENT. For multiple input modules, the mapping of prefixes depends on how their namespace URIs are used, see Section 10.33 (The namespace Statement).
TOC |
This statement influences the mapping of 'container' (Section 10.11 (The container Statement)): it makes the parent container optional, regardless of its content. See also Section 7.1 (Optional and Mandatory Content).
TOC |
Handled within numeric types, see Section 10.50.8 (The numeric Types).
TOC |
This statement is ignored if it appears at the top level of a module or submodule.
Otherwise, this statement is mapped to <a:documentation> element and its text is set to ARGUMENT prefixed with "See: ".
TOC |
Handled within the types "leafref" (Section 10.50.7 (The leafref Type)) and "instance-identifier" (Section 10.50.6 (The instance-identifier Type)).
TOC |
The mapping uses only the most recent instance of the 'revision' statement, i.e., one with the latest date in ARGUMENT, which specifies the current revision of the input YANG module [5] (Bjorklund, M., Ed., “YANG - A data modeling language for NETCONF,” January 2009.). This date SHOULD be recorded, together with the name of the YANG module, in the corresponding Dublin Core element <dc:source> (see Section 10.31 (The module Statement)), for example in this form:
<dc:source>YANG module 'foo', revision 2009-01-19</dc:source>
The 'description' substatement of 'revision' is not used.
TOC |
This element is mapped to <rng:element> and its @name attribute is set to "nmt:rpc-method" element. This element is defined as a child of the <nmt:rpc-methods> element in the conceptual tree.
TOC |
This statement is mapped to @nma:status attribute and ARGUMENT becomes its value.
TOC |
This statement is not specifically mapped. Its substatements are mapped as if they appeared directly in the module the submodule belongs to.
TOC |
Most YANG built-in types have an equivalent in the XSD datatype library [14] (Biron, P. and A. Malhotra, “XML Schema Part 2: Datatypes Second Edition,” October 2004.) as shown in Table 3 (Selected datatypes from the W3C XML Schema Type Library).
YANG type | XSD type | Meaning |
---|---|---|
int8 | byte | 8-bit integer value |
int16 | short | 16-bit integer value |
int32 | int | 32-bit integer value |
int64 | long | 64-bit integer value |
uint8 | unsignedByte | 8-bit unsigned integer value |
uint16 | unsignedShort | 16-bit unsigned integer value |
uint32 | unsignedInt | 32-bit unsigned integer value |
uint64 | unsignedLong | 64-bit unsigned integer value |
float32 | float | 32-bit IEEE floating-point value |
float64 | double | 64-bit IEEE floating-point value |
string | string | character string |
boolean | boolean | "true" or "false" |
binary | base64Binary | binary data in base64 encoding |
Table 3: Selected datatypes from the W3C XML Schema Type Library |
Details about the mapping of individual YANG built-in types are given in the following subsections.
TOC |
This type is mapped to <rng:empty/>.
TOC |
These two built-in types do not allow any restrictions and are mapped simply by inserting <rng:data> element whose @type attribute is set to ARGUMENT mapped according to Table 3 (Selected datatypes from the W3C XML Schema Type Library).
TOC |
This type is mapped to <rng:list> and for each 'bit' substatement the following XML fragment is inserted as a child of <rng:list>:
<rng:optional> <rng:value>bit_name</rng:value> </rng:optional>
where bit_name is the name of the bit as found in the argument of the corresponding 'bit' statement.
TOC |
These types are mapped to <rng:choice> element.
TOC |
This type is mapped to <rng:choice> element with one or more <rng:value> subelements. Each of the <rng:value> subelements MUST have a @type attribute and its value set to "QName". One <rng:value> subelement with argument of the 'base' substatement as its text MUST always be present. In addition, one <rng:value> substatement MUST be added for each identity declared locally or in an imported module that has the argument of the 'base' substatement as its base identity.
All namespace prefixes that are used for identities from imported modules MUST be appropriately defined.
EXAMPLE (taken from [5] (Bjorklund, M., Ed., “YANG - A data modeling language for NETCONF,” January 2009.), Section 7.6.13). Consider the following two YANG modules:
module crypto-base { namespace "http://example.com/crypto-base"; prefix "crypto"; identity crypto-alg { description "Base identity from which all crypto algorithms are derived."; } } module des { namespace "http://example.com/des"; prefix "des"; import "crypto-base" { prefix "crypto"; } identity des { base "crypto:crypto-alg"; description "DES crypto algorithm"; } identity des3 { base "crypto:crypto-alg"; description "Triple DES crypto algorithm"; } }
If these two modules are imported to another module, leaf definition
leaf crypto { type identityref { base "crypto:crypto-alg"; } }
is mapped to
<rng:element name="crypto"> <rng:choice> <rng:value type="QName">crypto:crypto-alg</value> <rng:value type="QName">des:des</value> <rng:value type="QName">des:des3</value> </rng:choice> </rng:element>
The "crypto" and "des" prefixes will by typically defined via attributes of the <rng:grammar> element.
TOC |
This type is mapped to <rng:data> element with @type attribute set to "string". In addition, empty <nma:instance-identifier> element MUST be inserted as a child of PARENT.
The 'require-instance' substatement, if it exists, is mapped to the @require-instance attribute of <nma:instance-identifier>.
TOC |
This type is mapped to <rng:data> element with @type attribute set to the type of the leaf given in the argument of 'path' substatement. In addition, <nma:leafref> element MUST be inserted as a child of PARENT. The argument value of the 'path' substatement is set as the text of this element.
The 'require-instance' substatement, if it exists, is mapped to the @require-instance attribute of <nma:leafref>.
TOC |
YANG built-in numeric types are "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64", "float32" and "float64". They are mapped to <rng:data> element with @type attribute set to ARGUMENT mapped according to Table 3 (Selected datatypes from the W3C XML Schema Type Library).
All numeric types support the 'range' restriction, which is handled in the following way:
<rng:param name="minInclusive">...</rng:param>
<rng:param name="maxInclusive">...</rng:param>
For example, the 'typedef' statement
typedef rt { type int32 { range "-6378..0|42|100..max"; } }
appearing at the top level of the "example" module is mapped to the following RELAX NG fragment:
<rng:define name="example__rt"> <rng:choice> <rng:data type="int"> <rng:param name="minInclusive">-6378</rng:param> <rng:param name="maxInclusive">0</rng:param> </rng:data> <rng:data type="int"> <rng:param name="minInclusive">42</rng:param> <rng:param name="maxInclusive">42</rng:param> </rng:data> <rng:data type="int"> <rng:param name="minInclusive">100</rng:param> </rng:data> </rng:choice> </rng:define>
TOC |
This type is mapped to <rng:data> element with the @type attribute set to "string".
For the 'pattern' restriction, insert <rng:param> element with @name attribute set to "pattern". The argument of the 'pattern' statement (regular expression) becomes the content of this element.
The 'length' restriction is handled in the same way as the 'range' restriction for the numeric types, with the additional twist that if the length expression has multiple parts, the "pattern" facet
<rng:param name="pattern">...</rng:param>
if there is any, must be repeated inside each copy of the <rng:data> element, i.e., for each length part.
TOC |
If the 'type' statement refers to a derived type, it is mapped in one of the following ways depending on whether it contains any restrictions as its substatements:
See Section 7.2.2 (Type derivation chains) for more details and an example.
TOC |
This statement is mapped to a RELAX NG named pattern definition <rng:define>, but only if the type defined by this statement is used without restrictions in at least one of the input modules. In this case, the named pattern definition becomes a child of the <rng:grammar> element and its name is ARGUMENT mangled according to the rules specified in Section 7.2 (Mapping YANG Groupings and Typedefs).
Whenever a derived type is used with additional restrictions, the the base type for the derived type is used instead with restrictions (facets) that are a combination of all restrictions specified along the type derivation chain. See Section 10.50.10 (Derived Types) for further details and an example.
An implementation MAY offer the option of recording all 'typedef' statements as named patterns in the output RELAX NG schema even if they are not referenced. This is useful for mapping YANG "library" modules containing only 'typedef' and/or 'grouping' statements.
TOC |
This statement is mapped to @nma:unique attribute and ARGUMENT becomes its value.
TOC |
This statement is mapped to @nma:units attribute and ARGUMENT becomes its value.
TOC |
If this statement has neither 'refine' nor 'augment' substatements, it is mapped to <rng:ref> element and the value of its @name attribute is set to ARGUMENT mangled according to Section 7.2 (Mapping YANG Groupings and Typedefs)
If there are any 'refine' or 'augment' substatements, the corresponding grouping must be looked up and its contents is inserted as children of PARENT. See Section 7.2.1 (YANG Refinements and Augments) for further details and an example.
TOC |
This statement is ignored.
TOC |
This statement is mapped to @nma:when attribute and ARGUMENT becomes it value.
TOC |
This statement is not mapped to the output schema. However, an implementation SHOULD check that it is compatible with the YANG version declared by the statement (currently version 1).
TOC |
This statement is not mapped to the output schema, but see the rules for extension handling in Section 7.4 (YANG Language Extensions).
TOC |
TBD
TOC |
This document registers two namespace URIs in the IETF XML registry [21] (Mealling, M., “The IETF XML Registry,” January 2004.):
URI: urn:ietf:params:xml:ns:netmod:dsdl-annotations:1
URI: urn:ietf:params:xml:ns:netmod:conceptual-tree:1
TOC |
[1] | Enns, R., “NETCONF Configuration Protocol,” RFC 4741, December 2006 (TXT). |
[2] | Case, J., Fedor, M., Schoffstall, M., and J. Davin, “Simple Network Management Protocol (SNMP),” STD 15, RFC 1157, May 1990 (TXT). |
[3] | McCloghrie, K., Ed., Perkins, D., Ed., and J. Schoenwaelder, Ed., “Structure of Management Information Version 2 (SMIv2),” STD 58, RFC 2578, April 1999 (TXT). |
[4] | Elliott, C., Harrington, D., Jason, J., Schoenwaelder, J., Strauss, F., and W. Weiss, “SMIng Objectives,” RFC 3216, December 2001 (TXT). |
[5] | Bjorklund, M., Ed., “YANG - A data modeling language for NETCONF,” draft-ietf-netmod-yang-03 (work in progress), January 2009 (HTML). |
[6] | ISO/IEC, “Document Schema Definition Languages (DSDL) - Part 1: Overview,” ISO/IEC 19757-1, 11 2004. |
[7] | Bradner, S., “Key words for use in RFCs to Indicate Requirement Levels,” BCP 14, RFC 2119, March 1997 (TXT). |
[8] | Clark, J., Ed. and M. Murata, Ed., “RELAX NG DTD Compatibility,” OASIS Committee Specification 3 December 2001, December 2001. |
[9] | ISO/IEC, “Information Technology - Document Schema Definition Languages (DSDL) - Part 8: Document Semantics Renaming Language - DSRL,” ISO/IEC 19757-8:2008(E), 12 2008. |
[10] | ISO/IEC, “Information Technology - Document Schema Definition Languages (DSDL) - Part 2: Regular-Grammar-Based Validation - RELAX NG. Second Edition.,” ISO/IEC 19757-2:2008(E), 12 2008. |
[11] | ISO/IEC, “Information Technology - Document Schema Definition Languages (DSDL) - Part 3: Rule-Based Validation - Schematron,” ISO/IEC 19757-3:2006(E), 6 2006. |
[12] | Thompson, H., Beech, D., Maloney, M., and N. Mendelsohn, “XML Schema Part 1: Structures Second Edition,” World Wide Web Consortium Recommendation REC-xmlschema-1-20041028, October 2004 (HTML). |
[13] | Bray, T., Paoli, J., Sperberg-McQueen, C., Maler, E., and F. Yergeau, “Extensible Markup Language (XML) 1.0 (Fourth Edition),” World Wide Web Consortium Recommendation REC-xml-20060816, August 2006 (HTML). |
[14] | Biron, P. and A. Malhotra, “XML Schema Part 2: Datatypes Second Edition,” World Wide Web Consortium Recommendation REC-xmlschema-2-20041028, October 2004 (HTML). |
[15] | ISO/IEC, “Information Technology - Document Schema Definition Languages (DSDL) - Part 2: Regular-Grammar-Based Validation - RELAX NG. AMENDMENT 1: Compact Syntax,” ISO/IEC 19757-2:2003/Amd. 1:2006(E), 1 2006. |
[16] | Clark, J. and S. DeRose, “XML Path Language (XPath) Version 1.0,” World Wide Web Consortium Recommendation REC-xpath-19991116, November 1999 (HTML). |
[17] | Clark, J., “XSL Transformations (XSLT) Version 1.0,” World Wide Web Consortium Recommendation REC-xslt-19991116, November 1999. |
[18] | Kunze, J., “The Dublin Core Metadata Element Set,” RFC 5013, August 2007 (TXT). |
[19] | Schoenwaelder, J., Ed., “Common YANG Data Types,” draft-ietf-netmod-yang-types-01 (work in progress), November 2008 (HTML). |
[20] | van der Vlist, E., “RELAX NG,” O'Reilly , 2004. |
[21] | Mealling, M., “The IETF XML Registry,” BCP 81, RFC 3688, January 2004 (TXT). |
TOC |
This appendix contains the RELAX NG schema for the NETMOD-specific annotations in both XML and compact syntax.
[Editor's note: It is currently only a set of named pattern definitions as templates for the annotation elements and attributes. We should find a way how to connect this to the schema for RELAX NG, which these annotations extend. One option may be NVDL or it can also be done as in the spec for DTD compatibility annotations.]
TOC |
<?xml version="1.0" encoding="UTF-8"?> <grammar xmlns="http://relaxng.org/ns/structure/1.0" ns="urn:ietf:params:xml:ns:netmod:dsdl-annotations:1" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> <define name="config-attribute"> <attribute name="config"> <data type="boolean"/> </attribute> </define> <define name="default-attribute"> <attribute name="default"/> </define> <define name="default-case-attribute"> <attribute name="default-case"> <data type="boolean"/> </attribute> </define> <define name="error-app-tag-element"> <optional> <element name="error-app-tag"> <text/> </element> </optional> </define> <define name="error-message-element"> <optional> <element name="error-message"> <text/> </element> </optional> </define> <define name="instance-identifier-element"> <element name="instance-identifier"> <optional> <attribute name="require-instance"> <data type="boolean"/> </attribute> </optional> </element> </define> <define name="key-attribute"> <attribute name="key"> <list> <data type="QName"/> </list> </attribute> </define> <define name="leafref-element"> <element name="leafref"> <optional> <attribute name="require-instance"> <data type="boolean"/> </attribute> </optional> <data type="string"/> </element> </define> <define name="min-elements-attribute"> <attribute name="min-elements"> <data type="integer"/> </attribute> </define> <define name="max-elements-attribute"> <attribute name="max-elements"> <data type="integer"/> </attribute> </define> <define name="must-element"> <element name="must"> <attribute name="assert"> <data type="string"/> </attribute> <interleave> <ref name="err-app-tag-element"/> <ref name="err-message-element"/> </interleave> </element> </define> <define name="ordered-by-attribute"> <attribute name="ordered-by"> <choice> <value>user</value> <value>system</value> </choice> </attribute> </define> <define name="status-attribute"> <attribute name="status"> <choice> <value>current</value> <value>deprecated</value> <value>obsolete</value> </choice> </attribute> </define> <define name="unique-attribute"> <attribute name="unique"> <list> <data type="string"/> </list> </attribute> </define> <define name="units-attribute"> <attribute name="units"> <data type="string"/> </attribute> </define> <define name="when-attribute"> <attribute name="when"> <data type="string"/> </attribute> </define> </grammar>
TOC |
default namespace = "urn:ietf:params:xml:ns:netmod:dsdl-annotations:1" config-attribute = attribute config { xsd:boolean } default-attribute = attribute default { text } default-case-attribute = attribute default-case { xsd:boolean } error-app-tag-element = element error-app-tag { text }? error-message-element = element error-message { text }? instance-identifier-element = element instance-identifier { attribute require-instance { xsd:boolean }? } key-attribute = attribute key { list { xsd:QName } } leafref-element = element leafref { attribute require-instance { xsd:boolean }?, xsd:string } min-elements-attribute = attribute min-elements { xsd:integer } max-elements-attribute = attribute max-elements { xsd:integer } must-element = element must { attribute assert { xsd:string }, (err-app-tag-element & err-message-element) } ordered-by-attribute = attribute ordered-by { "user" | "system" } status-attribute = attribute status { "current" | "deprecated" | "obsolete" } unique-attribute = attribute unique { list { xsd:string } } units-attribute = attribute units { xsd:string } when-attribute = attribute when { xsd:string }
TOC |
This appendix contains the schema-independent library of Schematron abstract patterns.
[Editor's note: It is incomplete.]
<!-- Uniqueness of list keys --> <sch:pattern abstract="true" id="key"> <sch:rule context="$context"> <sch:assert test="count($context[$key=current()/$key])=1"> The key "<value-of select="$key"/>" needs to be unique within the list at: <value-of select="$context"/>. </sch:assert> </sch:rule> </sch:pattern> <!-- Check of listref target --> <sch:pattern abstract="true" id="keyref"> <sch:rule context="$keyref-context"> <sch:assert test="$key-context[$key=current()]"> The contents of "<value-of select="$keyref-context"/>" must be a '</name>' with the key "<value-of select="$key"/>" in this context: <value-of select="$key-context"/>. </sch:assert> </sch:rule> </sch:pattern>
TOC |
This appendix demonstrates output of the YANG->DSDL mapping algorithm applied to the "canonical" DHCP tutorial data model.
Appendix C.1 (XML Syntax) shows the result of the mapping algorithm in the RELAX NG XML syntax and Appendix C.2 (Compact Syntax) the same in the compact syntax, which was obtained using the Trang tool.
The long regular expressions for IP addresses etc. that would exceed the limit of 72 characters per line were trimmed. Other than that, the results of the automatic translations were not changed.
TOC |
<?xml version="1.0" encoding="UTF-8"?> <grammar xmlns="http://relaxng.org/ns/structure/1.0" xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns:dc="http://purl.org/dc/terms" xmlns:dhcp="http://example.com/ns/dhcp" xmlns:nma="urn:ietf:params:xml:ns:netmod:rng-annot:1" xmlns:nmt="urn:ietf:params:xml:ns:netmod:tree:1" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> <dc:creator>Pyang 0.9.3, RELAX NG plugin</dc:creator> <dc:source>YANG module 'dhcp'</dc:source> <start> <element name="nmt:netmod-tree"> <element name="nmt:top"> <interleave> <optional> <element name="dhcp:dhcp"> <a:documentation>configuration and operational parameters for a DHCP server.</a:documentation> <optional> <element name="dhcp:max-lease-time" nma:default="7200" nma:units="seconds"> <data type="unsignedInt"/> </element> </optional> <optional> <element name="dhcp:default-lease-time" nma:default="600" nma:units="seconds"> <data type="unsignedInt"/> <nma:must assert="current() <= ../max-lease-time"> <nma:error-message>The default-lease-time must be less than max-lease-time</nma:error-message> </nma:must> </element> </optional> <ref name="dhcp__subnet-list"/> <optional> <element name="dhcp:shared-networks"> <zeroOrMore> <element name="dhcp:shared-network" nma:key="name"> <element name="dhcp:name"> <data type="string"/> </element> <ref name="dhcp__subnet-list"/> </element> </zeroOrMore> </element> </optional> <optional> <element name="dhcp:status" nma:config="false"> <zeroOrMore> <element name="dhcp:leases" nma:key="address"> <element name="dhcp:address"> <ref name="inet-types__ip-address"/> </element> <optional> <element name="dhcp:starts"> <ref name="yang-types__date-and-time"/> </element> </optional> <optional> <element name="dhcp:ends"> <ref name="yang-types__date-and-time"/> </element> </optional> <optional> <element name="dhcp:hardware"> <optional> <element name="dhcp:type"> <choice> <value>ethernet</value> <value>token-ring</value> <value>fddi</value> </choice> </element> </optional> <optional> <element name="dhcp:address"> <ref name="yang-types__phys-address"/> </element> </optional> </element> </optional> </element> </zeroOrMore> </element> </optional> </element> </optional> </interleave> </element> <element name="nmt:rpc-methods"> <empty/> </element> <element name="nmt:notifications"> <empty/> </element> </element> </start> <define name="dhcp__subnet-list"> <a:documentation>A reusable list of subnets</a:documentation> <zeroOrMore> <element name="dhcp:subnet" nma:key="net"> <element name="dhcp:net"> <ref name="inet-types__ip-prefix"/> </element> <optional> <element name="dhcp:range"> <optional> <element name="dhcp:dynamic-bootp"> <a:documentation>Allows BOOTP clients to get addresses in this range</a:documentation> <empty/> </element> </optional> <element name="dhcp:low"> <ref name="inet-types__ip-address"/> </element> <element name="dhcp:high"> <ref name="inet-types__ip-address"/> </element> </element> </optional> <optional> <element name="dhcp:dhcp-options"> <a:documentation>Options in the DHCP protocol</a:documentation> <zeroOrMore> <element name="dhcp:router" nma:ordered-by="user"> <ref name="inet-types__host"/> <a:documentation>See: RFC 2132, sec. 3.8</a:documentation> </element> </zeroOrMore> <optional> <element name="dhcp:domain-name"> <ref name="inet-types__domain-name"/> <a:documentation>See: RFC 2132, sec. 3.17</a:documentation> </element> </optional> </element> </optional> <optional> <element name="dhcp:max-lease-time" nma:default="7200" nma:units="seconds"> <data type="unsignedInt"/> </element> </optional> </element> </zeroOrMore> </define> <define name="inet-types__ip-prefix"> <choice> <ref name="inet-types__ipv4-prefix"/> <ref name="inet-types__ipv6-prefix"/> </choice> </define> <define name="inet-types__ipv4-prefix"> <data type="string"> <param name="pattern">... removed ...</param> </data> </define> <define name="inet-types__ipv6-prefix"> <data type="string"> <param name="pattern">... removed ...</param> </data> </define> <define name="inet-types__ip-address"> <choice> <ref name="inet-types__ipv4-address"/> <ref name="inet-types__ipv6-address"/> </choice> </define> <define name="inet-types__ipv4-address"> <data type="string"> <param name="pattern">... removed ...</param> </data> </define> <define name="inet-types__ipv6-address"> <data type="string"> <param name="pattern">... removed ...</param> </data> </define> <define name="inet-types__host"> <choice> <ref name="inet-types__ip-address"/> <ref name="inet-types__domain-name"/> </choice> </define> <define name="inet-types__domain-name"> <data type="string"> <param name="pattern">... removed ...</param> </data> </define> <define name="yang-types__date-and-time"> <data type="string"> <param name="pattern">... removed ...</param> </data> </define> <define name="yang-types__phys-address"> <data type="string"> <param name="pattern">... removed ...</param> </data> </define> </grammar>
TOC |
namespace a = "http://relaxng.org/ns/compatibility/annotations/1.0" namespace dc = "http://purl.org/dc/terms" namespace dhcp = "http://example.com/ns/dhcp" namespace nma = "urn:ietf:params:xml:ns:netmod:rng-annot:1" namespace nmt = "urn:ietf:params:xml:ns:netmod:tree:1" dc:creator [ "Pyang 0.9.3, RELAX NG plugin" ] dc:source [ "YANG module 'dhcp'" ] start = element nmt:netmod-tree { element nmt:top { ## configuration and operational parameters for a DHCP server. element dhcp:dhcp { [ nma:default = "7200" nma:units = "seconds" ] element dhcp:max-lease-time { xsd:unsignedInt }?, [ nma:default = "600" nma:units = "seconds" ] element dhcp:default-lease-time { xsd:unsignedInt >> nma:must [ assert = "current() <= ../max-lease-time" nma:error-message [ "The default-lease-time must be less than max-lease-time" ] ] }?, dhcp__subnet-list, element dhcp:shared-networks { [ nma:key = "name" ] element dhcp:shared-network { element dhcp:name { xsd:string }, dhcp__subnet-list }* }?, [ nma:config = "false" ] element dhcp:status { [ nma:key = "address" ] element dhcp:leases { element dhcp:address { inet-types__ip-address }, element dhcp:starts { yang-types__date-and-time }?, element dhcp:ends { yang-types__date-and-time }?, element dhcp:hardware { element dhcp:type { "ethernet" | "token-ring" | "fddi" }?, element dhcp:address { yang-types__phys-address }? }? }* }? }? }, element nmt:rpc-methods { empty }, element nmt:notifications { empty } } ## A reusable list of subnets dhcp__subnet-list = [ nma:key = "net" ] element dhcp:subnet { element dhcp:net { inet-types__ip-prefix }, element dhcp:range { ## Allows BOOTP clients to get addresses in this range element dhcp:dynamic-bootp { empty }?, element dhcp:low { inet-types__ip-address }, element dhcp:high { inet-types__ip-address } }?, ## Options in the DHCP protocol element dhcp:dhcp-options { [ nma:ordered-by = "user" ] element dhcp:router { inet-types__host >> a:documentation [ "See: RFC 2132, sec. 3.8" ] }*, element dhcp:domain-name { inet-types__domain-name >> a:documentation [ "See: RFC 2132, sec. 3.17" ] }? }?, [ nma:default = "7200" nma:units = "seconds" ] element dhcp:max-lease-time { xsd:unsignedInt }? }* inet-types__ip-prefix = inet-types__ipv4-prefix | inet-types__ipv6-prefix inet-types__ipv4-prefix = xsd:string { pattern = "... removed ..." } inet-types__ipv6-prefix = xsd:string { pattern = "... removed ..." } inet-types__ip-address = inet-types__ipv4-address | inet-types__ipv6-address inet-types__ipv4-address = xsd:string { pattern = "... removed ..." } inet-types__ipv6-address = xsd:string { pattern = "... removed ..." } inet-types__host = inet-types__ip-address | inet-types__domain-name inet-types__domain-name = xsd:string { pattern = "... removed ..." } yang-types__date-and-time = xsd:string { pattern = "... removed ..." } yang-types__phys-address = xsd:string { pattern = "([0-9a0-fA-F]{2}(:[0-9a0-fA-F]{2})*)?" }
TOC |
Ladislav Lhotka | |
CESNET | |
Email: | lhotka@cesnet.cz |
Rohan Mahy | |
Plantronics | |
Email: | rohan@ekabal.com |
Sharon Chisholm | |
Nortel | |
Email: | schishol@nortel.com |