One document matched: draft-ietf-netmod-dsdl-map-04.txt
Differences from draft-ietf-netmod-dsdl-map-03.txt
NETMOD L. Lhotka
Internet-Draft CESNET
Intended status: Standards Track R. Mahy
Expires: April 22, 2010 Plantronics
S. Chisholm
Nortel
October 19, 2009
Mapping YANG to Document Schema Definition Languages and Validating
NETCONF Content
draft-ietf-netmod-dsdl-map-04
Status of this Memo
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 April 22, 2010.
Copyright Notice
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.
Lhotka, et al. Expires April 22, 2010 [Page 1]
Internet-Draft Mapping YANG to DSDL October 2009
Abstract
This draft specifies the mapping rules for translating YANG data
models into Document Schema Definition Languages (DSDL), a
coordinated set of XML schema languages standardized as ISO 19757.
The following DSDL schema languages are used by the mapping: RELAX
NG, Schematron and DSRL. The mapping takes one or more YANG modules
and produces a set of DSDL schemas for a selected target document
type - datastore content, NETCONF PDU etc. Procedures for schema-
based validation of such documents are also discussed.
Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 6
2. Terminology and Notation . . . . . . . . . . . . . . . . . . 7
2.1. Glossary of New Terms . . . . . . . . . . . . . . . . . 8
3. Objectives and Motivation . . . . . . . . . . . . . . . . . . 10
4. DSDL Schema Languages . . . . . . . . . . . . . . . . . . . . 12
4.1. RELAX NG . . . . . . . . . . . . . . . . . . . . . . . . 12
4.2. Schematron . . . . . . . . . . . . . . . . . . . . . . . 13
4.3. Document Semantics Renaming Language (DSRL) . . . . . . 14
5. Additional Annotations . . . . . . . . . . . . . . . . . . . 15
5.1. Dublin Core Metadata Elements . . . . . . . . . . . . . 15
5.2. RELAX NG DTD Compatibility Annotations . . . . . . . . . 15
5.3. NETMOD-Specific Annotations . . . . . . . . . . . . . . 16
6. Overview of the Mapping . . . . . . . . . . . . . . . . . . . 18
7. NETCONF Content Validation . . . . . . . . . . . . . . . . . 20
8. Design Considerations . . . . . . . . . . . . . . . . . . . . 21
8.1. Conceptual Data Tree . . . . . . . . . . . . . . . . . . 21
8.2. Modularity . . . . . . . . . . . . . . . . . . . . . . . 23
8.3. Granularity . . . . . . . . . . . . . . . . . . . . . . 24
8.4. Handling of XML Namespaces . . . . . . . . . . . . . . . 24
8.5. Features and Deviations . . . . . . . . . . . . . . . . 25
9. Mapping YANG Data Models to the Conceptual Tree Schema . . . 26
9.1. Occurrence Rules for Data Nodes . . . . . . . . . . . . 26
9.1.1. Optional and Mandatory Nodes . . . . . . . . . . . 27
9.1.2. Implicit Nodes . . . . . . . . . . . . . . . . . . 28
9.2. Mapping YANG Groupings and Typedefs . . . . . . . . . . 29
9.2.1. YANG Refinements and Augments . . . . . . . . . . . 31
9.2.2. Type derivation chains . . . . . . . . . . . . . . 34
9.3. Translation of XPath Expressions . . . . . . . . . . . . 37
9.4. YANG Language Extensions . . . . . . . . . . . . . . . . 37
10. Mapping Conceptual Tree Schema to DSDL . . . . . . . . . . . 39
10.1. Generating RELAX NG Schemas for Various Document Types . 39
10.1.1. Reply to <get> or <get-config> . . . . . . . . . . 40
10.1.2. Remote Procedure Calls . . . . . . . . . . . . . . 40
10.1.3. Notifications . . . . . . . . . . . . . . . . . . . 41
Lhotka, et al. Expires April 22, 2010 [Page 2]
Internet-Draft Mapping YANG to DSDL October 2009
10.2. Mapping Semantic Constraints to Schematron . . . . . . . 42
10.2.1. Validation Phases . . . . . . . . . . . . . . . . . 45
10.3. Constraints on Mandatory Choice . . . . . . . . . . . . 46
10.4. Mapping Default Values to DSRL . . . . . . . . . . . . . 48
11. Mapping YANG Statements to Conceptual Tree Schema . . . . . . 53
11.1. The anyxml Statement . . . . . . . . . . . . . . . . . . 53
11.2. The argument Statement . . . . . . . . . . . . . . . . . 54
11.3. The augment Statement . . . . . . . . . . . . . . . . . 55
11.4. The base Statement . . . . . . . . . . . . . . . . . . . 55
11.5. The belongs-to Statement . . . . . . . . . . . . . . . . 55
11.6. The bit Statement . . . . . . . . . . . . . . . . . . . 55
11.7. The case Statement . . . . . . . . . . . . . . . . . . . 55
11.8. The choice Statement . . . . . . . . . . . . . . . . . . 55
11.9. The config Statement . . . . . . . . . . . . . . . . . . 56
11.10. The contact Statement . . . . . . . . . . . . . . . . . 56
11.11. The container Statement . . . . . . . . . . . . . . . . 56
11.12. The default Statement . . . . . . . . . . . . . . . . . 56
11.13. The description Statement . . . . . . . . . . . . . . . 57
11.14. The deviation Statement . . . . . . . . . . . . . . . . 58
11.15. The enum Statement . . . . . . . . . . . . . . . . . . . 58
11.16. The error-app-tag Statement . . . . . . . . . . . . . . 58
11.17. The error-message Statement . . . . . . . . . . . . . . 58
11.18. The extension Statement . . . . . . . . . . . . . . . . 58
11.19. The feature Statement . . . . . . . . . . . . . . . . . 58
11.20. The grouping Statement . . . . . . . . . . . . . . . . . 58
11.21. The identity Statement . . . . . . . . . . . . . . . . . 59
11.22. The if-feature Statement . . . . . . . . . . . . . . . . 59
11.23. The import Statement . . . . . . . . . . . . . . . . . . 59
11.24. The include Statement . . . . . . . . . . . . . . . . . 59
11.25. The input Statement . . . . . . . . . . . . . . . . . . 59
11.26. The key Statement . . . . . . . . . . . . . . . . . . . 59
11.27. The leaf Statement . . . . . . . . . . . . . . . . . . . 60
11.28. The leaf-list Statement . . . . . . . . . . . . . . . . 60
11.29. The length Statement . . . . . . . . . . . . . . . . . . 61
11.30. The list Statement . . . . . . . . . . . . . . . . . . . 61
11.31. The mandatory Statement . . . . . . . . . . . . . . . . 62
11.32. The max-elements Statement . . . . . . . . . . . . . . . 62
11.33. The min-elements Statement . . . . . . . . . . . . . . . 62
11.34. The module Statement . . . . . . . . . . . . . . . . . . 62
11.35. The must Statement . . . . . . . . . . . . . . . . . . . 63
11.36. The namespace Statement . . . . . . . . . . . . . . . . 63
11.37. The notification Statement . . . . . . . . . . . . . . . 63
11.38. The ordered-by Statement . . . . . . . . . . . . . . . . 64
11.39. The organization Statement . . . . . . . . . . . . . . . 64
11.40. The output Statement . . . . . . . . . . . . . . . . . . 64
11.41. The path Statement . . . . . . . . . . . . . . . . . . . 64
11.42. The pattern Statement . . . . . . . . . . . . . . . . . 64
11.43. The position Statement . . . . . . . . . . . . . . . . . 64
Lhotka, et al. Expires April 22, 2010 [Page 3]
Internet-Draft Mapping YANG to DSDL October 2009
11.44. The prefix Statement . . . . . . . . . . . . . . . . . . 64
11.45. The presence Statement . . . . . . . . . . . . . . . . . 64
11.46. The range Statement . . . . . . . . . . . . . . . . . . 65
11.47. The reference Statement . . . . . . . . . . . . . . . . 65
11.48. The require-instance Statement . . . . . . . . . . . . . 65
11.49. The revision Statement . . . . . . . . . . . . . . . . . 65
11.50. The rpc Statement . . . . . . . . . . . . . . . . . . . 65
11.51. The status Statement . . . . . . . . . . . . . . . . . . 66
11.52. The submodule Statement . . . . . . . . . . . . . . . . 66
11.53. The type Statement . . . . . . . . . . . . . . . . . . . 66
11.53.1. The empty Type . . . . . . . . . . . . . . . . . . 67
11.53.2. The boolean and binary Types . . . . . . . . . . . 67
11.53.3. The bits Type . . . . . . . . . . . . . . . . . . . 67
11.53.4. The enumeration and union Types . . . . . . . . . . 68
11.53.5. The identityref Type . . . . . . . . . . . . . . . 68
11.53.6. The instance-identifier Type . . . . . . . . . . . 70
11.53.7. The leafref Type . . . . . . . . . . . . . . . . . 70
11.53.8. The numeric Types . . . . . . . . . . . . . . . . . 70
11.53.9. The string Type . . . . . . . . . . . . . . . . . . 72
11.53.10. Derived Types . . . . . . . . . . . . . . . . . . . 73
11.54. The typedef Statement . . . . . . . . . . . . . . . . . 74
11.55. The unique Statement . . . . . . . . . . . . . . . . . . 74
11.56. The units Statement . . . . . . . . . . . . . . . . . . 74
11.57. The uses Statement . . . . . . . . . . . . . . . . . . . 74
11.58. The value Statement . . . . . . . . . . . . . . . . . . 75
11.59. The when Statement . . . . . . . . . . . . . . . . . . . 75
11.60. The yang-version Statement . . . . . . . . . . . . . . . 75
11.61. The yin-element Statement . . . . . . . . . . . . . . . 75
12. Mapping NETMOD-specific annotations to DSDL Schema
Languages . . . . . . . . . . . . . . . . . . . . . . . . . . 76
12.1. The @nma:config Annotation . . . . . . . . . . . . . . . 76
12.2. The @nma:default Annotation . . . . . . . . . . . . . . 76
12.3. The @nma:implicit Annotation . . . . . . . . . . . . . . 76
12.4. The <nma:error-app-tag> Annotation . . . . . . . . . . . 76
12.5. The <nma:error-message> Annotation . . . . . . . . . . . 76
12.6. The <nma:instance-identifier> Annotation . . . . . . . . 76
12.7. The @nma:key Annotation . . . . . . . . . . . . . . . . 77
12.8. The @nma:leafref Annotation . . . . . . . . . . . . . . 77
12.9. The @nma:min-elements Annotation . . . . . . . . . . . . 77
12.10. The @nma:max-elements Annotation . . . . . . . . . . . . 78
12.11. The <nma:must> Annotation . . . . . . . . . . . . . . . 78
12.12. The <nma:ordered-by> Annotation . . . . . . . . . . . . 78
12.13. The <nma:status> Annotation . . . . . . . . . . . . . . 78
12.14. The @nma:unique Annotation . . . . . . . . . . . . . . . 78
12.15. The @nma:when Annotation . . . . . . . . . . . . . . . . 79
13. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 80
14. Security Considerations . . . . . . . . . . . . . . . . . . . 81
15. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 82
Lhotka, et al. Expires April 22, 2010 [Page 4]
Internet-Draft Mapping YANG to DSDL October 2009
16. References . . . . . . . . . . . . . . . . . . . . . . . . . 83
16.1. Normative References . . . . . . . . . . . . . . . . . . 83
16.2. Informative References . . . . . . . . . . . . . . . . . 84
Appendix A. Schemas for NETMOD-Specific Annotations . . . . . . 87
A.1. NVDL Schema . . . . . . . . . . . . . . . . . . . . . . 87
A.2. Annotation Attributes for define Pattern . . . . . . . . 89
A.3. Annotation Elements for element Pattern . . . . . . . . 89
A.4. Annotation Attributes for element Pattern . . . . . . . 90
A.5. Annotation attributes for group Pattern . . . . . . . . 90
A.6. Annotation attributes for choice and ref Patterns . . . 91
A.7. Annotation attributes for element Pattern in the List
Context . . . . . . . . . . . . . . . . . . . . . . . . 91
A.8. Annotation attributes for value Pattern . . . . . . . . 92
A.9. Named Patterns for All NETMOD-Specific Annotations . . . 92
Appendix B. Schema-Independent Library . . . . . . . . . . . . . 96
Appendix C. Mapping DHCP Data Model - A Complete Example . . . . 97
C.1. Input YANG Module . . . . . . . . . . . . . . . . . . . 97
C.2. Conceptual Tree Schema . . . . . . . . . . . . . . . . . 100
C.2.1. XML Syntax . . . . . . . . . . . . . . . . . . . . 100
C.2.2. Compact Syntax . . . . . . . . . . . . . . . . . . 105
C.3. Final DSDL Schemas . . . . . . . . . . . . . . . . . . . 107
C.3.1. RELAX NG Schema for <get> Reply - XML Syntax . . . 108
C.3.2. RELAX NG Schema for <get> Reply - Compact Syntax . 112
C.4. Schematron Schema for <get> Reply . . . . . . . . . . . 114
C.5. DSRL Schema for <get> Reply . . . . . . . . . . . . . . 116
Appendix D. Change Log . . . . . . . . . . . . . . . . . . . . . 117
D.1. Changes Between Versions -03 and -04 . . . . . . . . . . 117
D.2. Changes Between Versions -02 and -03 . . . . . . . . . . 117
D.3. Changes Between Versions -01 and -02 . . . . . . . . . . 118
D.4. Changes Between Versions -00 and -01 . . . . . . . . . . 119
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 120
Lhotka, et al. Expires April 22, 2010 [Page 5]
Internet-Draft Mapping YANG to DSDL October 2009
1. Introduction
The NETCONF Working Group has completed a base protocol used for
configuration management [RFC4741]. 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) [RFC1157] using the SMI language [RFC2578]
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 [RFC3216] and called YANG [YANG].
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 [DSDL]. 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 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.
Lhotka, et al. Expires April 22, 2010 [Page 6]
Internet-Draft Mapping YANG to DSDL October 2009
2. Terminology and Notation
This document relies on many terms that are defined in the
specifications of the NETCONF protocol [RFC4741] and YANG data
modeling language [YANG]. Also, the common terminology of XML and
DSDL schema languages is used as defined in the respective standards
[XML], [DSDL], [NVDL], [RNG], [Schematron] and [DSRL].
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 [RFC2119].
In the text, we use the following typographic conventions:
o YANG statement keywords are delimited by single quotes.
o XML element names are delimited by "<" and ">" characters.
o Names of XML attributes are prefixed by the "@" character.
o Other literal values are delimited by double quotes.
XML elements names are always written with explicit namespace
prefixes corresponding to the following XML vocabularies:
"a" DTD compatibility annotations [RNG-DTD]
"dc" Dublin Core metadata elements [RFC5013]
"dsrl" Document Semantics Renaming Language [DSRL]
"en" NETCONF event notifications [RFC5277]
"nc" NETCONF protocol [RFC4741]
"nma" NETMOD-specific schema annotations (see Section 5.3)
"nmf" NETMOD-specific XPath extension functions
"nmt" Conceptual tree (see Section 8.1)
"rng" RELAX NG [RNG]
"sch" ISO Schematron [Schematron]
Lhotka, et al. Expires April 22, 2010 [Page 7]
Internet-Draft Mapping YANG to DSDL October 2009
"xsd" W3C XML Schema [XSD]
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 |
| | |
| dsrl | http://purl.oclc.org/dsdl/dsrl |
| | |
| en | urn:ietf:params:xml:ns:netconf:notification:1.0 |
| | |
| nc | urn:ietf:params:xml:ns:netconf:base:1.0 |
| | |
| nma | urn:ietf:params:xml:ns:netmod:dsdl-annotations:1 |
| | |
| nmf | urn:ietf:params:xml:ns:netmod:xpath-extensions:1 |
| | |
| nmt | urn:ietf:params:xml:ns:netmod:conceptual-tree:1 |
| | |
| 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
2.1. Glossary of New Terms
o ancestor datatype: Any datytype a given datatype is (transitively)
derived from.
o ancestor built-in datatype: The built-in datatype that is at the
start of the type derivation chain for a given datatype.
o conceptual data tree: A virtual XML document integrating all
components of a YANG data model, i.e., configuration datastore,
RPC methods (both requests and replies) and notifications. The
conceptual tree is normally not instantiated, it only serves as a
conceptual target for its schema. See Section 8.1 for details.
Lhotka, et al. Expires April 22, 2010 [Page 8]
Internet-Draft Mapping YANG to DSDL October 2009
o implicit node: A node that, if missing, may be added to the
information set of an XML document (configuration, RPC input or
output, notification) without changing the meaning of that XML
document for the NETCONF server.
Lhotka, et al. Expires April 22, 2010 [Page 9]
Internet-Draft Mapping YANG to DSDL October 2009
3. Objectives and Motivation
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-based information models and XML-encoded data appear in several
different forms in various phases of YANG data modeling and 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 effective for validation 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 an extended period 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:
1. The first step maps one or more YANG modules to a single RELAX NG
schema of the so-called "conceptual tree", which contains
grammatical constraints for the main data tree as well as RPCs
and notifications. In order to record additional constraints
that appear in the YANG modules but cannot be expressed in RELAX
NG, the schema is augmented by simple annotations. The output of
the first step can thus be considered a reasonably readable
equivalent of the input YANG modules.
Lhotka, et al. Expires April 22, 2010 [Page 10]
Internet-Draft Mapping YANG to DSDL October 2009
2. In the second step, the annotated RELAX NG schema from step 1 is
transformed further to a coordinated set of fully conformant DSDL
schemas containing constraints for a particular data object and a
specific situation. The DSDL schemas are intended mainly for
machine validation using off-the-shelf tools.
Lhotka, et al. Expires April 22, 2010 [Page 11]
Internet-Draft Mapping YANG to DSDL October 2009
4. DSDL Schema Languages
Document Schema Definition Languages (DSDL) is a framework of schema
languages that is being developed as an international standard ISO/
IEC 19757. Unlike other approaches to XML document validation,
notably W3C XML Schema (XSD) [XSD], the DSDL framework adheres to the
principle of "small languages": Each of the DSDL constituents is a
stand-alone schema language with a relatively narrow purpose and
focus. Together, these schema languages may be used in a coordinated
way to accomplish various validation tasks.
The mapping described in this document uses three of the DSDL schema
languages, namely RELAX NG, Schematron and DSRL.
4.1. RELAX NG
RELAX NG (pronounced "relaxing") is an XML schema language for
grammar-based validation and Part 2 of the ISO/IEC DSDL family of
standards [RNG]. Like the W3C XML Schema language [XSD], it is able
to describe constraints on the structure and content of XML
documents. However, unlike the DTD [XML] 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 4.3).
As its base datatype library, RELAX NG uses the W3C XML Schema
Datatype Library [XSD-D], 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 elements such as
<xsd:annotation> in XSD.
RELAX NG schemas can be represented in two equivalent syntaxes: XML
and compact. The compact syntax is described in Annex C of the RELAX
NG specification [RNG-CS], which was added to the standard in 2006
(Amendment 1). Automatic bidirectional conversions between the two
syntaxes can be accomplished using several tools, for example
Trang [1].
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:
Lhotka, et al. Expires April 22, 2010 [Page 12]
Internet-Draft Mapping YANG to DSDL October 2009
o External annotations make the compact syntax schema considerably
less readable. While in the XML syntax the annotating elements
and attributes are represented in a simple and uniform way (XML
elements and attributes from foreign namespaces), the compact
syntax uses four different syntactic constructs: documentation,
grammar, initial and following annotations. Therefore, the impact
of annotations on readability is often much stronger for the
compact syntax than for the XML syntax.
o In a computer program, it is more difficult to generate compact
syntax than XML syntax. While a number of software libraries
exist that make it easy to create an XML tree in memory and
serialize it, no such aid is available for compact syntax.
For these reasons, the mapping specification in this document uses
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".
4.2. Schematron
Schematron is Part 3 of DSDL that reached the status of a full ISO/
IEC standard in 2006 [Schematron]. 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 components:
o context - an XPath expression that defines the set of locations
where the rule is to be applied;
o assert or report condition - another XPath expression that is
evaluated relative to the location matched by the context
expression;
o human-readable message that is displayed when the assert condition
is false or report condition is true.
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.
Lhotka, et al. Expires April 22, 2010 [Page 13]
Internet-Draft Mapping YANG to DSDL October 2009
Schematron draws most of its expressive power from XPath [XPath] and
XSLT [XSLT]. 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 common schema languages. 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.
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".
4.3. Document Semantics Renaming Language (DSRL)
DSRL (pronounced "disrule") is Part 8 of DSDL that reached the status
of a full ISO/IEC standard in 2008 [DSRL]. Unlike RELAX NG and
Schematron, it is specifically designed to modify XML information set
of the validated document. While DSRL is primarily intended for
renaming XML elements and attributes, it can also define default
values for XML attributes and default content for XML elements so
that elements or attributes with these default values are inserted if
they are missing (or present and empty) in the validated documents.
The latter feature is used by the YANG-to-DSDL mapping for
representing YANG default values for leaf nodes.
DSRL elements are qualified with namespace URI
"http://purl.oclc.org/dsdl/dsrl".
Lhotka, et al. Expires April 22, 2010 [Page 14]
Internet-Draft Mapping YANG to DSDL October 2009
5. Additional Annotations
Besides the DSDL schema languages, the mapping also uses three sets
of annotations that are added as foreign-namespace attributes and
elements 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. Although these data model items are not used for
formal validation, they quite often carry important information for
data model implementers. 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 YANG 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.
5.1. Dublin Core Metadata Elements
Dublin Core [2] 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 from [RFC5013].
Dublin Core elements are qualified with namespace URI
"http://purl.org/dc/terms".
5.2. RELAX NG DTD Compatibility Annotations
DTD compatibility annotations are part of the RELAX NG DTD
Compatibility specification [RNG-DTD]. 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:
they are 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".
Lhotka, et al. Expires April 22, 2010 [Page 15]
Internet-Draft Mapping YANG to DSDL October 2009
5.3. NETMOD-Specific Annotations
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 straightforward way. In most cases,
the annotation attributes and elements always have the same name as
the corresponding YANG statement.
Table 2 lists alphabetically the names of NETMOD-specific annotation
attributes (prefixed with "@") and elements (in angle brackets) along
with a reference to the section where their use is described.
Appendix A contains the formal specification of this annotation
vocabulary.
Lhotka, et al. Expires April 22, 2010 [Page 16]
Internet-Draft Mapping YANG to DSDL October 2009
+---------------------------+--------------------+------+
| annotation | section | note |
+---------------------------+--------------------+------+
| @nma:config | 11.9 | |
| | | |
| @nma:default | 11.12 | |
| | | |
| @nma:implicit | 11.11, 11.7, 11.12 | |
| | | |
| <nma:error-app-tag> | 11.16 | 1 |
| | | |
| <nma:error-message> | 11.17 | 1 |
| | | |
| <nma:instance-identifier> | 11.53.6 | 2 |
| | | |
| @nma:key | 11.26 | |
| | | |
| @nma:leafref | 11.53.7 | |
| | | |
| @nma:min-elements | 11.28 | |
| | | |
| @nma:max-elements | 11.28 | |
| | | |
| <nma:must> | 11.35 | 3 |
| | | |
| @nma:ordered-by | 11.38 | |
| | | |
| @nma:presence | 11.45 | |
| | | |
| @nma:status | 11.51 | |
| | | |
| @nma:unique | 11.55 | |
| | | |
| @nma:units | 11.56 | |
| | | |
| @nma:when | 11.59 | |
+---------------------------+--------------------+------+
Table 2: NETMOD-specific annotations
Notes:
1. Appears only as subelement of <nma:must>.
2. Has an optional attribute @require-instance.
3. Has a mandatory attribute @assert and two optional subelements
<nma:error-app-tag> and <nma:error-message>.
Lhotka, et al. Expires April 22, 2010 [Page 17]
Internet-Draft Mapping YANG to DSDL October 2009
6. Overview of the Mapping
This section gives an overview of the YANG-to-DSDL mapping, its
inputs and outputs. Figure 1 presents an overall structure of the
mapping:
+----------------+
| YANG module(s) |
+----------------+
|
|T
|
+-------------------------------------+
| RELAX NG schema for conceptual tree |
+-------------------------------------+
/ | | \
/ | | \ +-------+
Tg/ Tr| |Tn \ |library|
/ | | \ +-------+
+---------+ +-----+ +-------+ +------+
|get reply| | rpc | | notif | | .... |
+---------+ +-----+ +-------+ +------+
Figure 1: Structure of the mapping
The mapping procedure is divided into two steps:
1. Transformation T in the first step maps one or more YANG modules
to a single RELAX NG schema for the conceptual tree (see
Section 8.1). Constraints that cannot be expressed directly in
RELAX NG (list key definitions, 'must' statements etc.) and
various documentation texts are recorded in the schema as simple
annotations belonging to special namespaces.
2. In the second step, the conceptual tree schema is transformed in
multiple ways to a coordinated set of DSDL schemas that can be
used for validating a particular data object in a specific
context. Figure 1 shows just three simple possibilities as
examples. In the process, appropriate parts of the conceptual
tree schema are extracted and specific annotations transformed to
equivalent, but usually more complex, Schematron patterns, DSRL
element maps etc.
3. As indicated in Figure 1, the second step of the mapping also
uses a schema-independent library that contains common schema
objects such as RELAX NG named pattern definitions.
An implementation of the mapping algorithm accepts one or more valid
Lhotka, et al. Expires April 22, 2010 [Page 18]
Internet-Draft Mapping YANG to DSDL October 2009
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, which may also lead to multiple
roots. 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 - a virtual XML document containing, in its
different subtrees, the entire datastore, all RPC requests and
replies, and notifications as 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 may
produce practical validation schemas. The conceptual tree is further
described in Section 8.1.
Other information contained in input YANG modules, such as semantic
constraints or default values, are recorded in the conceptual tree
schema as annotations - XML attributes or elements 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 5.1). Finally, documentation
strings are mapped to the <a:documentation> elements belonging to the
DTD compatibility vocabulary (Section 5.2).
The output from the second step is a coordinated set of three DSDL
schemas corresponding to a specific data object and context:
o RELAX NG schema describing the grammatical and datatype
constraints;
o Schematron schema expressing other constraints such as uniqueness
of list keys or user-specified semantic rules;
o DSRL schema containing a specification of default content.
Lhotka, et al. Expires April 22, 2010 [Page 19]
Internet-Draft Mapping YANG to DSDL October 2009
7. NETCONF Content Validation
This section describes how the schemas generated by the YANG-to-DSDL
mapping are supposed to be applied for validating XML instance
documents such as the content of a datastore or various NETCONF PDUs.
The validation proceeds in the following steps, which are also
illustrated in Figure 2:
1. The XML instance document can be immediately checked for
grammatical and data type validity using the RELAX NG schema.
2. Second, default values for leaf nodes have to be applied and
their ancestor containers added where necessary. It is important
to apply the defaults before the next validation step because
YANG specification [YANG] states that the data tree against which
XPath expressions are evaluated already has all defaults
filled-in. Note that this step modifies the information set of
the input XML document.
3. The semantic constraints are checked using the Schematron schema.
+----------+ +----------+
| | | XML |
| XML | | document |
| document |-----------o----------->| with |
| | ^ | defaults |
| | | | |
+----------+ | +----------+
^ | filling-in ^
| grammar, | defaults | semantic
| datatypes | | constraints
| | |
+----------+ +--------+ +------------+
| RELAX NG | | DSRL | | Schematron |
| schema | | schema | | schema |
+----------+ +--------+ +------------+
Figure 2: Outline of the validation procedure
Lhotka, et al. Expires April 22, 2010 [Page 20]
Internet-Draft Mapping YANG to DSDL October 2009
8. Design Considerations
YANG modules could in principle 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.
8.1. Conceptual Data Tree
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: every YANG-based model
represents the contents of a 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. While the decision
about proper structuring of all PDU-validating schemas is beyond the
scope of this document, the mapping procedure 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 grammar and
datatype specifications 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.
For example, the conceptual data tree for a YANG module defining
nodes in the namespace "http://example.com/ns/example" may be
schematically represented as follows:
Lhotka, et al. Expires April 22, 2010 [Page 21]
Internet-Draft Mapping YANG to DSDL October 2009
<nmt:netmod-tree
xmlns:nmt="urn:ietf:params:xml:ns:netmod:conceptual-tree:1"
xmlns:ex="http://example.com/ns/example">
<nmt:top>
... configuration and status data ...
</nmt:top>
<nmt:rpc-methods>
<nmt:rpc-method>
<nmt:input>
<ex:myrpc ...>
...
</myrpc>
</nmt:input>
<nmt:output>
...
</nmt:output>
</nmt:rpc-method>
...
</nmt:rpc-methods>
<nmt:notifications>
<nmt:notification>
<ex:mynotif>
...
</mynotif>
</nmt:notification>
...
</nmt:notifications>
</nmt:netmod>
The namespace URI "urn:ietf:params:xml:ns:netmod:conceptual-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 validation schemas. In general, these
transformations should be relatively simple - they will typically
extract one or more 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 NETMOD-specific 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, these
annotations are translated to equivalent Schematron and DSRL rules.
Lhotka, et al. Expires April 22, 2010 [Page 22]
Internet-Draft Mapping YANG to DSDL October 2009
As a useful side effect, by introducing the conceptual data tree we
are also able to resolve the difficulties arising from the fact that
a single datastore 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:top> element.
8.2. Modularity
Both YANG and RELAX NG offer means for modularity, i.e., for
splitting the contents of a full schema into separate modules 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:
o In YANG, whenever module A imports module B, it gets access to the
definitions (groupings and typedefs) appearing at the top level of
module B. However, no part of data tree from module B is imported
along with it. In contrast, the <rng:include> pattern in RELAX NG
imports both definitions of named patterns and the entire schema
tree from the included schema.
o The names of imported YANG groupings and typedefs are qualified
with the namespace of the imported module. On the other hand, the
names of data nodes contained inside the imported groupings, when
used within the importing module, become part of the importing
module's namespace. In RELAX NG, the names of patterns are
unqualified and so named patterns defined in both the importing
and imported module share the same flat namespace. The contents
of RELAX NG named patterns may either keep the namespace of the
schema where they are defined or inherit the namespace of the
importing module, analogically to YANG. However, in order to
achieve the latter behavior, the imported module must be prepared
in a special way as a library module that cannot be used as a
stand-alone schema.
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
Lhotka, et al. Expires April 22, 2010 [Page 23]
Internet-Draft Mapping YANG to DSDL October 2009
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.
8.3. Granularity
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 corresponds to a named pattern
definition. 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.
8.4. Handling of XML Namespaces
Most modern XML schema languages including RELAX NG, Schematron and
DSRL support schemas for so-called compound XML documents, which
contain elements from multiple namespaces. This is useful for our
purpose since YANG-to-DSDL mapping allows for multiple input YANG
modules that naturally leads to compound document schemas.
RELAX NG offers two alternatives for defining the "target" namespaces
in the schema:
1. First possibility is the traditional XML way via the @xmlns:xxx
attribute.
Lhotka, et al. Expires April 22, 2010 [Page 24]
Internet-Draft Mapping YANG to DSDL October 2009
2. One of the target namespace URIs may be declared using the @ns
attribute.
In both cases these attributes are typically attached to the <rng:
grammar> element.
The design decision for the mapping is to use exclusively the
alternative 1, since in this case all YANG modules are represented
symmetrically, which makes further processing of the conceptual tree
schema considerably easier. Moreover, this way the namespace
prefixes declared in the input modules are recorded in the resulting
schema - the prefix for the namespace declared using @ns would be
lost.
DSRL schemas can declare any number of target namespaces via the
standard XML attributes xmlns:xxx.
In contrast, Schematron requires all the target namespaces to be
defined in the <sch:ns> subelements of the root <sch:schema> element.
8.5. Features and Deviations
YANG provides statements that allow for marking parts of the schema
as conditional ('feature' and 'if-feature' statements) or declaring
deviations from a data model ('deviation' statement). These
statements are not handled by the YANG-to-DSDL mapping. Instead, it
is assumed that all features and deviations are specified beforehand
and the corresponding changes in the input YANG modules are already
applied.
Lhotka, et al. Expires April 22, 2010 [Page 25]
Internet-Draft Mapping YANG to DSDL October 2009
9. Mapping YANG Data Models to the Conceptual Tree Schema
This section explains the main principles underlying the first step
of the mapping. Its result is an annotated RELAX NG schema of the
conceptual tree, which is described in Section 8.1.
As a special case, if the input YANG modules contain no data nodes
(this is typical, e.g., for datatype library modules), an
implementation MAY entirely remove the schema of the (empty)
conceptual tree - the <rng:start> element with all its contents. The
output RELAX NG schema will then contain only named pattern
definitions translated from YANG groupings and typedefs.
Detailed specification of the mapping of individual YANG statements
is contained in Section 11.
9.1. Occurrence Rules for Data Nodes
In DSDL schema languages, occurrence constraints for a node are
always localized together with that node. In RELAX NG, for example,
<rng:optional> pattern appears as the parent element of the pattern
defining the node in the schema, be it a leaf or container node.
Similarly, DSRL specifies default content separately for every single
node, be it a leaf or non-leaf element.
For leaf nodes in YANG modules, the occurrence constraints are also
easily inferred from the substatements of 'leaf'. In contrast, for a
YANG container it is often necessary to examine its entire subtree in
order to determine the container's occurrence constraints.
Therefore, one of the goals of the first mapping step is to infer the
occurrence constraints for all containers and mark accordingly the
corresponding <rng:element> patterns in the conceptual tree schema so
that any transformation procedure in the second mapping step can
simply use this information and need not examine the subtree again.
First, it has to be decided whether a given container element must
always be present in a valid configuration. If so, such a container
element is called mandatory, otherwise it is called optional. This
constraint is very closely related to the notion of mandatory nodes
in Section 3.1 in [YANG]. The only difference is that we also
consider list keys to be mandatory.
The other occurrence constraint has to do with the semantics of the
'default' statement and the possibility of removing empty non-
presence containers. As a result, the information set of a valid
configuration may be modified by adding or removing certain leaf or
container elements without changing the meaning of the configuration.
Lhotka, et al. Expires April 22, 2010 [Page 26]
Internet-Draft Mapping YANG to DSDL October 2009
Such elements are called implicit.
Note that both occurrence constraints apply to containers at the top
level of the data tree, and then also to other containers under the
additional condition that their parent node exists in the instance
document. For example, consider the following YANG fragment:
container outer {
presence 'Presence of "outer" means something.';
container c1 {
leaf foo {
type uint8;
default 1;
}
}
container c2 {
leaf-list bar {
type uint8;
min-elements 0;
}
}
container c3 {
leaf baz {
type uint8;
mandatory true;
}
}
}
Here, container "outer" has the 'presence' substatement, which means
that it is optional and not implicit. If "outer" is not present in a
configuration, its child containers are not present as well.
However, if "outer" does exist, it makes sense to ask which of its
child containers are optional and which are implicit. In this case,
"c1" is optional and implicit, "c2" is optional but not implicit and
"c3" is mandatory (and therefore not implicit).
The following subsections give precise rules for determining whether
a container is optional or mandatory and whether it is implicit. In
order to simplify the recursive definition of these occurrence
characteristics, it is useful to define them for other types of nodes
as well, i.e., leaf, list, leaf-list and anyxml.
9.1.1. Optional and Mandatory Nodes
The decision whether a given node is mandatory or optional is
governed by the following rules:
Lhotka, et al. Expires April 22, 2010 [Page 27]
Internet-Draft Mapping YANG to DSDL October 2009
o Leaf, anyxml and choice nodes are mandatory if they contain the
substatement "mandatory true;". For a choice node this means that
at least one node from exactly one case branch must exist.
o In addition, leaf nodes are mandatory if they are declared as list
keys.
o List or leaf-list nodes are mandatory if they contain 'min-
elements' substatement with argument value greater than zero.
o A container node is mandatory if its definition does not contain
the 'presence' substatement and at least one of its child nodes is
mandatory.
A node is optional iff it is not mandatory.
In RELAX NG, definitions of nodes that are optional must be
explicitly wrapped in the <rng:optional> element. The mapping MUST
use the above rules to determine whether a YANG node is optional and
if so, insert the <rng:optional> element in the conceptual tree
schema.
However, alternatives in <rng:choice> are never defined as optional
in the conceptual tree schema. Therefore, 'anyxml', 'container',
'leaf', 'list' and 'leaf-list' statements appearing as children of
'choice' (shorthand cases) are always mapped to mandatory RELAX NG
patterns. If a choice in YANG is not mandatory, <rng:optional> is
used to wrap the entire <rng:choice> pattern.
9.1.2. Implicit Nodes
The following rules are used to determine whether a given node is
implicit:
o List, leaf-list and anyxml nodes are never implicit.
o A leaf node is implicit if and only if it has a specified default
value (either directly or via its datatype).
o A container node is implicit if and only if it does not have the
'presence' substatement, none of its children is mandatory and at
least one child is implicit.
o As an exception to the above two rules, a leaf or container node
appearing inside a case of a choice can be implicit only if that
case is declared as default by using the 'default' statement, see
Section 7.9.3 in [YANG].
Lhotka, et al. Expires April 22, 2010 [Page 28]
Internet-Draft Mapping YANG to DSDL October 2009
In the conceptual tree schema, all implicit containers MUST be marked
with @nma:implicit attribute with the value "true". In addition, the
default case in a choice (defined by the 'default' substatement of
'choice') MUST be also marked in the same way, i.e., by @nma:implicit
set to "true".
9.2. Mapping YANG Groupings and Typedefs
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 Section
5.5 in [YANG]. 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:
o Names of groupings and typedefs appearing at the top level of the
YANG module hierarchy are prefixed with the module name and two
underscore characters ("__").
o Names of other groupings and typedefs, i.e., those that do not
appear at the top level of a YANG module, are prefixed with the
module name, double underscore, and then the names of all ancestor
data nodes separated by double underscore.
o Since the names of groupings and typedefs in YANG have different
namespaces, an additional underline character is added to the
beginning of the mangled names of all groupings.
EXAMPLE. Consider the following YANG module which imports the
standard module "ietf-inet-types" [Ytypes]:
Lhotka, et al. Expires April 22, 2010 [Page 29]
Internet-Draft Mapping YANG to DSDL October 2009
module example1 {
namespace "http://example.com/ns/example1";
prefix ex1;
import "ietf-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):
Lhotka, et al. Expires April 22, 2010 [Page 30]
Internet-Draft Mapping YANG to DSDL October 2009
<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="ex1:void">
<rng:empty/>
</rng:element>
</rng:optional>
</rng:define>
<rng:define name="_example1__cont__grp2">
<rng:optional>
<rng:element name="ex1:address">
<rng:ref name="ietf-inet-types__ip-address"/>
</rng:element>
</rng:optional>
</rng:define>
<rng:define name="ietf-inet-types__ip-address">
<rng:choice>
<rng:ref name="ietf-inet-types__ipv4-address"/>
<rng:ref name="ietf-inet-types__ipv6-address"/>
</rng:choice>
</rng:define>
<rng:define name="ietf-inet-types__ipv4-address">
<rng:data type="string">
<rng:param name="pattern">... regex pattern ...</param>
</rng:data>
</rng:define>
<rng:define name="ietf-inet-types__ipv6-address">
<rng:data type="string">
<rng:param name="pattern">... regex pattern ...</param>
</rng:data>
</rng:define>
9.2.1. YANG Refinements and Augments
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
Lhotka, et al. Expires April 22, 2010 [Page 31]
Internet-Draft Mapping YANG to DSDL October 2009
statements for this purpose that may appear as substatements of
'uses':
o 'refine' statement allows for changing parameters of a schema node
inside the grouping referenced by the parent 'uses' statement;
o 'augment' statement can be used for adding new schema nodes to the
grouping content.
Both 'refine' and 'augment' statements are quite powerful in that
they can address, using XPath-like expressions as arguments, schema
nodes that are arbitrarily deep inside the grouping content. In
contrast, modifications of named pattern definitions in RELAX NG are
applied 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 8.3) 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 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:
Lhotka, et al. Expires April 22, 2010 [Page 32]
Internet-Draft Mapping YANG to DSDL October 2009
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="ex2:feuille">
<rng:data type="string"/>
</rng:element>
</rng:optional>
</rng:define>
<rng:define name="_example2__es">
<rng:optional>
<rng:element name="ex2:hoja">
<rng:data type="string"/>
</rng:element>
</rng:optional>
</rng:define>
and the configuration data part of the conceptual tree schema is a
single named pattern reference:
<rng:ref name="_example2__leaves"/>
Lhotka, et al. Expires April 22, 2010 [Page 33]
Internet-Draft Mapping YANG to DSDL October 2009
Now assume that the "uses leaves" statement is refined:
uses leaves {
refine "hoja" {
default "alamo";
}
}
The resulting conceptual tree schema now contains just one named
pattern definition - "_example2__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="ex2:hoja" nma:default="alamo">
<rng:data type="string"/>
</rng:element>
</rng:optional>
9.2.2. Type derivation chains
RELAX NG has no equivalent of the type derivation mechanism in YANG,
where a ancestor built-in type may be modified (perhaps 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 ancestor 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 - as a
substatement of either 'leaf' or another 'typedef' - 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 definition MUST be
expanded at that point so that only the ancestor 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:
Lhotka, et al. Expires April 22, 2010 [Page 34]
Internet-Draft Mapping YANG to DSDL October 2009
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="example3__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="ex3:month">
<rng:data type="unsignedByte">
<rng:param name="minInclusive">7</param>
<rng:param name="maxInclusive">12</param>
</rng:data>
</rng:element>
The mapping of type derivation chains may be further complicated by
the presence of the 'default' statement in type definitions. In the
simple case, when a type definition containing the 'default'
statement is used without restrictions, the 'default' statement is
mapped to the @nma:default attribute attached to the <rng:define>
element.
Lhotka, et al. Expires April 22, 2010 [Page 35]
Internet-Draft Mapping YANG to DSDL October 2009
However, if that type definition has to be expanded, the @nma:default
annotation arising from the expanded type or ancestor types in the
type derivation chain MUST be attached to the element where the
expansion occurs. If there are multiple 'default' statements in
consecutive steps of the type derivation, only the 'default'
statement that is closest to the expanded type is used.
EXAMPLE. Consider this variation of the last example:
module example3bis {
namespace "http://example.com/ns/example3bis";
prefix ex3bis;
typedef dozen {
type uint8 {
range 1..12;
}
default 7;
}
leaf month {
type dozen;
}
The 'typedef' statement in this module is mapped to the following
named pattern definition:
<rng:define name="example3bis__dozen" @nma:default="7">
<rng:data type="unsignedByte">
<rng:param name="minInclusive">1</param>
<rng:param name="maxInclusive">12</param>
</rng:data>
</rng:define>
If the "dozen" type is restricted when used in the leaf "month"
definition as in the previous example, the "dozen" type has to be
expanded and @nma:default becomes an attribute of the <ex3bis:month>
element definition:
<rng:element name="ex3bis:month" @nma:default="7">
<rng:data type="unsignedByte">
<rng:param name="minInclusive">7</param>
<rng:param name="maxInclusive">12</param>
</rng:data>
</rng:element>
However, if the definition of leaf "month" itself contained the
'default' substatement, the default specified for the "dozen" type
will be ignored.
Lhotka, et al. Expires April 22, 2010 [Page 36]
Internet-Draft Mapping YANG to DSDL October 2009
9.3. Translation of XPath Expressions
YANG uses full XPath 1.0 syntax [XPath] for the arguments of 'must',
'when' and 'path' statements. However, since the names of data nodes
defined in a YANG module always belong to the namespace of that YANG
module, 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 conceptual tree schema, it MUST be translated into
a fully conformant XPath 1.0 expression that also reflects the
hierarchy of the conceptual data tree:
1. Each unprefixed node name MUST be prepended with the local
module's namespace prefix declared by the 'prefix' statement.
2. Absolute XPath expressions, i.e., those starting with a slash,
MUST be prepended with appropriate path in the conceptual tree,
according to the YANG specification of context for XPath
expressions, see [YANG], sections 7.5.3 and 7.19.5 in [YANG].
Translation rule 2 means for example that absolute XPath expressions
appearing in the main configuration data tree always start with "nmt:
netmod-tree/nmt:top/", those appearing in a notification always start
with "nmt:netmod-tree/nmt:notifications/nmt:notification/", etc.
EXAMPLE. YANG XPath expression "/dhcp/max-lease-time" appearing in
the main configuration data will be translated to "nmt:netmod-tree/
nmt:top/dhcp:dhcp/dhcp:max-lease-time".
The key identifiers and "descendant schema node identifiers" (see the
ABNF production for and "descendant-schema-nodeid" in Section 12 of
[YANG]) are not XPath expressions but SHOULD be translated by adding
local module prefixes as well.
9.4. YANG Language Extensions
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.
Lhotka, et al. Expires April 22, 2010 [Page 37]
Internet-Draft Mapping YANG to DSDL October 2009
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="acme:folio">
<acme:documentation-flag number="42"/>
<rng:data type="string"/>
</rng:element>
Note that the 'extension' statement itself is not mapped in any way.
Lhotka, et al. Expires April 22, 2010 [Page 38]
Internet-Draft Mapping YANG to DSDL October 2009
10. Mapping Conceptual Tree Schema to DSDL
As explained in Section 6, the second step of the YANG-to-DSDL
mapping takes the conceptual tree schema and transforms it to various
DSDL schemas ready for validation. As an input parameter, this step
gets in the simplest case a specification of the NETCONF XML document
type (or combination of multiple types) that is to be validated.
These document type can be, for example, the content of a datastore,
reply to <nc:get> or <nc:get-config>, other RPC requests or replies
and notifications.
In general, the second mapping step has to accomplish the following
three tasks:
1. Extract the part(s) of the conceptual tree schema that are
appropriate for the requested document type. For example, if a
<get> reply is to be validated, the subtree under <nmt:top> must
be selected.
2. The schema must be adapted to the specific encapsulating XML
elements mandated by the RPC layer. These are, for example, <nc:
rpc> and <nc:data> elements in the case of a datastore or <en:
notification> for a notification.
3. Finally, NETMOD-specific annotations that are relevant for the
schema language of the generated schema must be mapped to
corresponding schema-language-specific rules.
These three tasks are together much simpler than the first mapping
step. Presumably, they can be effectively realized using XSL
transformations [XSLT].
The following subsections describe the details of the second mapping
step for the individual DSDL schema languages. Section 12 then
contains a detailed specification for the mapping of all NETMOD-
specific annotations.
10.1. Generating RELAX NG Schemas for Various Document Types
With one minor exception, obtaining a validating RELAX NG schema from
the conceptual tree schema really means only taking appropriate parts
from the conceptual tree schema and assembling them in a new RELAX NG
grammar, perhaps after removing all unwanted annotations. Depending
on the XML document type that is the target for validation (<get>/
<get-config> reply, RPC or notification) a corresponding top-level
part of the grammar MUST be added as described in the following
subsections.
Lhotka, et al. Expires April 22, 2010 [Page 39]
Internet-Draft Mapping YANG to DSDL October 2009
Schemas for multiple alternative target document types can also be
easily generated by enclosing the definitions for requested type in
<rng:choice> element.
In order to avoid copying identical named pattern definitions to the
output RELAX NG file, these schema-independent definitions SHOULD be
collected in a library file which is then included by the validating
RELAX NG schemas. Appendix B has the listing of this library file.
The minor exception mentioned above is the annotation @nma:config,
which must be observed if the target document type is <get-config>
reply. In this case, each element definition that has this attribute
with the value "false" MUST be removed from the schema together with
its descendants. See Section 12.1 for more details.
10.1.1. Reply to <get> or <get-config>
For a reply to <get> or <get-config>, the mapping must take the part
of the conceptual tree schema under the definition of <nmt:top> and
insert it in the following grammar:
<rng:grammar ... namespaces etc. ...>
<rng:include href="relaxng-lib.rng"/>
<rng:start>
<rng:element name="nc:rpc-reply">
<rng:ref name="message-id-attribute"/>
<rng:element name="nc:data">
... patterns defining contents of "nmt:top" subtree ...
</rng:element>
</rng:element>
</rng:start>
... named pattern definitions ...
</rng:grammar>
The definition for the named pattern "message-id-attribute" is found
in the library file "relaxng-lib.rng" which is included on the second
line (see Appendix B).
Definitions of other named patterns MUST be copied from the
conceptual tree schema without any changes to the resulting grammar.
However, an implementation MAY choose to copy only those definitions
that are really used in the particular output grammar.
10.1.2. Remote Procedure Calls
For an RPC method named "myrpc" and defined in a YANG module with
prefix "yam", the corresponding schema subtree is identified by the
definition of <nmt:rpc-method> element whose <nmt:input> subelement
Lhotka, et al. Expires April 22, 2010 [Page 40]
Internet-Draft Mapping YANG to DSDL October 2009
has <yam:myrpc> as the only child.
The mapping must also take into account whether the target document
type is an RPC request or reply. For "yam:myrpc" request, the
resulting grammar looks as follows:
<rng:grammar ... namespaces etc. ...>
<rng:include href="relaxng-lib.rng"/>
<rng:start>
<rng:element name="nc:rpc">
<rng:ref name="message-id-attribute"/>
<rng:element name="yam:myrpc">
... patterns defining contents of subtree ...
... "nmt:rpc-method/nmt:input/yam:myrpc" ...
</rng:element>
</rng:element>
</rng:start>
... named pattern definitions ...
</rng:grammar>
For "myrpc" reply, the output grammar is
<rng:grammar ... namespaces etc. ...>
<rng:include href="relaxng-lib.rng"/>
<rng:start>
<rng:element name="nc:rpc-reply">
<rng:ref name="message-id-attribute"/>
... patterns defining contents of corresponding ...
... "nmt:rpc-method/nmt:output" subtree ...
</rng:element>
</rng:start>
... named pattern definitions ...
</rng:grammar>
In both cases, exact copies of named pattern definitions from the
conceptual tree schema MUST be inserted, but an implementation MAY
choose to include only those used for the given RPC.
10.1.3. Notifications
For a notification named "mynotif" and defined in a YANG module with
prefix "yam", the corresponding schema subtree is identified by the
definition of <nmt:notification> element that has the single child
<yam:mynotif>.
The resulting grammar looks as follows:
Lhotka, et al. Expires April 22, 2010 [Page 41]
Internet-Draft Mapping YANG to DSDL October 2009
<rng:grammar ... namespaces etc. ...>
<rng:include href="relaxng-lib.rng"/>
<rng:start>
<rng:element name="en:notification">
<rng:ref name="eventTime-element"/>
<rng:element name="yam:mynotif">
<!-- patterns defining contents of
"nmt:rpc-notification/yam:mynotif" subtree -->
</rng:element>
</rng:element>
</rng:start>
<!-- named pattern definitions -->
</rng:grammar>
The definition of the named pattern "eventTime-element" is found in
the "relaxng-lib.rng" library file, see Appendix B.
Again, exact copies of named pattern definitions from the conceptual
tree schema MUST be inserted, but an implementation MAY choose to
include only those used for the given notification.
10.2. Mapping Semantic Constraints to Schematron
Schematron schemas tend to be much flatter and more uniform compared
to RELAX NG. They have exactly four levels of XML hierarchy: <sch:
schema>, <sch:pattern>, <sch:rule> and <sch:assert> or <sch:report>.
In a Schematron schema generated by the second mapping step, the
basic unit of organization is a _rule_ represented by the <sch:rule>
element. Every rule corresponds to exactly one element definition
pattern in the conceptual tree schema:
<sch:rule context="XELEM">
...
</sch:rule>
The value of the mandatory @context attribute of <sch:rule> is set to
the absolute path of the context element in the data tree. The <sch:
rule> element contains the mappings of one or more of the following
NETMOD-specific annotations, if they are attached to the context
element: <nma:instance-identifier>, @nma:key, @nma:leafref, @nma:min-
elements, @nma:max-elements, <nma:must>, @nma:unique and <nma:when>.
In the opposite direction, however, not every element definition
pattern in the conceptual tree schema has a corresponding rule in the
Schematron schema: definitions of elements the carry none of the
above annotations are omitted.
Lhotka, et al. Expires April 22, 2010 [Page 42]
Internet-Draft Mapping YANG to DSDL October 2009
Schematron rules may be further grouped into _patterns_ represented
by the <sch:pattern> element. The mapping uses patterns only for
discriminating between subsets of rules that belong to different
validation phases, see Section 10.2.1. Therefore, the <sch:schema>
always has exactly two <sch:pattern> children: one named "standard"
contains rules for all annotations except <nma:instance-identifier>
and @nma:leafref, and another named "ref-integrity" containing rules
for these two remaining annotations, i.e., referential integrity
checks.
Element definitions in the conceptual tree schema that appear inside
a named pattern definition (i.e., have <rng:define> among its
ancestors) are subject to a different treatment. This is because
their path in the data tree is not fixed - the named pattern may be
referred to in multiple different places. The mapping uses
Schematron _abstract rules_ to handle this case: An element
definition inside a named pattern is mapped to an abstract rule and
every use of the named pattern then extends (uses) this abstract rule
in the concrete context.
EXAMPLE. Consider this element pattern annotated with <nma:must>:
<rng:element name="dhcp:default-lease-time">
<rng:data type="unsignedInt"/>
<nma:must assert=". <= ../dhcp:max-lease-time">
<nma:error-message>
The default-lease-time must be less than max-lease-time
</nma:error-message>
</nma:must>
</rng:element>
If this element pattern appears outside any named pattern and as a
child of <dhcp:dhcp> (as it does in the DHCP schema, see
Appendix C.2), it is mapped to the following Schematron rule:
<sch:rule context="/nc:rpc-reply/nc:data/dhcp:dhcp/
dhcp:default-lease-time">
<sch:assert test=". <= ../dhcp:max-lease-time">
The default-lease-time must be less than max-lease-time
</sch:assert>
</sch:rule>
Now assume the element definition is inside a named pattern
definition, say
Lhotka, et al. Expires April 22, 2010 [Page 43]
Internet-Draft Mapping YANG to DSDL October 2009
<rng:define name="_dhcp__default-lease-time">
<rng:element name="dhcp:default-lease-time">
... same content ...
</rng:element>
</rng:define>
In this case it is mapped to an abstract rule, for instance
<sch:rule id="id31415926" abstract="true">
<sch:assert test=". <= ../dhcp:max-lease-time">
The default-lease-time must be less than max-lease-time
</sch:assert>
</sch:rule>
Any use of the named pattern definition via <rng:ref
name="_dhcp__default-lease-time"/> then results in a new rule
extending the abstract one, for example
<sch:rule context="/nc:rpc-reply/nc:data/dhcp:dhcp/
dhcp:default-lease-time">
<sch:extends rule="id31415926"/>
</sch:rule>
Care must be taken that the value of the @context attribute in
general consists of two parts in this case: its beginning is
determined by the location of the <rng:ref> element in the main
schema tree and the rest of the path comes from the relative position
of the annotated element definition inside the named pattern. The
situation becomes even more complex when the mapping has to deal with
chained definitions of named patterns (<rng:ref> inside <rng:
define>). The @context value then must be recursively glued together
from multiple parts.
The mapping from the conceptual tree schema to Schematron proceeds in
the following steps:
1. First, the active subtree(s) of the conceptual tree schema must
be selected depending on the requested target document type.
This procedure is identical to the RELAX NG case, including the
handling of @nma:config if the target document type is <get-
config> reply.
2. Namespaces of all input YANG modules, together with the
namespaces of base NETCONF ("nc" prefix) or notifications ("en"
prefix) MUST be declared using the <sch:ns> element, for example
<sch:ns uri="http://example.com/ns/dhcp" prefix="dhcp"/>
Lhotka, et al. Expires April 22, 2010 [Page 44]
Internet-Draft Mapping YANG to DSDL October 2009
3. Validation phases are defined (see Section 10.2.1) and their
constituting patterns "standard" and "ref-integrity" created.
4. For either validation phase, the input conceptual tree schema is
scanned and element definitions with annotations relevant for the
given phase are selected and a <sch:rule> is created for each of
them. The rule is abstract if the element definition appears
inside a named pattern, see above.
5. All annotations attached to the given element definition are then
mapped using the mapping rules specified in Section 12. The
resulting <sch:assert> or <sch:report> elements are the installed
as children of the <sch:rule> element.
10.2.1. Validation Phases
In certain situations it is useful to validate XML instance documents
without enforcing the referential integrity constraints represented
by the @nma:leafref and <nma:instance-identifier> annotations. For
example, a candidate configuration referring to configuration
parameters or state data of certain hardware will not pass full
validation before the hardware is installed. To handle this, the
Schematron mapping introduces two _validation phases_:
o Validation phase "full", which is the default, checks all semantic
constraints.
o Validation phase "noref" is the same as "full" except it doesn't
check referential integrity constraints.
A parameter identifying the validation phase to use has to be passed
to the Schematron processor or otherwise both patterns are used by
default. How this is exactly done depends on the concrete Schematron
processor and is outside the scope of this document.
The validation phases are defined in Schematron by listing the
patterns that are to be applied for each phase. Therefore, the
mapping puts the rules for referential integrity checking to a
special <sch:pattern> with @id attribute set to "ref-integrity". The
rules mapped from the remaining semantic constraints are put to
another <sch:pattern> with @id attributes set to "standard".
With validation phases, the resulting Schematron schema has the
following overall structure:
Lhotka, et al. Expires April 22, 2010 [Page 45]
Internet-Draft Mapping YANG to DSDL October 2009
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron">
<sch:ns uri="..." prefix="..."/>
... more NS declarations ...
<sch:phase id="full">
<sch:active pattern="standard"/>
<sch:active pattern="ref-integrity"/>
</sch:phase>
<sch:phase id="noref">
<sch:active pattern="standard"/>
</sch:phase>
<sch:pattern id="standard">
... all rules except ref. integrity checks ...
</sch:pattern>
<sch:pattern id="ref-integrity">
... rules for ref. integrity checks ...
</sch:pattern>
</sch:schema>
10.3. Constraints on Mandatory Choice
In order to fully represent the semantics of YANG 'choice' statement
with "mandatory true;" substatement, the RELAX NG grammar has to be
combined with a special Schematron rule.
EXAMPLE. Consider the following module:
module example4 {
namespace "http://example.com/ns/example4";
prefix ex4;
choice foobar {
mandatory true;
case foo {
leaf foo1 {
type uint8;
}
leaf foo2 {
type uint8;
}
}
leaf bar {
type uint8;
}
}
}
In this module, all three leaf nodes in both case branches are
optional but because of the "mandatory true;" statement, at least one
of them must be present in a valid configuration. The 'choice'
Lhotka, et al. Expires April 22, 2010 [Page 46]
Internet-Draft Mapping YANG to DSDL October 2009
statement from this module is mapped to the following fragment of the
conceptual tree schema:
<rng:choice>
<rng:interleave>
<rng:optional>
<rng:element name="ex4:foo1">
<rng:data type="unsignedByte"/>
</rng:element>
</rng:optional>
<rng:optional>
<rng:element name="ex4:foo2">
<rng:data type="unsignedByte"/>
</rng:element>
</rng:optional>
</rng:interleave>
<rng:element name="ex4:bar">
<rng:data type="unsignedByte"/>
</rng:element>
</rng:choice>
In the second case branch, the "ex4:bar" element is defined as
mandatory so that this element must be present in a valid
configuration if this branch is selected. However, the two elements
in the first branch "foo" cannot be both declared as mandatory since
each of them alone suffices for a valid configuration. As a result,
the above RELAX NG fragment would successfully validate
configurations where none of the three leaf elements is present.
Therefore, mandatory choices, which can be recognized in the
conceptual tree schema as <rng:choice> elements that do not have
<optional> as their parent, have to be handled in a special way: For
each mandatory choice where at least one of the cases contains more
than one node, a rule MUST be present in the "standard" pattern of
the Schematron schema enforcing the presence of at least one element
from any of the cases. (RELAX NG schema guarantees that elements
from different cases cannot be mixed together, that all mandatory
nodes are present etc.).
For the example module above, the Schematron rule will be as follows:
<sch:rule context="/nc:rpc-reply/nc:data">
<sch:assert test="ex4:foo1 or ex4:foo2 or ex4:bar">
Node(s) from at least one case of choice "foobar" must exist.
</sch:assert>
</sch:rule>
Lhotka, et al. Expires April 22, 2010 [Page 47]
Internet-Draft Mapping YANG to DSDL October 2009
10.4. Mapping Default Values to DSRL
DSRL is the only component of DSDL that is allowed to change the
information set of the validated XML document. While DSRL has other
functions, the YANG-to-DSDL mapping uses it only for specifying
default content. For XML instance documents based on YANG data
models, insertion of default content may potentially take place for
all implicit nodes, see Section 9.1.
In DSRL, the default content of an element is specified using the
<dsrl:default-content> element, which is a child of <dsrl:element-
map>. Two sibling elements of <dsrl:default-content> determine the
context for application of the default content, see [DSRL]:
o <dsrl:parent> element contains an XSLT pattern specifying the
parent element; the default content is applied only if the parent
element exists in the instance document.
o <dsrl:name> contains the XML name of the element which, if missing
or empty, is inserted together with the content of <dsrl:default-
content>.
The <dsrl:parent> element is optional in a general DSRL schema but
for the purpose of the YANG-to-DSDL mapping this element MUST be
always present in order to guarantee proper application of default
content.
DSRL mapping only deals with element patterns defining implicit nodes
(see Section 9.1.2). In the conceptual tree schema, such element
patterns are distinguished by NETMOD-specific annotation attributes
@nma:default or @nma:implicit, i.e., either
<rng:element name="ELEM" nma:default="DEFVALUE">
...
</rng:element>
or
<rng:element name="ELEM" nma:implicit="true">
...
</rng:element>
In the simple case, these element patterns are mapped to the
following DSRL element map:
Lhotka, et al. Expires April 22, 2010 [Page 48]
Internet-Draft Mapping YANG to DSDL October 2009
<dsrl:element-map>
<dsrl:parent>XPARENT</dsrl:parent>
<dsrl:name>ELEM</dsrl:name>
<dsrl:default-content>DEFCONT</dsrl:default-content>
</dsrl:element-map>
where XPARENT is the absolute XPath of ELEM's parent element in the
data tree and DEFCONT is constructed as follows:
o If the element pattern defining ELEM is annotated with @nma:
default, DEFCONT is equal to the value of this attribute (denoted
above as DEFVALUE).
o Otherwise, if the element pattern defining ELEM is annotated with
@nma:implicit, DEFCONT is an XML fragment containing all
descendant elements of ELEM that have either @nma:implicit or
@nma:default attribute.
Inside the subtree of <rng:choice>, the @nma:default and @nma:
implicit annotations MUST be ignored unless they are descendants of a
<rng:group> or <rng:interleave> pattern with @nma:implicit attribute
set to "true" - this corresponds to the default case of a YANG choice
(see Section 11.12).
When mapping such a default case, it has to be guaranteed that the
default content is be applied if any of the nodes from any non-
default case are present. This is accomplished by setting <dsrl:
parent> in a special way:
<dsrl:parent>XPARENT[not (ELEM1|ELEM2|...|ELEMn)]</dsrl:parent>
where ELEM1, ELEM2, ... ELEMn are the names of top-level nodes from
all non-default cases. The rest of the element map is exactly as
above.
EXAMPLE. Consider the following YANG module:
Lhotka, et al. Expires April 22, 2010 [Page 49]
Internet-Draft Mapping YANG to DSDL October 2009
module example5 {
namespace "http://example.com/ns/example5";
prefix ex5;
container outer {
leaf leaf1 {
type uint8;
default 1;
}
choice one-or-two {
default "one";
container one {
leaf leaf2 {
type uint8;
default 2;
}
}
leaf leaf3 {
type uint8;
default 3;
}
}
}
}
The DSRL schema generated for the "get-reply" target document type
will be:
Lhotka, et al. Expires April 22, 2010 [Page 50]
Internet-Draft Mapping YANG to DSDL October 2009
<dsrl:maps xmlns:dsrl="http://purl.oclc.org/dsdl/dsrl"
xmlns:ex5="http://example.com/ns/example5"
xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
<dsrl:element-map>
<dsrl:parent>/nc:rpc-reply/nc:data</dsrl:parent>
<dsrl:name>ex5:outer</dsrl:name>
<dsrl:default-content>
<ex5:leaf1>1</ex5:leaf1>
<ex5:one><ex5:leaf2>2</ex5:leaf2></ex5:one>
</dsrl:default-content>
</dsrl:element-map>
<dsrl:element-map>
<dsrl:parent>
/nc:rpc-reply/nc:data/ex5:outer[not(ex5:leaf3)]
</dsrl:parent>
<dsrl:name>ex5:one</dsrl:name>
<dsrl:default-content>
<ex5:leaf2>2</ex5:leaf2>
</dsrl:default-content>
</dsrl:element-map>
<dsrl:element-map>
<dsrl:parent>/nc:rpc-reply/nc:data/ex5:outer</dsrl:parent>
<dsrl:name>ex5:leaf1</dsrl:name>
<dsrl:default-content>1</dsrl:default-content>
</dsrl:element-map>
<dsrl:element-map>
<dsrl:parent>/nc:rpc-reply/nc:data/ex5:outer</dsrl:parent>
<dsrl:name>ex5:one</dsrl:name>
<dsrl:default-content>
<ex5:leaf2>2</ex5:leaf2>
</dsrl:default-content>
</dsrl:element-map>
<dsrl:element-map>
<dsrl:parent>/nc:rpc-reply/nc:data/ex5:outer/ex5:one</dsrl:parent>
<dsrl:name>ex5:leaf2</dsrl:name>
<dsrl:default-content>2</dsrl:default-content>
</dsrl:element-map>
</dsrl:maps>
Note that the default value for "leaf3" defined in the YANG module is
ignored, because "leaf3" represents a non-default alternative of a
choice and as such can never become an implicit element.
YANG leaf nodes may also obtain a default value from their type
definition. Consequently, @nma:default attributes may also be
attached to <rng:define> elements. The DSRL mapping MUST handle all
<rng:element> patterns that refer to such a named pattern definition
and don't have their own @nma:default attribute in the same way as if
Lhotka, et al. Expires April 22, 2010 [Page 51]
Internet-Draft Mapping YANG to DSDL October 2009
the @nma:default attributed was attached to the referring <rng:
element>.
Finally, if there is a chain of named pattern definitions containing
multiple @nma:default attributes, only the topmost @nma:default
annotation is taken into account.
Lhotka, et al. Expires April 22, 2010 [Page 52]
Internet-Draft Mapping YANG to DSDL October 2009
11. Mapping YANG Statements to Conceptual Tree Schema
Each subsection in this section is devoted to one YANG statement and
provides the specification 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 6. 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 procedure 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. Any changes to this default recursive procedure are
explicitly specified.
YANG XML encoding rules translate to the following rules for ordering
multiple subelements:
1. Within the <nmt:rpc-methods> subtree (i.e., for RPC input and
output parameters) the order of subelements is fixed and their
definitions in the conceptual tree schema MUST follow the order
specified in the source YANG module.
2. When mapping the 'list' statement, all keys MUST come before any
other subelements and in the same order as they are declared in
the 'key' statement. The order of the remaining (non-key)
subelements is not specified, so their definitions in the
conceptual tree schema MUST be enclosed in the <rng:interleave>
element.
3. Otherwise, all definitions of subelements in the conceptual tree
schema MUST be enclosed in the <rng:interleave> element.
We use the following notation:
o The argument of the statement being mapped is denoted by ARGUMENT.
o The element in the RELAX NG schema that becomes the parent of the
resulting XML fragment is denoted by PARENT.
11.1. The anyxml Statement
This statement is mapped to <rng:element> element and ARGUMENT with
prepended local namespace prefix becomes the value of its @name
attribute. The content of <rng:element> is
Lhotka, et al. Expires April 22, 2010 [Page 53]
Internet-Draft Mapping YANG to DSDL October 2009
<rng:ref name="__anyxml__"/>
Substatements of the 'anyxml' statement, if any, may be 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. [Vli04],
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 in a module with namespace prefix "yam"
anyxml data {
description "Any XML content allowed here.";
}
is mapped to the following fragment:
<rng:element name="yam:data">
<a:documentation>Any XML content allowed here</a:documentation>
<rng:ref name="__anyxml__"/>
</rng:element>
An anyxml node is optional if there is no "mandatory true;"
substatement. The <rng:element> element then MUST be wrapped in
<rng:optional>, except when the 'anyxml' statement is a child of the
'choice' statement and thus forms a shorthand case for that choice
(see Section 9.1.1 for details).
11.2. The argument Statement
This statement is not mapped to the output schema, but see the rules
for handling extensions in Section 9.4.
Lhotka, et al. Expires April 22, 2010 [Page 54]
Internet-Draft Mapping YANG to DSDL October 2009
11.3. The augment Statement
As a substatement of 'uses', this statement is handled as a part of
'uses' mapping, see Section 11.57.
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.
11.4. The base Statement
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 11.53.5.
11.5. The belongs-to Statement
This statement is not used since processing of submodules is always
initiated from the main module, see Section 11.24.
11.6. The bit Statement
This statement is handled within the "bits" type, see
Section 11.53.3.
11.7. The case Statement
This statement is mapped to <rng:group> or <rng:interleave> element,
depending on whether the statement belongs to an RPC definition or
not. If the argument of a sibling 'default' statement equals to
ARGUMENT, @nma:implicit attribute with the value "true" MUST be added
to that <rng:group> or <rng:interleave> element. The @nma:implicit
attribute MUST NOT be used for nodes that belong to non-default cases
of a choice (see Section 7.9.3 in [YANG]).
11.8. The choice Statement
This statement is mapped to <rng:choice> element.
Unless 'choice' has the 'mandatory' substatement with the value
"true", the <rng:choice> element MUST be wrapped in <rng:optional>.
The 'choice' statement with "mandatory true;" requires additional
handling, see Section 10.3.
The alternatives in <rng:choice> - mapped from either the 'case'
Lhotka, et al. Expires April 22, 2010 [Page 55]
Internet-Draft Mapping YANG to DSDL October 2009
statement or a shorthand case - MUST NOT be defined as optional.
11.9. The config Statement
This statement is mapped to @nma:config attribute and ARGUMENT
becomes its value.
11.10. The contact Statement
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 11.34. The original
YANG modules are the authoritative sources of the authorship
information.
11.11. The container Statement
Using the rules specified in Section 9.1.1, 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
with prepended local namespace prefix as the value of its @name
attribute.
Finally, using the rules specified in Section 9.1.2, the mapping
algorithm MUST determine whether the container is implicit, and if
so, add the attribute @nma:implicit with the value "true" to the
<rng:element> element.
11.12. The default Statement
If this statement is a substatement of 'leaf', it is mapped to the
@nma:default attribute of PARENT and ARGUMENT becomes its value.
As a substatement of 'typedef', the 'default' statement is also
mapped to the @nma:default attribute with the value of ARGUMENT. The
placement of this attribute depends on whether or not the type
definition has to be expanded when it is used:
o If the type definition is not expanded, @nma:default becomes an
attribute of the <rng:define> pattern resulting from the parent
'typedef' mapping.
Lhotka, et al. Expires April 22, 2010 [Page 56]
Internet-Draft Mapping YANG to DSDL October 2009
o Otherwise, @nma:default becomes an attribute of the ancestor RELAX
NG pattern inside which the expansion takes place.
Details and an example are given in Section 9.2.2.
Finally, as a substatement of 'choice', the 'default' statement
identifies the default case and is handled within the 'case'
statement, see Section 11.7. If the default case uses the shorthand
notation where the 'case' statement is omitted, an extra <rng:group>
or <rng:interleave> element MUST be inserted with @nma:implicit
attribute set to "true" and the default case node is mapped inside
this element. The net result is then the same as if the 'case'
statement wasn't omitted for the default case.
EXAMPLE. The following 'choice' statement in a module with namespace
prefix "yam"
choice leaves {
default feuille;
leaf feuille { type empty; }
leaf hoja { type empty; }
}
is mapped to
<rng:choice>
<rng:interleave nma:implicit="true">
<rng:element name="yam:feuille">
<rng:empty/>
</rng:element>
</rng:interleave>
<rng:element name="yam:hoja">
<rng:empty/>
</rng:element/>
</rng:choice>
11.13. The description Statement
This statement MAY be ignored. Otherwise, it 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.
Lhotka, et al. Expires April 22, 2010 [Page 57]
Internet-Draft Mapping YANG to DSDL October 2009
11.14. The deviation Statement
This statement is ignored, see Section 8.5.
11.15. The enum Statement
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 annotation elements, see [RNG],
section 6.
11.16. The error-app-tag Statement
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 11.35.
11.17. The error-message Statement
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 11.35.
11.18. The extension Statement
This statement is ignored. However, extensions to the YANG language
MAY be mapped as described in Section 9.4.
11.19. The feature Statement
This statement is ignored, see Section 8.5.
11.20. The grouping Statement
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 9.2.
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 9.2.1 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
Lhotka, et al. Expires April 22, 2010 [Page 58]
Internet-Draft Mapping YANG to DSDL October 2009
they are not referenced. This is useful for mapping YANG "library"
modules containing only 'typedef' and/or 'grouping' statements.
11.21. The identity Statement
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 11.53.5 for more details and an example.
11.22. The if-feature Statement
This statement is ignored, see Section 8.5.
11.23. The import Statement
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.
11.24. The include Statement
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.
11.25. The input Statement
This statement is handled within 'rpc' statement, see Section 11.50.
11.26. The key Statement
This statement is mapped to @nma:key attribute. ARGUMENT is MUST be
translated so that every key is prefixed with the namespace prefix of
the local module. The result of this translation then becomes the
value of the @nma:key attribute.
Lhotka, et al. Expires April 22, 2010 [Page 59]
Internet-Draft Mapping YANG to DSDL October 2009
11.27. The leaf Statement
This statement is mapped to the <rng:element> element and ARGUMENT
with prepended local namespace prefix becomes the value of its @name
attribute.
A leaf is optional if there is no "mandatory true;" substatement and
if the leaf is not declared among the keys of an enclosing list. The
<rng:element> element then MUST be wrapped in <rng:optional>, except
when the 'leaf' statement is a child of the 'choice' statement and
thus forms a shorthand case for that choice (see Section 9.1.1 for
details).
11.28. The leaf-list Statement
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.
<rng:element> is then added as a child element of PARENT and ARGUMENT
with prepended local namespace prefix becomes the value of its @name
attribute. If the 'leaf-list' statement has the 'min-elements'
substatement and its argument is greater than one, additional
attribute @nma:min-elements is attached to <rng:element> and the
argument of 'min-elements' becomes the value of this attribute.
Similarly, if there is the 'max-elements' substatement and its
argument value is not "unbounded", attribute @nma:max-elements is
attached to this element and the argument of 'max-elements' becomes
the value of this attribute.
EXAMPLE. YANG leaf-list in a module with namespace prefix "yam"
leaf-list foliage {
min-elements 3;
max-elements 6378;
ordered-by user;
type string;
}
is mapped to the following RELAX NG fragment:
<rng:oneOrMore>
<rng:element name="yam:foliage" nma:ordered-by="user"
nma:min-elements="3" nma:max-elements="6378">
<rng:data type="string"/>
</rng:element>
Lhotka, et al. Expires April 22, 2010 [Page 60]
Internet-Draft Mapping YANG to DSDL October 2009
</rng:oneOrMore>
11.29. The length Statement
This statement is handled within the "string" type, see
Section 11.53.9.
11.30. The list Statement
This statement is mapped exactly as the 'leaf-list' statement, see
Section 11.28.
When mapping the substatements of 'list', the order of children of
the list element MUST be specified so that list keys always appear in
the same order as they are defined in the input YANG module and
before other children, see [YANG], Section 7.8.5. In particular, if
any list key is defined in a grouping but the list itself is not
defined in the same grouping, and the position of the 'uses'
statement would violate the above ordering requirement, the grouping
MUST be expanded, i.e., the 'uses' statement replaced by the grouping
contents.
For example, consider the following YANG fragment of a module with
prefix "yam":
grouping keygrp {
leaf clef {
type uint8;
}
}
list foo {
key clef;
leaf bar {
type string;
}
leaf baz {
type string;
}
uses keygrp;
}
is mapped to the following RELAX NG fragment:
Lhotka, et al. Expires April 22, 2010 [Page 61]
Internet-Draft Mapping YANG to DSDL October 2009
<rng:zeroOrMore>
<rng:element name="yam:foo" nma:key="yam:clef">
<rng:element name="yam:clef">
<rng:data type="unsignedByte"/>
</rng:element>
<rng:interleave>
<rng:element name="yam:bar">
<rng:data type="string"/>
</rng:element>
<rng:element name="yam:baz">
<rng:data type="string"/>
</rng:element>
</rng:interleave>
</rng:element>
</rng:zeroOrMore>
Note that the "keygrp" grouping is expanded and the "yam:clef"
definition moved before the <rng:interleave> pattern.
11.31. The mandatory Statement
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 9.1.1.
11.32. The max-elements Statement
This statement is handled within 'leaf-list' or 'list' statements,
see Section 11.28.
11.33. The min-elements Statement
This statement is handled within 'leaf-list' or 'list' statements,
see Section 11.28.
11.34. The module Statement
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 11.49.
With respect to the conceptual tree schema, substatements of 'module'
MUST be mapped so that
o top level data elements be defined as children of the <nmt:top>
element;
Lhotka, et al. Expires April 22, 2010 [Page 62]
Internet-Draft Mapping YANG to DSDL October 2009
o elements mapped from 'rpc' statements be defined as children of
the <nmt:rpc-methods> element;
o elements mapped from 'notification' statements be defined as
children of the <nmt:notifications> element.
11.35. The must Statement
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 9.3).
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>
11.36. The namespace Statement
This statement is mapped to @xmlns:xxx attribute of the <rng:grammar>
element where "xxx" is the namespace prefix specified by the sibling
'prefix' statement. ARGUMENT becomes the value of this attribute.
11.37. The notification Statement
This statement is mapped to the following subtree in the RELAX NG
schema ("yam" is the prefix of the local YANG module):
<rng:element name="nmt:notification">
<rng:element name="yam:ARGUMENT">
...
</rng:element>
</rng:element>
Lhotka, et al. Expires April 22, 2010 [Page 63]
Internet-Draft Mapping YANG to DSDL October 2009
Substatements of 'notification' are mapped under <rng:element
name="yam:ARGUMENT">.
The <rng:element name="nmt:rpc-notification"> element is a child of
<rng:element name="nmt:notifications">.
11.38. The ordered-by Statement
This statement is mapped to @nma:ordered-by attribute and ARGUMENT
becomes the value of this attribute. See Section 11.28 for an
example.
11.39. The organization Statement
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 11.34. The original
modules are the authoritative sources of the authorship information.
11.40. The output Statement
This statement is handled within 'rpc' statement, see Section 11.50.
11.41. The path Statement
This statement is handled within "leafref" type, see Section 11.53.7.
11.42. The pattern Statement
This statement is handled within "string" type, see Section 11.53.9.
11.43. The position Statement
This statement is ignored.
11.44. The prefix Statement
This statement is handled within the sibling 'namespace' statement,
see Section 11.36, or within the parent 'import' statement, see
Section 11.23. As a substatement of 'belongs-to' (in submodules),
the 'prefix' statement is ignored.
11.45. The presence Statement
This statement is mapped to the annotation attribute @nma:presence
with the value "true". In addition, it influences the mapping of
'container' (Section 11.11): the parent container definition MUST be
Lhotka, et al. Expires April 22, 2010 [Page 64]
Internet-Draft Mapping YANG to DSDL October 2009
wrapped in <rng:optional>, regardless of its content. See also
Section 9.1.1.
11.46. The range Statement
This statement is handled within numeric types, see Section 11.53.8.
11.47. The reference Statement
This statement MAY be ignored. Otherwise, it is mapped to
<a:documentation> element and its text is set to ARGUMENT prefixed
with "See: ".
11.48. The require-instance Statement
This statement is handled within "instance-identifier" type
(Section 11.53.6).
11.49. The revision Statement
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 [YANG]. This
date SHOULD be recorded, together with the name of the YANG module,
in the corresponding Dublin Core element <dc:source> (see
Section 11.34), for example in this form:
<dc:source>YANG module 'foo', revision 2009-01-19</dc:source>
The 'description' substatement of 'revision' is not used.
11.50. The rpc Statement
This statement is mapped to the following subtree in the RELAX NG
schema ("yam" is the prefix of the local YANG module):
<rng:element name="nmt:rpc-method">
<rng:element name="nmt:input">
<rng:element name="yam:ARGUMENT">
<!-- mapped content of 'input' -->
</rng:element>
</rng:element>
<rng:element name="nmt:output">
<!-- mapped content of 'output' -->
</rng:element>
</rng:element>
As indicated by the comments, contents of the 'input' substatement
Lhotka, et al. Expires April 22, 2010 [Page 65]
Internet-Draft Mapping YANG to DSDL October 2009
(if any) are mapped under <rng:element name="yam:ARGUMENT">.
Similarly, contents of the 'output' substatement are mapped under
<rng:element name="nmt:output">. If there is no 'output'
substatement, the <rng:element name="nmt:output"> MUST NOT be
present.
The <rng:element name="nmt:rpc-method"> element is a child of <rng:
element name="nmt:rpc-methods">.
11.51. The status Statement
This statement MAY be ignored. Otherwise, it is mapped to @nma:
status attribute and ARGUMENT becomes its value.
11.52. The submodule Statement
This statement is not specifically mapped. Its substatements are
mapped as if they appeared directly in the module the submodule
belongs to.
11.53. The type Statement
Most YANG built-in types have an equivalent in the XSD datatype
library [XSD-D] as shown in Table 3.
Lhotka, et al. Expires April 22, 2010 [Page 66]
Internet-Draft Mapping YANG to DSDL October 2009
+-----------+---------------+--------------------------------+
| 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 |
| | | |
| 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.
11.53.1. The empty Type
This type is mapped to <rng:empty/>.
11.53.2. The boolean and binary Types
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 above.
11.53.3. The bits Type
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>
Lhotka, et al. Expires April 22, 2010 [Page 67]
Internet-Draft Mapping YANG to DSDL October 2009
</rng:optional>
where bit_name is the name of the bit as found in the argument of the
corresponding 'bit' statement.
11.53.4. The enumeration and union Types
These types are mapped to <rng:choice> element.
11.53.5. The identityref Type
This type is mapped to <rng:choice> element with one or more <rng:
value> subelements. Each of the <rng:value> subelements MUST have
the @type attribute and its value set to "QName". One <rng:value>
subelement for the base identity MUST always be present - it contains
the argument of the 'base' substatement as its text. In addition,
one <rng:value> substatement MUST be added for each identity declared
locally or in an imported module that is derived from this base
identity.
All namespace prefixes that are used for identities from imported
modules MUST be appropriately defined.
EXAMPLE (taken from Section 7.16.3 of [YANG]). Consider the
following two YANG modules:
Lhotka, et al. Expires April 22, 2010 [Page 68]
Internet-Draft Mapping YANG to DSDL October 2009
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 with namespace
prefix "yam", leaf definition
leaf crypto {
type identityref {
base "crypto:crypto-alg";
}
}
is mapped to
<rng:element name="yam: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>
Lhotka, et al. Expires April 22, 2010 [Page 69]
Internet-Draft Mapping YANG to DSDL October 2009
The "crypto" and "des" prefixes will by typically defined via
attributes of the <rng:grammar> element.
11.53.6. The instance-identifier Type
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>.
11.53.7. The leafref Type
This type is mapped exactly as the type of the leaf given in the
argument of 'path' substatement. In addition, @nma:leafref attribute
MUST be added to PARENT. The argument of the 'path' substatement,
translated according to Section 9.3, is set as the value of this
attribute.
11.53.8. The numeric Types
YANG built-in numeric types are "int8", "int16", "int32", "int64",
"uint8", "uint16", "uint32", "uint64" and "decimal64". They are
mapped to <rng:data> element with @type attribute set to ARGUMENT
mapped according to Table 3.
An exception is the "decimal64" type, which is mapped to the
"decimal" type of the XSD datatype library. Its precision and number
of fractional digits are controlled with the following facets, which
MUST always be present:
o "totalDigits" facet set to the value of 19.
o "fractionDigits" facet set to the argument of the 'fraction-
digits' substatement.
The fixed value of the "totalDigits" facet corresponds to the maximum
of 19 decimal digits for 64-bit integers.
For example, the statement
type decimal64 {
fraction-digits 2;
}
is mapped to the following RELAX NG datatype:
Lhotka, et al. Expires April 22, 2010 [Page 70]
Internet-Draft Mapping YANG to DSDL October 2009
<rng:data type="decimal">
<rng:param name="totalDigits">19</rng:param>
<rng:param name="fractionDigits">2</rng:param>
</rng:data>
All numeric types support the 'range' restriction, which is handled
as follows:
If the range expression has just a single range, then
o if the range consists of a single number, the <rng:value> pattern
is inserted and its content set to this number.
o Otherwise the range consists of both lower and upper bound and the
following pair of datatype facets are inserted:
<rng:param name="minInclusive">...</rng:param>
and
<rng:param name="maxInclusive">...</rng:param>
Their contents are the lower and upper bound, respectively. If
the lower bound is "min", the "minInclusive" facet is omitted and
if the upper bound is "max", the "maxInclusive" facet is omitted.
If the range expression has multiple parts separated by "|", then the
parent <rng:data> element must be repeated once for every range part
and all the <rng:data> elements are wrapped in <rng:choice> element.
Each <rng:data> element contains the <rng:value> pattern or the
"minInclusive" and "maxInclusive" facets for the corresponding part
of the range expression as described in the previous paragraph. For
the "decimal64" type, the "totalDigits" and "fractionDigits" must be
repeated inside each of the <rng:data> elements.
For example,
type int32 {
range "-6378..0|42|100..max";
}
is mapped to the following RELAX NG fragment:
Lhotka, et al. Expires April 22, 2010 [Page 71]
Internet-Draft Mapping YANG to DSDL October 2009
<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:value>42</rng:value>
</rng:data>
<rng:data type="int">
<rng:param name="minInclusive">100</rng:param>
</rng:data>
</rng:choice>
11.53.9. The string Type
This type is mapped to <rng:data> element with the @type attribute
set to "string".
The 'length' restriction is handled analogically to the 'range'
restriction for the numeric types (Section 11.53.8):
If the length expression has just a single range, then
o if the length range consists of a single number L, the following
datatype facet is inserted:
<rng:param name="length">L</rng:param>.
o Otherwise the length range consists of both lower and upper bound
and the following pair of datatype facets are inserted:
<rng:param name="minLength">...</rng:param>
and
<rng:param name="maxLength">...</rng:param>
Their contents are the lower and upper bound of the length range,
respectively. If the lower bound is "min", the "minLength" facet
is omitted and if the upper bound is "max", the "maxLength" facet
is omitted.
If the length expression has of multiple parts separated by "|", then
the parent <rng:data> element must be repeated once for every range
part and all the <rng:data> elements are wrapped in <rng:choice>
element. Each <rng:data> element contains the "length" or
"minLength" and "maxLength" facets for the corresponding part of the
length expression as described in the previous paragraph.
Lhotka, et al. Expires April 22, 2010 [Page 72]
Internet-Draft Mapping YANG to DSDL October 2009
Every 'pattern' restriction of the "string" datatype is mapped to the
"pattern" facet
<rng:param name="pattern">...</rng:param>
with content equal to the argument of the 'pattern' statement. All
such "pattern" facets must be repeated inside each copy of the <rng:
data> element, i.e., once for each length range.
For example,
type string {
length "1|3..8";
pattern "[A-Z][a-z]*";
}
is mapped to the following RELAX NG fragment:
<rng:choice>
<rng:data type="string">
<rng:param name="length">1</rng:param>
<rng:param name="pattern">[A-Z][a-z]*</rng:param>
</rng:data>
<rng:data type="string">
<rng:param name="minLength">3</rng:param>
<rng:param name="maxLength">8</rng:param>
<rng:param name="pattern">[A-Z][a-z]*</rng:param>
</rng:data>
</rng:choice>
11.53.10. Derived Types
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:
1. Without restrictions, the 'type' statement is mapped simply to
the <rng:ref> element, i.e., a reference to a named pattern. If
the RELAX NG definition of this named pattern has not been added
to the output schema yet, the corresponding 'typedef' must be
found and its mapping installed as a subelement of <rng:grammar>,
see Section 11.54. Even if a given derived type is used more
than once in the input YANG modules, the mapping of the
corresponding 'typedef' MUST be installed only once.
2. If any restrictions are present, the ancestor built-in type for
the given derived type must be determined and the mapping of this
base type is used. Restrictions appearing at all stages of the
Lhotka, et al. Expires April 22, 2010 [Page 73]
Internet-Draft Mapping YANG to DSDL October 2009
derivation chain must be taken into account and their conjunction
added to the <rng:data> element which defines the basic type.
See Section 9.2.2 for more details and an example.
11.54. The typedef Statement
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 9.2.
Whenever a derived type is used with additional restrictions, the
ancestor built-in 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 11.53.10 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.
11.55. The unique Statement
This statement is mapped to @nma:unique attribute. ARGUMENT is
translated so that every node identifier in each of its components is
prefixed with the namespace prefix of the local module, unless the
prefix is already present. The result of this translation then
becomes the value of the @nma:unique attribute.
For example, assuming that the local module prefix is "ex",
unique "foo ex:bar/baz"
is mapped to the following attribute/value pair:
nma:unique="ex:foo ex:bar/ex:baz"
11.56. The units Statement
This statement is mapped to @nma:units attribute and ARGUMENT becomes
its value.
11.57. The uses Statement
If this statement has neither 'refine' nor 'augment' substatements,
it is mapped to <rng:ref> element and the value of its @name
Lhotka, et al. Expires April 22, 2010 [Page 74]
Internet-Draft Mapping YANG to DSDL October 2009
attribute is set to ARGUMENT mangled according to Section 9.2
If there are any 'refine' or 'augment' substatements, the
corresponding grouping must be looked up and its contents is inserted
under PARENT. See Section 9.2.1 for further details and an example.
11.58. The value Statement
This statement is ignored.
11.59. The when Statement
This statement is mapped to @nma:when attribute and ARGUMENT,
translated according to Section 9.3, becomes it value.
11.60. The yang-version Statement
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).
11.61. The yin-element Statement
This statement is not mapped to the output schema, but see the rules
for extension handling in Section 9.4.
Lhotka, et al. Expires April 22, 2010 [Page 75]
Internet-Draft Mapping YANG to DSDL October 2009
12. Mapping NETMOD-specific annotations to DSDL Schema Languages
This section contains mapping specification for individual NETMOD-
specific annotations. In each case, the result of the mapping must
be inserted into an appropriate context of the target DSDL schema as
described in Section 10. The context is determined by the element
definition in the conceptual tree schema to which the annotation is
attached. In the rest of this section, we will denote CONTELEM the
name of this context element properly qualified with its namespace
prefix. Unless otherwise stated, Schematron asserts are descendants
of the "standard" pattern and therefore active in both validation
phases.
12.1. The @nma:config Annotation
If this annotation is present with the value "true", the following
rules apply for DSDL schemas of <nc:get-config> reply. In
particular:
o When generating RELAX NG, the contents of the CONTELEM definition
MUST be changed to <rng:notAllowed>.
o When generating Schematron or DSRL, the CONTELEM definition and
all its descendants in the conceptual tree schema MUST be ignored.
12.2. The @nma:default Annotation
This annotation is used for generating the DSRL schema as described
in Section 10.4.
12.3. The @nma:implicit Annotation
This annotation is used for generating the DSRL schema as described
in Section 10.4.
12.4. The <nma:error-app-tag> Annotation
This annotation currently has no mapping defined.
12.5. The <nma:error-message> Annotation
This annotation is handled within <nma:must>, see Section 12.11.
12.6. The <nma:instance-identifier> Annotation
If this annotation element has the @require-instance attribute with
the value "false", it is ignored. Otherwise it is mapped to the
following Schematron assert:
Lhotka, et al. Expires April 22, 2010 [Page 76]
Internet-Draft Mapping YANG to DSDL October 2009
<sch:assert test="nmf:evaluate(.)">
The element pointed to by "CONTELEM" must exist.
</sch:assert>
The nmf:evaluate() function is an XSLT extension function (see
Extension Functions in [XSLT]) that evaluates an XPath expression at
runtime. Such an extension function is provided by some XSLT
processors, for example Saxon [3].
12.7. The @nma:key Annotation
Assume this annotation has the value "k_1 k_2 ... k_n", i.e.,
specifies n child leaves as keys. The annotation is then mapped to
the following Schematron report:
<sch:report test="CONDITION">
Duplicate key of list "CONTELEM"
</sch:report>
where CONDITION has this form:
preceding-sibling::CONTELEM[C_1 and C_2 and ... and C_n]
Each C_i, for i=1,2,...,n, specifies the condition for violation of
uniqueness of key k_i, namely
k_i=current()/k_i
12.8. The @nma:leafref Annotation
This annotation is mapped to the following assert:
<sch:assert test="PATH=.">
Leafref "CONTELEM" must have the same value as "PATH"
</sch:assert>
where PATH is the value of @nma:leafref. The assert is a descendant
of the "ref-integrity" pattern, which means that it will be used only
for the "full" validation phase.
12.9. The @nma:min-elements Annotation
This annotation is mapped to the following Schematron assert:
<sch:assert test="count(../CONTELEM)>=MIN">
List "CONTELEM" - item count must be at least MIN
</sch:assert>
where MIN is the value of @nma:min-elements.
Lhotka, et al. Expires April 22, 2010 [Page 77]
Internet-Draft Mapping YANG to DSDL October 2009
12.10. The @nma:max-elements Annotation
This annotation is mapped to the following Schematron assert:
<sch:assert test="count(../CONTELEM)<=MAX">
List "CONTELEM" - item count must be at most MAX
</sch:assert>
where MAX is the value of @nma:min-elements.
12.11. The <nma:must> Annotation
This annotation is mapped to the following Schematron assert:
<sch:assert test="EXPRESSION">
MESSAGE
</sch:assert>
where EXPRESSION is the value of the mandatory @assert attribute of
<nma:must>. If the <nma:error-message> subelement exists, MESSAGE is
set to its content, otherwise it is set to the default message
"Condition EXPRESSION must be true".
12.12. The <nma:ordered-by> Annotation
This annotation currently has no mapping defined.
12.13. The <nma:status> Annotation
This annotation currently has no mapping defined.
12.14. The @nma:unique Annotation
The mapping of this annotation is almost identical as for @nma:key,
see Section 12.7, with two small differences:
o The value of @nma:unique is a list of descendant schema node
identifiers rather than simple leaf names. However, the XPath
expressions specified in Section 12.7 work without any
modifications if the descendant schema node identifiers are
substituted for k_1, k_2, ..., k_n.
o The message appearing as the text of <sch:report> is different:
"Violated uniqueness for list CONTELEM".
Lhotka, et al. Expires April 22, 2010 [Page 78]
Internet-Draft Mapping YANG to DSDL October 2009
12.15. The @nma:when Annotation
This annotation is mapped to the following Schematron assert:
<sch:assert test="EXPRESSION">
Node "CONTELEM" is only valid if "EXPRESSION" is true.
</sch:assert>
where EXPRESSION is the value of @nma:when.
Lhotka, et al. Expires April 22, 2010 [Page 79]
Internet-Draft Mapping YANG to DSDL October 2009
13. IANA Considerations
This document registers three namespace URIs in the IETF XML registry
[RFC3688]:
URI: urn:ietf:params:xml:ns:netmod:dsdl-annotations:1
URI: urn:ietf:params:xml:ns:netmod:conceptual-tree:1
urn:ietf:params:xml:ns:netmod:xpath-extensions:1
Lhotka, et al. Expires April 22, 2010 [Page 80]
Internet-Draft Mapping YANG to DSDL October 2009
14. Security Considerations
This document defines a procedure that maps data models expressed in
the YANG language to a coordinated set of DSDL schemas. The
procedure itself has no security impact on the Internet.
DSDL schemas obtained by the mapping procedure may be used for
validating the content of NETCONF protocol data units or entire data
stores and thus provide additional validity checks above those
performed by NETCONF server and client implementations supporting
YANG data models. The strictness of this validation is directly
derived from the source YANG modules that the validated XML data
adhere to.
Lhotka, et al. Expires April 22, 2010 [Page 81]
Internet-Draft Mapping YANG to DSDL October 2009
15. Acknowledgements
The authors wish to thank the following individuals who provided
helpful suggestions and/or comments on various versions of this
document: Andy Bierman, Martin Bjorklund, Jirka Kosek and Phil
Shafer.
Lhotka, et al. Expires April 22, 2010 [Page 82]
Internet-Draft Mapping YANG to DSDL October 2009
16. References
16.1. Normative References
[DSDL] ISO/IEC, "Document Schema Definition Languages (DSDL) -
Part 1: Overview", ISO/IEC 19757-1, 11 2004.
[DSRL] ISO/IEC, "Information Technology - Document Schema
Definition Languages (DSDL) - Part 8: Document Semantics
Renaming Language - DSRL", ISO/IEC 19757-8:2008(E),
12 2008.
[NVDL] ISO/IEC, "Information Technology - Document Schema
Definition Languages (DSDL) - Part 4: Namespace-Based
Validation Dispatching Language (NVDL)", ISO/
IEC 19757-4:2006(E), 6 2006.
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", BCP 14, RFC 2119, March 1997.
[RFC3688] Mealling, M., "The IETF XML Registry", BCP 81, RFC 3688,
January 2004.
[RFC4741] Enns, R., "NETCONF Configuration Protocol", RFC 4741,
December 2006.
[RFC5013] Kunze, J., "The Dublin Core Metadata Element Set",
RFC 5013, August 2007.
[RNG] 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.
[RNG-CS] 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.
[RNG-DTD] Clark, J., Ed. and M. Murata, Ed., "RELAX NG DTD
Compatibility", OASIS Committee Specification 3 December
2001, December 2001.
[Schematron]
ISO/IEC, "Information Technology - Document Schema
Definition Languages (DSDL) - Part 3: Rule-Based
Validation - Schematron", ISO/IEC 19757-3:2006(E), 6 2006.
Lhotka, et al. Expires April 22, 2010 [Page 83]
Internet-Draft Mapping YANG to DSDL October 2009
[XML] 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,
<http://www.w3.org/TR/2006/REC-xml-20060816>.
[XPath] Clark, J. and S. DeRose, "XML Path Language (XPath)
Version 1.0", World Wide Web Consortium
Recommendation REC-xpath-19991116, November 1999,
<http://www.w3.org/TR/1999/REC-xpath-19991116>.
[XSD-D] Biron, P. and A. Malhotra, "XML Schema Part 2: Datatypes
Second Edition", World Wide Web Consortium
Recommendation REC-xmlschema-2-20041028, October 2004,
<http://www.w3.org/TR/2004/REC-xmlschema-2-20041028>.
[XSLT] Clark, J., "XSL Transformations (XSLT) Version 1.0", World
Wide Web Consortium Recommendation REC-xslt-19991116,
November 1999.
[YANG] Bjorklund, M., Ed., "YANG - A data modeling language for
NETCONF", draft-ietf-netmod-yang-04 (work in progress),
March 2009.
16.2. Informative References
[RFC1157] Case, J., Fedor, M., Schoffstall, M., and J. Davin,
"Simple Network Management Protocol (SNMP)", STD 15,
RFC 1157, May 1990.
[RFC2578] McCloghrie, K., Ed., Perkins, D., Ed., and J.
Schoenwaelder, Ed., "Structure of Management Information
Version 2 (SMIv2)", STD 58, RFC 2578, April 1999.
[RFC3216] Elliott, C., Harrington, D., Jason, J., Schoenwaelder, J.,
Strauss, F., and W. Weiss, "SMIng Objectives", RFC 3216,
December 2001.
[RFC5277] Chisholm, S. and H. Trevino, "NETCONF Event
Notifications", RFC 5277, July 2008.
[Vli04] van der Vlist, E., "RELAX NG", O'Reilly , 2004.
[XSD] 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,
<http://www.w3.org/TR/2004/REC-xmlschema-1-20041028>.
Lhotka, et al. Expires April 22, 2010 [Page 84]
Internet-Draft Mapping YANG to DSDL October 2009
[Ytypes] Schoenwaelder, J., Ed., "Common YANG Data Types",
draft-ietf-netmod-yang-types-03 (work in progress),
May 2009.
Lhotka, et al. Expires April 22, 2010 [Page 85]
Internet-Draft Mapping YANG to DSDL October 2009
URIs
[1] <http://www.thaiopensource.com/relaxng/trang.html>
[2] <http://dublincore.org/>
[3] <http://www.saxonica.com/>
[4] <http://www.yang-central.org/twiki/bin/view/Main/DhcpTutorial>
[5] <http://code.google.com/p/pyang/>
[6] <http://thaiopensource.com/relaxng/trang.html>
Lhotka, et al. Expires April 22, 2010 [Page 86]
Internet-Draft Mapping YANG to DSDL October 2009
Appendix A. Schemas for NETMOD-Specific Annotations
This appendix utilizes Namespace-Based Validation Dispatching
Language (NVDL, Part 4 of DSDL) [NVDL] to define NETMOD-specific
annotations as extensions of the RELAX NG language. The NVDL schema
may be used for validating conceptual tree schemas as compound XML
documents consisting of RELAX NG sections and embedded sections with
NETMOD-specific annotations. The NVDL schema dispatches the
validation as follows:
1. RELAX NG sections identified by the namespace URI
"http://relaxng.org/ns/structure/1.0" is validated with the
standard RELAX NG schema for RELAX NG, see [RNG], Annex A.
2. NETMOD-specific annotation sections identified by the namespace
URI "urn:ietf:params:xml:ns:netmod:dsdl-annotations:1" are
validated by several context-dependent RELAX NG schemas given
below.
3. Other sections such as Dublin Core metadata or <a:documentation>
annotation are attached to and validated together with the parent
RELAX NG section.
A.1. NVDL Schema
== CODE BEGINS: file "nmannot.nvdl"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE nvdl:rules [<!ENTITY nmannot-uri
"urn:ietf:params:xml:ns:netmod:dsdl-annotations:1">
]>
<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0"
startMode="rng">
<mode name="rng">
<namespace ns="http://relaxng.org/ns/structure/1.0">
<validate schema="http://relaxng.org/relaxng.rng"
useMode="other">
<context path="define" useMode="define"/>
<context path="oneOrMore/element" useMode="list"/>
<context path="element" useMode="element"/>
<context path="choice/group|choice/interleave"
useMode="group-interleave"/>
<context path="choice|ref" useMode="choice-ref"/>
<context path="value" useMode="value"/>
</validate>
</namespace>
</mode>
<mode name="define">
Lhotka, et al. Expires April 22, 2010 [Page 87]
Internet-Draft Mapping YANG to DSDL October 2009
<namespace ns="&nmannot-uri;" match="attributes">
<validate schema="define.rng"/>
</namespace>
</mode>
<mode name="element">
<namespace ns="&nmannot-uri;" match="elements">
<validate schema="element-el.rng"/>
</namespace>
<namespace ns="&nmannot-uri;" match="attributes">
<validate schema="element-att.rng"/>
</namespace>
</mode>
<mode name="group-interleave">
<namespace ns="&nmannot-uri;" match="attributes">
<validate schema="group-interleave.rng"/>
</namespace>
</mode>
<mode name="choice-ref">
<namespace ns="&nmannot-uri;" match="attributes">
<validate schema="choice-ref.rng"/>
</namespace>
</mode>
<mode name="list">
<namespace ns="&nmannot-uri;" match="attributes">
<validate schema="list.rng"/>
</namespace>
</mode>
<mode name="value">
<namespace ns="&nmannot-uri;" match="attributes">
<validate schema="value.rng"/>
</namespace>
</mode>
<mode name="other">
<namespace ns="&nmannot-uri;" match="elements attributes">
<reject/>
</namespace>
<anyNamespace match="elements attributes">
<attach/>
</anyNamespace>
</mode>
</rules>
== CODE ENDS
Lhotka, et al. Expires April 22, 2010 [Page 88]
Internet-Draft Mapping YANG to DSDL October 2009
A.2. Annotation Attributes for define Pattern
== CODE BEGINS: file "define.rng"
<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<include href="nmannotdefs.rng"/>
<start>
<group>
<ref name="default-attribute"/>
<ref name="status-attribute"/>
<ref name="units-attribute"/>
</group>
</start>
</grammar>
== CODE ENDS
A.3. Annotation Elements for element Pattern
== CODE BEGINS: file "element-el.rng"
<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<include href="nmannotdefs.rng"/>
<start>
<choice>
<ref name="must-element"/>
<ref name="instance-identifier-element"/>
</choice>
</start>
</grammar>
== CODE ENDS
Lhotka, et al. Expires April 22, 2010 [Page 89]
Internet-Draft Mapping YANG to DSDL October 2009
A.4. Annotation Attributes for element Pattern
== CODE BEGINS: file "element-att.rng"
<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<include href="nmannotdefs.rng"/>
<start>
<group>
<ref name="config-attribute"/>
<ref name="default-attribute"/>
<ref name="implicit-attribute"/>
<ref name="leafref-attribute"/>
<ref name="presence-attribute"/>
<ref name="status-attribute"/>
<ref name="units-attribute"/>
<ref name="when-attribute"/>
</group>
</start>
</grammar>
== CODE ENDS
A.5. Annotation attributes for group Pattern
== CODE BEGINS: file "group-interleave.rng"
<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<include href="nmannotdefs.rng"/>
<start>
<group>
<ref name="implicit-attribute"/>
<ref name="status-attribute"/>
<ref name="when-attribute"/>
</group>
</start>
</grammar>
== CODE ENDS
Lhotka, et al. Expires April 22, 2010 [Page 90]
Internet-Draft Mapping YANG to DSDL October 2009
A.6. Annotation attributes for choice and ref Patterns
== CODE BEGINS: file "choice-ref.rng"
<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<include href="nmannotdefs.rng"/>
<start>
<group>
<ref name="status-attribute"/>
<ref name="when-attribute"/>
</group>
</start>
</grammar>
== CODE ENDS
A.7. Annotation attributes for element Pattern in the List Context
== CODE BEGINS: file "list.rng"
<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<include href="nmannotdefs.rng"/>
<start>
<group>
<ref name="key-attribute"/>
<ref name="min-elements-attribute"/>
<ref name="max-elements-attribute"/>
<ref name="ordered-by-attribute"/>
<ref name="unique-attribute"/>
</group>
</start>
</grammar>
== CODE ENDS
Lhotka, et al. Expires April 22, 2010 [Page 91]
Internet-Draft Mapping YANG to DSDL October 2009
A.8. Annotation attributes for value Pattern
== CODE BEGINS: file "value.rng"
<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<include href="nmannotdefs.rng"/>
<start>
<ref name="status-attribute"/>
</start>
</grammar>
== CODE ENDS
A.9. Named Patterns for All NETMOD-Specific Annotations
== CODE BEGINS: file "nmannotdefs.rng"
<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
xmlns:nma="urn:ietf:params:xml:ns:netmod:dsdl-annotations:1"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<define name="config-attribute">
<optional>
<attribute name="nma:config">
<data type="boolean"/>
</attribute>
</optional>
</define>
<define name="default-attribute">
<optional>
<attribute name="nma:default"/>
</optional>
</define>
<define name="implicit-attribute">
<optional>
<attribute name="nma:implicit">
<data type="boolean"/>
</attribute>
</optional>
</define>
<define name="error-app-tag-element">
<optional>
<element name="nma:error-app-tag">
Lhotka, et al. Expires April 22, 2010 [Page 92]
Internet-Draft Mapping YANG to DSDL October 2009
<text/>
</element>
</optional>
</define>
<define name="error-message-element">
<optional>
<element name="nma:error-message">
<text/>
</element>
</optional>
</define>
<define name="instance-identifier-element">
<element name="nma:instance-identifier">
<optional>
<attribute name="nma:require-instance">
<data type="boolean"/>
</attribute>
</optional>
</element>
</define>
<define name="key-attribute">
<optional>
<attribute name="nma:key">
<list>
<data type="QName"/>
</list>
</attribute>
</optional>
</define>
<define name="leafref-attribute">
<optional>
<attribute name="nma:leafref">
<data type="string"/>
</attribute>
</optional>
</define>
<define name="min-elements-attribute">
<optional>
<attribute name="nma:min-elements">
<data type="nonNegativeInteger"/>
</attribute>
</optional>
</define>
Lhotka, et al. Expires April 22, 2010 [Page 93]
Internet-Draft Mapping YANG to DSDL October 2009
<define name="max-elements-attribute">
<optional>
<attribute name="nma:max-elements">
<data type="nonNegativeInteger"/>
</attribute>
</optional>
</define>
<define name="must-element">
<element name="nma:must">
<attribute name="assert">
<data type="string"/>
</attribute>
<interleave>
<ref name="error-app-tag-element"/>
<ref name="error-message-element"/>
</interleave>
</element>
</define>
<define name="ordered-by-attribute">
<optional>
<attribute name="nma:ordered-by">
<choice>
<value>user</value>
<value>system</value>
</choice>
</attribute>
</optional>
</define>
<define name="presence-attribute">
<optional>
<attribute name="nma:presence">
<value>true</value>
</attribute>
</optional>
</define>
<define name="status-attribute">
<optional>
<attribute name="nma:status">
<choice>
<value>current</value>
<value>deprecated</value>
<value>obsolete</value>
</choice>
</attribute>
Lhotka, et al. Expires April 22, 2010 [Page 94]
Internet-Draft Mapping YANG to DSDL October 2009
</optional>
</define>
<define name="unique-attribute">
<optional>
<attribute name="nma:unique">
<list>
<data type="token"/>
</list>
</attribute>
</optional>
</define>
<define name="units-attribute">
<optional>
<attribute name="nma:units">
<data type="string"/>
</attribute>
</optional>
</define>
<define name="when-attribute">
<optional>
<attribute name="nma:when">
<data type="string"/>
</attribute>
</optional>
</define>
</grammar>
== CODE ENDS
Lhotka, et al. Expires April 22, 2010 [Page 95]
Internet-Draft Mapping YANG to DSDL October 2009
Appendix B. Schema-Independent Library
In order to avoid copying the same named pattern definitions to the
RELAX NG schemas generated in the second mapping step, we collected
these definitions to a library file - schema-independent library -
which is included by the validating schemas under the file name
"relaxng-lib.rng" (XML syntax) and "relaxng-lib.rnc" (compact
syntax). The included definitions cover patterns for common elements
from base NETCONF [RFC4741] and event notifications [RFC5277].
== CODE BEGINS: file "relaxng-lib.rng"
<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
xmlns:en="urn:ietf:params:xml:ns:netconf:notification:1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<define name="message-id-attribute">
<attribute name="message-id">
<data type="string">
<param name="maxLength">4095</param>
</data>
</attribute>
</define>
<define name="ok-element">
<element name="nc:ok">
<empty/>
</element>
</define>
<define name="eventTime-element">
<element name="en:eventTime">
<data type="dateTime"/>
</element>
</define>
</grammar>
== CODE ENDS
Lhotka, et al. Expires April 22, 2010 [Page 96]
Internet-Draft Mapping YANG to DSDL October 2009
Appendix C. Mapping DHCP Data Model - A Complete Example
This appendix demonstrates both steps of the YANG-to-DSDL mapping
applied to the "canonical" DHCP tutorial [4] data model. The input
(single) YANG module is shown in Appendix C.1 and the output schemas
in the following two subsections.
The conceptual tree schema was obtained by the "rng" plugin of the
pyang [5] tool and the validating DSDL schemas by XSLT stylesheets
that are also part of pyang distribution. RELAX NG schemas are shown
in both XML and compact syntax. The latter was obtained from the
former by using the Trang tool [6]
Due to the limit of 72 characters per line, few long strings required
manual editing, in particular the regular expression patterns for IP
addresses etc. in the RELAX NG schemas. In the compact syntax we
broke the patterns to appropriate segments and joined them with the
concatenation operator "~". In the XML syntax, though, the long
patterns had to be replaced by the placeholder string "... regex
pattern ...". Also, line breaks were added to several documentation
strings and Schematron messages. Other than that, the results of the
automatic translations were not changed.
C.1. Input YANG Module
module dhcp {
namespace "http://example.com/ns/dhcp";
prefix dhcp;
import ietf-yang-types { prefix yang; }
import ietf-inet-types { prefix inet; }
organization
"yang-central.org";
description
"Partial data model for DHCP, based on the config of
the ISC DHCP reference implementation.";
container dhcp {
description
"configuration and operational parameters for a DHCP server.";
leaf max-lease-time {
type uint32;
units seconds;
default 7200;
}
Lhotka, et al. Expires April 22, 2010 [Page 97]
Internet-Draft Mapping YANG to DSDL October 2009
leaf default-lease-time {
type uint32;
units seconds;
must '. <= ../max-lease-time' {
error-message
"The default-lease-time must be less than max-lease-time";
}
default 600;
}
uses subnet-list;
container shared-networks {
list shared-network {
key name;
leaf name {
type string;
}
uses subnet-list;
}
}
container status {
config false;
list leases {
key address;
leaf address {
type inet:ip-address;
}
leaf starts {
type yang:date-and-time;
}
leaf ends {
type yang:date-and-time;
}
container hardware {
leaf type {
type enumeration {
enum "ethernet";
enum "token-ring";
enum "fddi";
}
}
leaf address {
type yang:phys-address;
}
Lhotka, et al. Expires April 22, 2010 [Page 98]
Internet-Draft Mapping YANG to DSDL October 2009
}
}
}
}
grouping subnet-list {
description "A reusable list of subnets";
list subnet {
key net;
leaf net {
type inet:ip-prefix;
}
container range {
presence "enables dynamic address assignment";
leaf dynamic-bootp {
type empty;
description
"Allows BOOTP clients to get addresses in this range";
}
leaf low {
type inet:ip-address;
mandatory true;
}
leaf high {
type inet:ip-address;
mandatory true;
}
}
container dhcp-options {
description "Options in the DHCP protocol";
leaf-list router {
type inet:host;
ordered-by user;
reference "RFC 2132, sec. 3.8";
}
leaf domain-name {
type inet:domain-name;
reference "RFC 2132, sec. 3.17";
}
}
leaf max-lease-time {
type uint32;
units seconds;
default 7200;
}
}
Lhotka, et al. Expires April 22, 2010 [Page 99]
Internet-Draft Mapping YANG to DSDL October 2009
}
}
C.2. Conceptual Tree Schema
C.2.1. XML Syntax
<?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:dsdl-annotations:1"
xmlns:nmt="urn:ietf:params:xml:ns:netmod:conceptual-tree:1"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<dc:creator>Pyang 0.9.3, CTS 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" nma:implicit="true">
<interleave>
<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=". <= ../dhcp: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">
Lhotka, et al. Expires April 22, 2010 [Page 100]
Internet-Draft Mapping YANG to DSDL October 2009
<interleave>
<zeroOrMore>
<element name="dhcp:shared-network"
nma:key="dhcp:name">
<element name="dhcp:name">
<data type="string"/>
</element>
<interleave>
<ref name="_dhcp__subnet-list"/>
</interleave>
</element>
</zeroOrMore>
</interleave>
</element>
</optional>
<optional>
<element name="dhcp:status" nma:config="false">
<interleave>
<zeroOrMore>
<element name="dhcp:leases"
nma:key="dhcp:address">
<element name="dhcp:address">
<ref name="ietf-inet-types__ip-address"/>
</element>
<interleave>
<optional>
<element name="dhcp:starts">
<ref name="ietf-yang-types__date-and-time"/>
</element>
</optional>
<optional>
<element name="dhcp:ends">
<ref name="ietf-yang-types__date-and-time"/>
</element>
</optional>
<optional>
<element name="dhcp:hardware">
<interleave>
<optional>
<element name="dhcp:type">
<choice>
<value>ethernet</value>
<value>token-ring</value>
<value>fddi</value>
</choice>
</element>
</optional>
<optional>
Lhotka, et al. Expires April 22, 2010 [Page 101]
Internet-Draft Mapping YANG to DSDL October 2009
<element name="dhcp:address">
<ref name="ietf-yang-types__phys-address"/>
</element>
</optional>
</interleave>
</element>
</optional>
</interleave>
</element>
</zeroOrMore>
</interleave>
</element>
</optional>
</interleave>
</element>
</optional>
</interleave>
</element>
<element name="nmt:rpc-methods">
<empty/>
</element>
<element name="nmt:notifications">
<empty/>
</element>
</element>
</start>
<define name="_dhcp__subnet-list">
<interleave>
<a:documentation>A reusable list of subnets</a:documentation>
<zeroOrMore>
<element name="dhcp:subnet" nma:key="dhcp:net">
<element name="dhcp:net">
<ref name="ietf-inet-types__ip-prefix"/>
</element>
<interleave>
<optional>
<element name="dhcp:range">
<interleave>
<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="ietf-inet-types__ip-address"/>
Lhotka, et al. Expires April 22, 2010 [Page 102]
Internet-Draft Mapping YANG to DSDL October 2009
</element>
<element name="dhcp:high">
<ref name="ietf-inet-types__ip-address"/>
</element>
</interleave>
</element>
</optional>
<optional>
<element name="dhcp:dhcp-options">
<interleave>
<a:documentation>
Options in the DHCP protocol
</a:documentation>
<zeroOrMore>
<element name="dhcp:router" nma:ordered-by="user">
<a:documentation>
See: RFC 2132, sec. 3.8
</a:documentation>
<ref name="ietf-inet-types__host"/>
</element>
</zeroOrMore>
<optional>
<element name="dhcp:domain-name">
<a:documentation>
See: RFC 2132, sec. 3.17
</a:documentation>
<ref name="ietf-inet-types__domain-name"/>
</element>
</optional>
</interleave>
</element>
</optional>
<optional>
<element name="dhcp:max-lease-time"
nma:default="7200" nma:units="seconds">
<data type="unsignedInt"/>
</element>
</optional>
</interleave>
</element>
</zeroOrMore>
</interleave>
</define>
<define name="ietf-inet-types__ip-prefix">
<choice>
<ref name="ietf-inet-types__ipv4-prefix"/>
<ref name="ietf-inet-types__ipv6-prefix"/>
</choice>
Lhotka, et al. Expires April 22, 2010 [Page 103]
Internet-Draft Mapping YANG to DSDL October 2009
</define>
<define name="ietf-inet-types__ipv4-prefix">
<data type="string">
<param name="pattern">... regex pattern ...</param>
</data>
</define>
<define name="ietf-inet-types__ipv6-prefix">
<data type="string">
<param name="pattern">... regex pattern ...</param>
<param name="pattern">... regex pattern ...</param>
</data>
</define>
<define name="ietf-inet-types__ip-address">
<choice>
<ref name="ietf-inet-types__ipv4-address"/>
<ref name="ietf-inet-types__ipv6-address"/>
</choice>
</define>
<define name="ietf-inet-types__ipv4-address">
<data type="string">
<param name="pattern">... regex pattern ...</param>
</data>
</define>
<define name="ietf-inet-types__ipv6-address">
<data type="string">
<param name="pattern">... regex pattern ...</param>
<param name="pattern">... regex pattern ...</param>
</data>
</define>
<define name="ietf-inet-types__host">
<choice>
<ref name="ietf-inet-types__ip-address"/>
<ref name="ietf-inet-types__domain-name"/>
</choice>
</define>
<define name="ietf-inet-types__domain-name">
<data type="string">
<param name="minLength">1</param>
<param name="maxLength">253</param>
<param name="pattern">... regex pattern ...</param>
</data>
</define>
<define name="ietf-yang-types__date-and-time">
<data type="string">
<param name="pattern">... regex pattern ...</param>
</data>
</define>
<define name="ietf-yang-types__phys-address">
Lhotka, et al. Expires April 22, 2010 [Page 104]
Internet-Draft Mapping YANG to DSDL October 2009
<data type="string">
<param name="pattern">
([0-9a0-fA-F]{2}(:[0-9a0-fA-F]{2})*)?
</param>
</data>
</define>
</grammar>
C.2.2. Compact Syntax
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:dsdl-annotations:1"
namespace nmt = "urn:ietf:params:xml:ns:netmod:conceptual-tree:1"
dc:creator [ "Pyang 0.9.3, CTS plugin" ]
dc:source [ "YANG module 'dhcp'" ]
start =
element nmt:netmod-tree {
element nmt:top {
[ nma:implicit = "true" ]
element dhcp:dhcp {
##
## configuration and operational parameters for a DHCP server
##
([ 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 = ". <= ../dhcp:max-lease-time"
nma:error-message [
"\x{a}" ~
"The default-lease-time must be less than max-lease-time." ~
"\x{a}"
]
]
}?
& _dhcp__subnet-list
& element dhcp:shared-networks {
[ nma:key = "dhcp:name" ]
element dhcp:shared-network {
element dhcp:name { xsd:string },
(_dhcp__subnet-list)
}*
Lhotka, et al. Expires April 22, 2010 [Page 105]
Internet-Draft Mapping YANG to DSDL October 2009
}?
& [ nma:config = "false" ]
element dhcp:status {
[ nma:key = "dhcp:address" ]
element dhcp:leases {
element dhcp:address { ietf-inet-types__ip-address },
(element dhcp:starts { ietf-yang-types__date-and-time }?
& element dhcp:ends { ietf-yang-types__date-and-time }?
& element dhcp:hardware {
element dhcp:type {
"ethernet" | "token-ring" | "fddi"
}?
& element dhcp:address {
ietf-yang-types__phys-address
}?
}?)
}*
}?)
}?
},
element nmt:rpc-methods { empty },
element nmt:notifications { empty }
}
_dhcp__subnet-list =
## A reusable list of subnets
([ nma:key = "dhcp:net" ]
element dhcp:subnet {
element dhcp:net { ietf-inet-types__ip-prefix },
(element dhcp:range {
##
## Allows BOOTP clients to get addresses in this range
##
element dhcp:dynamic-bootp { empty }?
& element dhcp:low { ietf-inet-types__ip-address }
& element dhcp:high { ietf-inet-types__ip-address }
}?
& element dhcp:dhcp-options {
##
## Options in the DHCP protocol
##
(
##
## See: RFC 2132, sec. 3.8
##
[ nma:ordered-by = "user" ]
Lhotka, et al. Expires April 22, 2010 [Page 106]
Internet-Draft Mapping YANG to DSDL October 2009
element dhcp:router { ietf-inet-types__host }*
&
##
## See: RFC 2132, sec. 3.17
##
element dhcp:domain-name { ietf-inet-types__domain-name }?)
}?
& [ nma:default = "7200" nma:units = "seconds" ]
element dhcp:max-lease-time { xsd:unsignedInt }?)
}*)
ietf-inet-types__ip-prefix =
ietf-inet-types__ipv4-prefix | ietf-inet-types__ipv6-prefix
ietf-inet-types__ipv4-prefix =
xsd:string { pattern = "... regex pattern ..." }
ietf-inet-types__ipv6-prefix =
xsd:string {
pattern = "... regex pattern ..."
pattern = "... regex pattern ..."
}
ietf-inet-types__ip-address =
ietf-inet-types__ipv4-address | ietf-inet-types__ipv6-address
ietf-inet-types__ipv4-address =
xsd:string { pattern = "... regex pattern ..." }
ietf-inet-types__ipv6-address =
xsd:string {
pattern = "... regex pattern ..."
pattern = "... regex pattern ..."
}
ietf-inet-types__host =
ietf-inet-types__ip-address | ietf-inet-types__domain-name
ietf-inet-types__domain-name =
xsd:string {
minLength = "1"
maxLength = "253"
pattern = "... regex pattern ..."
}
ietf-yang-types__date-and-time =
xsd:string { pattern = "... regex pattern ..." }
ietf-yang-types__phys-address =
xsd:string {
pattern = "([0-9a0-fA-F]{2}(:[0-9a0-fA-F]{2})*)?"
}
C.3. Final DSDL Schemas
This appendix contains DSDL schemas that were obtained from the
conceptual tree schema in Appendix C.2 by XSL transformations. These
schemas can be directly used for validating a reply to unfiltered
Lhotka, et al. Expires April 22, 2010 [Page 107]
Internet-Draft Mapping YANG to DSDL October 2009
<get> with the contents corresponding to the DHCP data model.
The RELAX NG schema (again shown in both XML and compact syntax)
includes the schema independent library from Appendix B.
C.3.1. RELAX NG Schema for <get> Reply - XML Syntax
<?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:dsdl-annotations:1"
xmlns:nmt="urn:ietf:params:xml:ns:netmod:conceptual-tree:1"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
ns="urn:ietf:params:xml:ns:netconf:base:1.0">
<include href="relaxng-lib.rng"/>
<start>
<element name="rpc-reply">
<ref name="message-id-attribute"/>
<element name="data">
<interleave>
<optional>
<element name="dhcp:dhcp">
<interleave>
<optional>
<element name="dhcp:max-lease-time">
<data type="unsignedInt"/>
</element>
</optional>
<optional>
<element name="dhcp:default-lease-time">
<data type="unsignedInt"/>
</element>
</optional>
<ref name="_dhcp__subnet-list"/>
<optional>
<element name="dhcp:shared-networks">
<interleave>
<zeroOrMore>
<element name="dhcp:shared-network">
<element name="dhcp:name">
<data type="string"/>
</element>
<interleave>
<ref name="_dhcp__subnet-list"/>
</interleave>
Lhotka, et al. Expires April 22, 2010 [Page 108]
Internet-Draft Mapping YANG to DSDL October 2009
</element>
</zeroOrMore>
</interleave>
</element>
</optional>
<optional>
<element name="dhcp:status">
<interleave>
<zeroOrMore>
<element name="dhcp:leases">
<element name="dhcp:address">
<ref name="ietf-inet-types__ip-address"/>
</element>
<interleave>
<optional>
<element name="dhcp:starts">
<ref name="ietf-yang-types__date-and-time"/>
</element>
</optional>
<optional>
<element name="dhcp:ends">
<ref name="ietf-yang-types__date-and-time"/>
</element>
</optional>
<optional>
<element name="dhcp:hardware">
<interleave>
<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="ietf-yang-types__phys-address"/>
</element>
</optional>
</interleave>
</element>
</optional>
</interleave>
</element>
</zeroOrMore>
</interleave>
Lhotka, et al. Expires April 22, 2010 [Page 109]
Internet-Draft Mapping YANG to DSDL October 2009
</element>
</optional>
</interleave>
</element>
</optional>
</interleave>
</element>
</element>
</start>
<define name="_dhcp__subnet-list">
<interleave>
<zeroOrMore>
<element name="dhcp:subnet">
<element name="dhcp:net">
<ref name="ietf-inet-types__ip-prefix"/>
</element>
<interleave>
<optional>
<element name="dhcp:range">
<interleave>
<optional>
<element name="dhcp:dynamic-bootp">
<empty/>
</element>
</optional>
<element name="dhcp:low">
<ref name="ietf-inet-types__ip-address"/>
</element>
<element name="dhcp:high">
<ref name="ietf-inet-types__ip-address"/>
</element>
</interleave>
</element>
</optional>
<optional>
<element name="dhcp:dhcp-options">
<interleave>
<zeroOrMore>
<element name="dhcp:router">
<ref name="ietf-inet-types__host"/>
</element>
</zeroOrMore>
<optional>
<element name="dhcp:domain-name">
<ref name="ietf-inet-types__domain-name"/>
</element>
</optional>
</interleave>
Lhotka, et al. Expires April 22, 2010 [Page 110]
Internet-Draft Mapping YANG to DSDL October 2009
</element>
</optional>
<optional>
<element name="dhcp:max-lease-time">
<data type="unsignedInt"/>
</element>
</optional>
</interleave>
</element>
</zeroOrMore>
</interleave>
</define>
<define name="ietf-inet-types__ip-prefix">
<choice>
<ref name="ietf-inet-types__ipv4-prefix"/>
<ref name="ietf-inet-types__ipv6-prefix"/>
</choice>
</define>
<define name="ietf-inet-types__ipv4-prefix">
<data type="string">
<param name="pattern">... regex pattern ...</param>
</data>
</define>
<define name="ietf-inet-types__ipv6-prefix">
<data type="string">
<param name="pattern">... regex pattern ...</param>
<param name="pattern">... regex pattern ...</param>
</data>
</define>
<define name="ietf-inet-types__ip-address">
<choice>
<ref name="ietf-inet-types__ipv4-address"/>
<ref name="ietf-inet-types__ipv6-address"/>
</choice>
</define>
<define name="ietf-inet-types__ipv4-address">
<data type="string">
<param name="pattern">... regex pattern ...</param>
</data>
</define>
<define name="ietf-inet-types__ipv6-address">
<data type="string">
<param name="pattern">... regex pattern ...</param>
<param name="pattern">... regex pattern ...</param>
</data>
</define>
<define name="ietf-inet-types__host">
<choice>
Lhotka, et al. Expires April 22, 2010 [Page 111]
Internet-Draft Mapping YANG to DSDL October 2009
<ref name="ietf-inet-types__ip-address"/>
<ref name="ietf-inet-types__domain-name"/>
</choice>
</define>
<define name="ietf-inet-types__domain-name">
<data type="string">
<param name="minLength">1</param>
<param name="maxLength">253</param>
<param name="pattern">... regex pattern ...</param>
</data>
</define>
<define name="ietf-yang-types__date-and-time">
<data type="string">
<param name="pattern">... regex pattern ...</param>
</data>
</define>
<define name="ietf-yang-types__phys-address">
<data type="string">
<param name="pattern">
([0-9a0-fA-F]{2}(:[0-9a0-fA-F]{2})*)?
</param>
</data>
</define>
</grammar>
C.3.2. RELAX NG Schema for <get> Reply - Compact Syntax
default namespace = "urn:ietf:params:xml:ns:netconf:base:1.0"
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:dsdl-annotations:1"
namespace nmt = "urn:ietf:params:xml:ns:netmod:conceptual-tree:1"
include "relaxng-lib.rnc"
start =
element rpc-reply {
message-id-attribute,
element data {
element dhcp:dhcp {
element dhcp:max-lease-time { xsd:unsignedInt }?
& element dhcp:default-lease-time { xsd:unsignedInt }?
& _dhcp__subnet-list
& element dhcp:shared-networks {
element dhcp:shared-network {
element dhcp:name { xsd:string },
(_dhcp__subnet-list)
}*
Lhotka, et al. Expires April 22, 2010 [Page 112]
Internet-Draft Mapping YANG to DSDL October 2009
}?
& element dhcp:status {
element dhcp:leases {
element dhcp:address { ietf-inet-types__ip-address },
(element dhcp:starts { ietf-yang-types__date-and-time }?
& element dhcp:ends { ietf-yang-types__date-and-time }?
& element dhcp:hardware {
element dhcp:type {
"ethernet" | "token-ring" | "fddi"
}?
& element dhcp:address {
ietf-yang-types__phys-address
}?
}?)
}*
}?
}?
}
}
_dhcp__subnet-list =
element dhcp:subnet {
element dhcp:net { ietf-inet-types__ip-prefix },
(element dhcp:range {
element dhcp:dynamic-bootp { empty }?
& element dhcp:low { ietf-inet-types__ip-address }
& element dhcp:high { ietf-inet-types__ip-address }
}?
& element dhcp:dhcp-options {
element dhcp:router { ietf-inet-types__host }*
& element dhcp:domain-name { ietf-inet-types__domain-name }?
}?
& element dhcp:max-lease-time { xsd:unsignedInt }?)
}*
ietf-inet-types__ip-prefix =
ietf-inet-types__ipv4-prefix | ietf-inet-types__ipv6-prefix
ietf-inet-types__ipv4-prefix =
xsd:string { pattern = "... regex pattern ..." }
ietf-inet-types__ipv6-prefix =
xsd:string {
pattern = "... regex pattern ..."
pattern = "... regex pattern ..."
}
ietf-inet-types__ip-address =
ietf-inet-types__ipv4-address | ietf-inet-types__ipv6-address
ietf-inet-types__ipv4-address =
xsd:string { pattern = "... regex pattern ..." }
ietf-inet-types__ipv6-address =
xsd:string {
Lhotka, et al. Expires April 22, 2010 [Page 113]
Internet-Draft Mapping YANG to DSDL October 2009
pattern = "... regex pattern ..."
pattern = "... regex pattern ..."
}
ietf-inet-types__host =
ietf-inet-types__ip-address | ietf-inet-types__domain-name
ietf-inet-types__domain-name =
xsd:string {
minLength = "1"
maxLength = "253"
pattern = "... regex pattern ..."
}
ietf-yang-types__date-and-time =
xsd:string { pattern = "... regex pattern ..." }
ietf-yang-types__phys-address =
xsd:string {
pattern =
"\x{a}" ~
" ([0-9a0-fA-F]{2}(:[0-9a0-fA-F]{2})*)?\x{a}" ~
" "
}
C.4. Schematron Schema for <get> Reply
<?xml version="1.0" encoding="utf-8"?>
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron">
<sch:ns uri="http://example.com/ns/dhcp" prefix="dhcp"/>
<sch:ns uri="urn:ietf:params:xml:ns:netconf:base:1.0"
prefix="nc"/>
<sch:phase id="full">
<sch:active pattern="standard"/>
<sch:active pattern="ref-integrity"/>
</sch:phase>
<sch:phase id="noref">
<sch:active pattern="standard"/>
</sch:phase>
<sch:pattern id="standard">
<sch:rule id="std-id2247270" abstract="true">
<sch:report test="preceding-sibling::dhcp:subnet
[dhcp:net=current()/dhcp:net]">
Duplicate key of list dhcp:subnet
</sch:report>
</sch:rule>
<sch:rule context="/nc:rpc-reply/nc:data/dhcp:dhcp/
dhcp:default-lease-time">
<sch:assert test=". <= ../dhcp:max-lease-time">
The default-lease-time must be less than max-lease-time.
</sch:assert>
</sch:rule>
Lhotka, et al. Expires April 22, 2010 [Page 114]
Internet-Draft Mapping YANG to DSDL October 2009
<sch:rule context="/nc:rpc-reply/nc:data/dhcp:dhcp/dhcp:subnet">
<sch:extends rule="std-id2247270"/>
</sch:rule>
<sch:rule context="/nc:rpc-reply/nc:data/dhcp:dhcp/
dhcp:shared-networks/dhcp:shared-network">
<sch:report test="preceding-sibling::dhcp:shared-network
[dhcp:name=current()/dhcp:name]">
Duplicate key of list dhcp:shared-network
</sch:report>
</sch:rule>
<sch:rule context="/nc:rpc-reply/nc:data/dhcp:dhcp/
dhcp:shared-networks/dhcp:shared-network/
dhcp:subnet">
<sch:extends rule="std-id2247270"/>
</sch:rule>
<sch:rule context="/nc:rpc-reply/nc:data/dhcp:dhcp/
dhcp:status/dhcp:leases">
<sch:report test="preceding-sibling::dhcp:leases
[dhcp:address=current()/dhcp:address]">
Duplicate key of list dhcp:leases
</sch:report>
</sch:rule>
</sch:pattern>
<sch:pattern id="ref-integrity"/>
</sch:schema>
Lhotka, et al. Expires April 22, 2010 [Page 115]
Internet-Draft Mapping YANG to DSDL October 2009
C.5. DSRL Schema for <get> Reply
<?xml version="1.0" encoding="utf-8"?>
<dsrl:maps xmlns:dsrl="http://purl.oclc.org/dsdl/dsrl"
xmlns:dhcp="http://example.com/ns/dhcp"
xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
<dsrl:element-map>
<dsrl:parent>/nc:rpc-reply/nc:data/</dsrl:parent>
<dsrl:name>dhcp:dhcp</dsrl:name>
<dsrl:default-content>
<dhcp:max-lease-time>7200</dhcp:max-lease-time>
<dhcp:default-lease-time>600</dhcp:default-lease-time>
</dsrl:default-content>
</dsrl:element-map>
<dsrl:element-map>
<dsrl:parent>/nc:rpc-reply/nc:data/dhcp:dhcp</dsrl:parent>
<dsrl:name>dhcp:max-lease-time</dsrl:name>
<dsrl:default-content>7200</dsrl:default-content>
</dsrl:element-map>
<dsrl:element-map>
<dsrl:parent>/nc:rpc-reply/nc:data/dhcp:dhcp</dsrl:parent>
<dsrl:name>dhcp:default-lease-time</dsrl:name>
<dsrl:default-content>600</dsrl:default-content>
</dsrl:element-map>
<dsrl:element-map>
<dsrl:parent>
/nc:rpc-reply/nc:data/dhcp:dhcp/dhcp:subnet
</dsrl:parent>
<dsrl:name>dhcp:max-lease-time</dsrl:name>
<dsrl:default-content>7200</dsrl:default-content>
</dsrl:element-map>
<dsrl:element-map>
<dsrl:parent>
/nc:rpc-reply/nc:data/dhcp:dhcp/dhcp:shared-networks/
dhcp:shared-network/dhcp:subnet
</dsrl:parent>
<dsrl:name>dhcp:max-lease-time</dsrl:name>
<dsrl:default-content>7200</dsrl:default-content>
</dsrl:element-map>
</dsrl:maps>
Lhotka, et al. Expires April 22, 2010 [Page 116]
Internet-Draft Mapping YANG to DSDL October 2009
Appendix D. Change Log
D.1. Changes Between Versions -03 and -04
o Implemented ordering rules for list children - keys must go first
and appear in the same order as in the input YANG module.
o The 'case' statement is now mapped to either <rng:group> (inside
RPCs) or <rng:interleave> (otherwise).
o A nma:default annotation coming from a datatype which the mapping
expands is attached to the <rng:element> pattern where the
expansion occurs. Added an example.
o Documentation statements ('description', 'reference', 'status')
MAY be ignored.
o Single-valued numeric or length range parts are mapped to <rng:
value> pattern or "length" facet.
o Example for "string" datatype was added.
o Appendix A now uses NVDL for defining NETMOD-specific annotations.
o Added CODE BEGINS/ENDS markers.
o Separated normative and informative references.
o Added URL for XPath extensions namespace.
o Added Section 2 (Terminology and Notation).
o Added Section 14 (Security Considerations).
o Added Section 15 (Acknowledgements).
o Removed compact syntax schema from Appendix B.
o Editorial changes: symbolic citation labels.
D.2. Changes Between Versions -02 and -03
o Changed @nma:default-case to @nma:implicit.
o Changed nma:leafref annotation from element to attribute.
o Added skeleton rule to Section 10.2.
Lhotka, et al. Expires April 22, 2010 [Page 117]
Internet-Draft Mapping YANG to DSDL October 2009
o Reworked Section 10.4, added skeleton element maps,corrected the
example.
o Added Section 8.5 on 'feature' and 'deviation'.
o New Section 9.1 integrating discussion of both optional/mandatory
(was in -02) and implicit nodes (new).
o Reflected that key argument and schema node identifiers are no
more XPath (should be in yang-07).
o Element patterns for implicit containers now must have @nma:
implicit attribute.
o Removed "float32" and "float64" types and added mapping of
"decimal64" with example.
o Removed mapping of 'require-instance' for "leafref" type.
o Updated RELAX NG schema for NETMOD-specific annotations.
o Updated the DHCP example.
D.3. Changes Between Versions -01 and -02
o Moved Section 7 "NETCONF Content Validation" after Section 6.
o New text about mapping defaults to DSRL, especially in Section 7
and Section 10.4.
o Finished the DHCP example by adding the DSRL schema to Appendix C.
o New @nma:presence annotation was added - it is needed for proper
handling of default content.
o Section 10.3 "Constraints on Mandatory Choice" was added because
these constraints require a combination of RELAX NG and
Schematron.
o Fixed the schema for NETMOD-specific annotations by adding
explicit prefix to all defined elements and attributes.
Previously, the attributes had no namespace.
o Handling of 'feature', 'if-feature' and 'deviation' added.
o Handling of nma:instance-identifier via XSLT extension function.
Lhotka, et al. Expires April 22, 2010 [Page 118]
Internet-Draft Mapping YANG to DSDL October 2009
D.4. Changes Between Versions -00 and -01
o Attributes @nma:min-elements and @nma:max-elements are attached to
<rng:element> (list entry) and not to <rng:zeroOrMore> or <rng:
oneOrMore>.
o Keys and all node identifiers in 'key' and 'unique' statements are
prefixed.
o Fixed the mapping of 'rpc' and 'notification'.
o Removed previous sec. 7.5 "RPC Signatures and Notifications" - the
same information is now contained in Section 11.50 and
Section 11.37.
o Added initial "_" to mangled names of groupings.
o Mandated the use of @xmlns:xxx as the only method for declaring
the target namespace.
o Added section "Handling of XML Namespaces" to explain the previous
item.
o Completed DHCP example in Appendix C.
o Almost all text about the second mapping step is new.
Lhotka, et al. Expires April 22, 2010 [Page 119]
Internet-Draft Mapping YANG to DSDL October 2009
Authors' Addresses
Ladislav Lhotka
CESNET
Email: lhotka@cesnet.cz
Rohan Mahy
Plantronics
Email: rohan@ekabal.com
Sharon Chisholm
Nortel
Email: schishol@nortel.com
Lhotka, et al. Expires April 22, 2010 [Page 120]
| PAFTECH AB 2003-2026 | 2026-04-24 01:52:19 |