Internet Engineering Task Force (IETF)                    L. Lhotka, Ed.
Request for Comments: 6110                                        CESNET
Category: Standards Track                                  February 2011
ISSN: 2070-1721
        
Internet Engineering Task Force (IETF)                    L. Lhotka, Ed.
Request for Comments: 6110                                        CESNET
Category: Standards Track                                  February 2011
ISSN: 2070-1721
        

Mapping YANG to Document Schema Definition Languages and Validating NETCONF Content

将YANG映射到文档架构定义语言并验证NETCONF内容

Abstract

摘要

This document 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/IEC 19757. The following DSDL schema languages are addressed by the mapping: Regular Language for XML Next Generation (RELAX NG), Schematron, and Schematron and Document Schema Renaming Language (DSRL). The mapping takes one or more YANG modules and produces a set of DSDL schemas for a selected target document type -- datastore content, Network Configuration Protocol (NETCONF) messages, etc. Procedures for schema-based validation of such documents are also discussed.

本文档指定了将数据模型转换为文档模式定义语言(DSDL)的映射规则,DSDL是一组协调的XML模式语言,标准化为ISO/IEC 19757。映射处理了以下DSDL模式语言:XML下一代正则语言(RELAXNG)、Schematron和Schematron以及文档模式重命名语言(DSRL)。映射采用一个或多个模块,并为选定的目标文档类型(数据存储内容、网络配置协议(NETCONF)消息等)生成一组DSDL模式。还讨论了基于模式的此类文档验证过程。

Status of This Memo

关于下段备忘

This is an Internet Standards Track document.

这是一份互联网标准跟踪文件。

This document is a product of the Internet Engineering Task Force (IETF). It represents the consensus of the IETF community. It has received public review and has been approved for publication by the Internet Engineering Steering Group (IESG). Further information on Internet Standards is available in Section 2 of RFC 5741.

本文件是互联网工程任务组(IETF)的产品。它代表了IETF社区的共识。它已经接受了公众审查,并已被互联网工程指导小组(IESG)批准出版。有关互联网标准的更多信息,请参见RFC 5741第2节。

Information about the current status of this document, any errata, and how to provide feedback on it may be obtained at http://www.rfc-editor.org/info/rfc6110.

有关本文件当前状态、任何勘误表以及如何提供反馈的信息,请访问http://www.rfc-editor.org/info/rfc6110.

Copyright Notice

版权公告

Copyright (c) 2011 IETF Trust and the persons identified as the document authors. All rights reserved.

版权所有(c)2011 IETF信托基金和确定为文件作者的人员。版权所有。

This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.

本文件受BCP 78和IETF信托有关IETF文件的法律规定的约束(http://trustee.ietf.org/license-info)自本文件出版之日起生效。请仔细阅读这些文件,因为它们描述了您对本文件的权利和限制。从本文件中提取的代码组件必须包括信托法律条款第4.e节中所述的简化BSD许可证文本,并提供简化BSD许可证中所述的无担保。

Table of Contents

目录

   1. Introduction ....................................................5
   2. Terminology and Notation ........................................6
      2.1. Glossary of New Terms ......................................9
   3. Objectives and Motivation ......................................10
   4. DSDL Schema Languages ..........................................11
      4.1. RELAX NG ..................................................11
      4.2. Schematron ................................................12
      4.3. Document Semantics Renaming Language (DSRL) ...............13
   5. Additional Annotations .........................................14
      5.1. Dublin Core Metadata Elements .............................14
      5.2. RELAX NG DTD Compatibility Annotations ....................14
      5.3. NETMOD-Specific Annotations ...............................15
   6. Overview of the Mapping ........................................16
   7. NETCONF Content Validation .....................................18
   8. Design Considerations ..........................................19
      8.1. Hybrid Schema .............................................19
      8.2. Modularity ................................................22
      8.3. Granularity ...............................................23
      8.4. Handling of XML Namespaces ................................24
   9. Mapping YANG Data Models to the Hybrid Schema ..................25
      9.1. Occurrence Rules for Data Nodes ...........................25
           9.1.1. Optional and Mandatory Nodes .......................26
           9.1.2. Implicit Nodes .....................................27
      9.2. Mapping YANG Groupings and Typedefs .......................28
           9.2.1. YANG Refinements and Augments ......................29
           9.2.2. Type Derivation Chains .............................32
      9.3. Translation of XPath Expressions ..........................35
      9.4. YANG Language Extensions ..................................36
   10. Mapping YANG Statements to the Hybrid Schema ..................37
      10.1. The 'anyxml' Statement ...................................37
      10.2. The 'argument' Statement .................................38
        
   1. Introduction ....................................................5
   2. Terminology and Notation ........................................6
      2.1. Glossary of New Terms ......................................9
   3. Objectives and Motivation ......................................10
   4. DSDL Schema Languages ..........................................11
      4.1. RELAX NG ..................................................11
      4.2. Schematron ................................................12
      4.3. Document Semantics Renaming Language (DSRL) ...............13
   5. Additional Annotations .........................................14
      5.1. Dublin Core Metadata Elements .............................14
      5.2. RELAX NG DTD Compatibility Annotations ....................14
      5.3. NETMOD-Specific Annotations ...............................15
   6. Overview of the Mapping ........................................16
   7. NETCONF Content Validation .....................................18
   8. Design Considerations ..........................................19
      8.1. Hybrid Schema .............................................19
      8.2. Modularity ................................................22
      8.3. Granularity ...............................................23
      8.4. Handling of XML Namespaces ................................24
   9. Mapping YANG Data Models to the Hybrid Schema ..................25
      9.1. Occurrence Rules for Data Nodes ...........................25
           9.1.1. Optional and Mandatory Nodes .......................26
           9.1.2. Implicit Nodes .....................................27
      9.2. Mapping YANG Groupings and Typedefs .......................28
           9.2.1. YANG Refinements and Augments ......................29
           9.2.2. Type Derivation Chains .............................32
      9.3. Translation of XPath Expressions ..........................35
      9.4. YANG Language Extensions ..................................36
   10. Mapping YANG Statements to the Hybrid Schema ..................37
      10.1. The 'anyxml' Statement ...................................37
      10.2. The 'argument' Statement .................................38
        
      10.3. The 'augment' Statement ..................................39
      10.4. The 'base' Statement .....................................39
      10.5. The 'belongs-to' Statement ...............................39
      10.6. The 'bit' Statement ......................................39
      10.7. The 'case' Statement .....................................39
      10.8. The 'choice' Statement ...................................39
      10.9. The 'config' Statement ...................................40
      10.10. The 'contact' Statement .................................40
      10.11. The 'container' Statement ...............................40
      10.12. The 'default' Statement .................................40
      10.13. The 'description' Statement .............................42
      10.14. The 'deviation' Statement ...............................42
      10.15. The 'enum' Statement ....................................42
      10.16. The 'error-app-tag' Statement ...........................42
      10.17. The 'error-message' Statement ...........................42
      10.18. The 'extension' Statement ...............................43
      10.19. The 'feature' Statement .................................43
      10.20. The 'grouping' Statement ................................43
      10.21. The 'identity' Statement ................................43
      10.22. The 'if-feature' Statement ..............................45
      10.23. The 'import' Statement ..................................45
      10.24. The 'include' Statement .................................45
      10.25. The 'input' Statement ...................................46
      10.26. The 'key' Statement .....................................46
      10.27. The 'leaf' Statement ....................................46
      10.28. The 'leaf-list' Statement ...............................46
      10.29. The 'length' Statement ..................................47
      10.30. The 'list' Statement ....................................47
      10.31. The 'mandatory' Statement ...............................48
      10.32. The 'max-elements' Statement ............................49
      10.33. The 'min-elements' Statement ............................49
      10.34. The 'module' Statement ..................................49
      10.35. The 'must' Statement ....................................49
      10.36. The 'namespace' Statement ...............................50
      10.37. The 'notification' Statement ............................50
      10.38. The 'ordered-by' Statement ..............................50
      10.39. The 'organization' Statement ............................50
      10.40. The 'output' Statement ..................................51
      10.41. The 'path' Statement ....................................51
      10.42. The 'pattern' Statement .................................51
      10.43. The 'position' Statement ................................51
      10.44. The 'prefix' Statement ..................................51
      10.45. The 'presence' Statement ................................51
      10.46. The 'range' Statement ...................................51
      10.47. The 'reference' Statement ...............................51
      10.48. The 'require-instance' Statement ........................51
      10.49. The 'revision' Statement ................................52
      10.50. The 'rpc' Statement .....................................52
        
      10.3. The 'augment' Statement ..................................39
      10.4. The 'base' Statement .....................................39
      10.5. The 'belongs-to' Statement ...............................39
      10.6. The 'bit' Statement ......................................39
      10.7. The 'case' Statement .....................................39
      10.8. The 'choice' Statement ...................................39
      10.9. The 'config' Statement ...................................40
      10.10. The 'contact' Statement .................................40
      10.11. The 'container' Statement ...............................40
      10.12. The 'default' Statement .................................40
      10.13. The 'description' Statement .............................42
      10.14. The 'deviation' Statement ...............................42
      10.15. The 'enum' Statement ....................................42
      10.16. The 'error-app-tag' Statement ...........................42
      10.17. The 'error-message' Statement ...........................42
      10.18. The 'extension' Statement ...............................43
      10.19. The 'feature' Statement .................................43
      10.20. The 'grouping' Statement ................................43
      10.21. The 'identity' Statement ................................43
      10.22. The 'if-feature' Statement ..............................45
      10.23. The 'import' Statement ..................................45
      10.24. The 'include' Statement .................................45
      10.25. The 'input' Statement ...................................46
      10.26. The 'key' Statement .....................................46
      10.27. The 'leaf' Statement ....................................46
      10.28. The 'leaf-list' Statement ...............................46
      10.29. The 'length' Statement ..................................47
      10.30. The 'list' Statement ....................................47
      10.31. The 'mandatory' Statement ...............................48
      10.32. The 'max-elements' Statement ............................49
      10.33. The 'min-elements' Statement ............................49
      10.34. The 'module' Statement ..................................49
      10.35. The 'must' Statement ....................................49
      10.36. The 'namespace' Statement ...............................50
      10.37. The 'notification' Statement ............................50
      10.38. The 'ordered-by' Statement ..............................50
      10.39. The 'organization' Statement ............................50
      10.40. The 'output' Statement ..................................51
      10.41. The 'path' Statement ....................................51
      10.42. The 'pattern' Statement .................................51
      10.43. The 'position' Statement ................................51
      10.44. The 'prefix' Statement ..................................51
      10.45. The 'presence' Statement ................................51
      10.46. The 'range' Statement ...................................51
      10.47. The 'reference' Statement ...............................51
      10.48. The 'require-instance' Statement ........................51
      10.49. The 'revision' Statement ................................52
      10.50. The 'rpc' Statement .....................................52
        
      10.51. The 'status' Statement ..................................52
      10.52. The 'submodule' Statement ...............................52
      10.53. The 'type' Statement ....................................53
           10.53.1. The "empty" Type .................................54
           10.53.2. The "boolean" Type ...............................54
           10.53.3. The "binary" Type ................................54
           10.53.4. The "bits" Type ..................................54
           10.53.5. The "enumeration" and "union" Types ..............54
           10.53.6. The "identityref" Type ...........................54
           10.53.7. The "instance-identifier" Type ...................55
           10.53.8. The "leafref" Type ...............................55
           10.53.9. The Numeric Types ................................55
           10.53.10. The "string" Type ...............................57
           10.53.11. Derived Types ...................................58
      10.54. The 'typedef' Statement .................................59
      10.55. The 'unique' Statement ..................................59
      10.56. The 'units' Statement ...................................60
      10.57. The 'uses' Statement ....................................60
      10.58. The 'value' Statement ...................................60
      10.59. The 'when' Statement ....................................60
      10.60. The 'yang-version' Statement ............................60
      10.61. The 'yin-element' Statement .............................61
   11. Mapping the Hybrid Schema to DSDL .............................61
      11.1. Generating RELAX NG Schemas for Various Document Types ...61
      11.2. Mapping Semantic Constraints to Schematron ...............62
           11.2.1. Constraints on Mandatory Choice ...................65
      11.3. Mapping Default Values to DSRL ...........................67
   12. Mapping NETMOD-Specific Annotations to DSDL Schema Languages ..71
      12.1. The @nma:config Annotation ...............................71
      12.2. The @nma:default Annotation ..............................71
      12.3. The <nma:error-app-tag> Annotation .......................71
      12.4. The <nma:error-message> Annotation .......................71
      12.5. The @if-feature Annotation ...............................71
      12.6. The @nma:implicit Annotation .............................72
      12.7. The <nma:instance-identifier> Annotation .................72
      12.8. The @nma:key Annotation ..................................72
      12.9. The @nma:leaf-list Annotation ............................72
      12.10. The @nma:leafref Annotation .............................73
      12.11. The @nma:min-elements Annotation ........................73
      12.12. The @nma:max-elements Annotation ........................73
      12.13. The <nma:must> Annotation ...............................73
      12.14. The <nma:ordered-by> Annotation .........................74
      12.15. The <nma:status> Annotation .............................74
      12.16. The @nma:unique Annotation ..............................74
      12.17. The @nma:when Annotation ................................74
   13. IANA Considerations ...........................................75
   14. Security Considerations .......................................75
   15. Contributors ..................................................75
        
      10.51. The 'status' Statement ..................................52
      10.52. The 'submodule' Statement ...............................52
      10.53. The 'type' Statement ....................................53
           10.53.1. The "empty" Type .................................54
           10.53.2. The "boolean" Type ...............................54
           10.53.3. The "binary" Type ................................54
           10.53.4. The "bits" Type ..................................54
           10.53.5. The "enumeration" and "union" Types ..............54
           10.53.6. The "identityref" Type ...........................54
           10.53.7. The "instance-identifier" Type ...................55
           10.53.8. The "leafref" Type ...............................55
           10.53.9. The Numeric Types ................................55
           10.53.10. The "string" Type ...............................57
           10.53.11. Derived Types ...................................58
      10.54. The 'typedef' Statement .................................59
      10.55. The 'unique' Statement ..................................59
      10.56. The 'units' Statement ...................................60
      10.57. The 'uses' Statement ....................................60
      10.58. The 'value' Statement ...................................60
      10.59. The 'when' Statement ....................................60
      10.60. The 'yang-version' Statement ............................60
      10.61. The 'yin-element' Statement .............................61
   11. Mapping the Hybrid Schema to DSDL .............................61
      11.1. Generating RELAX NG Schemas for Various Document Types ...61
      11.2. Mapping Semantic Constraints to Schematron ...............62
           11.2.1. Constraints on Mandatory Choice ...................65
      11.3. Mapping Default Values to DSRL ...........................67
   12. Mapping NETMOD-Specific Annotations to DSDL Schema Languages ..71
      12.1. The @nma:config Annotation ...............................71
      12.2. The @nma:default Annotation ..............................71
      12.3. The <nma:error-app-tag> Annotation .......................71
      12.4. The <nma:error-message> Annotation .......................71
      12.5. The @if-feature Annotation ...............................71
      12.6. The @nma:implicit Annotation .............................72
      12.7. The <nma:instance-identifier> Annotation .................72
      12.8. The @nma:key Annotation ..................................72
      12.9. The @nma:leaf-list Annotation ............................72
      12.10. The @nma:leafref Annotation .............................73
      12.11. The @nma:min-elements Annotation ........................73
      12.12. The @nma:max-elements Annotation ........................73
      12.13. The <nma:must> Annotation ...............................73
      12.14. The <nma:ordered-by> Annotation .........................74
      12.15. The <nma:status> Annotation .............................74
      12.16. The @nma:unique Annotation ..............................74
      12.17. The @nma:when Annotation ................................74
   13. IANA Considerations ...........................................75
   14. Security Considerations .......................................75
   15. Contributors ..................................................75
        
   16. Acknowledgments ...............................................76
   17. References ....................................................76
      17.1. Normative References .....................................76
      17.2. Informative References ...................................77
   Appendix A. RELAX NG Schema for NETMOD-Specific Annotations .......79
   Appendix B. Schema-Independent Library ............................84
   Appendix C. Mapping DHCP Data Model - A Complete Example ..........85
      C.1. Input YANG Module .........................................85
      C.2. Hybrid Schema .............................................88
      C.3. Final DSDL Schemas  .......................................93
           C.3.1. Main RELAX NG Schema for <nc:get> Reply ............93
           C.3.2. RELAX NG Schema - Global Named Pattern
                  Definitions ........................................95
           C.3.3. Schematron Schema for <nc:get> Reply ...............98
           C.3.4. DSRL Schema for <nc:get> Reply .....................99
        
   16. Acknowledgments ...............................................76
   17. References ....................................................76
      17.1. Normative References .....................................76
      17.2. Informative References ...................................77
   Appendix A. RELAX NG Schema for NETMOD-Specific Annotations .......79
   Appendix B. Schema-Independent Library ............................84
   Appendix C. Mapping DHCP Data Model - A Complete Example ..........85
      C.1. Input YANG Module .........................................85
      C.2. Hybrid Schema .............................................88
      C.3. Final DSDL Schemas  .......................................93
           C.3.1. Main RELAX NG Schema for <nc:get> Reply ............93
           C.3.2. RELAX NG Schema - Global Named Pattern
                  Definitions ........................................95
           C.3.3. Schematron Schema for <nc:get> Reply ...............98
           C.3.4. DSRL Schema for <nc:get> Reply .....................99
        
1. Introduction
1. 介绍

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 data modeling language or accompanying rules for how to model configuration and state information carried by NETCONF. The IETF Operations Area has a long tradition of defining data for Simple Network Management Protocol (SNMP) Management Information Bases (MIB) modules [RFC1157] using the Structure of Management Information (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 without the additional semantic relationships has caused significant interoperability problems in the past.

NETCONF工作组已经完成了用于配置管理的基本协议[RFC4741]。此基本规范定义了用于配置和管理操作的协议绑定和XML容器语法,但不包括数据建模语言或有关如何对NETCONF携带的配置和状态信息建模的附带规则。IETF操作领域有着使用管理信息结构(SMI)语言[RFC2578]为简单网络管理协议(SNMP)管理信息库(MIB)模块[RFC1157]定义数据的悠久传统。虽然这种特定的建模方法有许多众所周知的问题,但SMI提供的大多数数据建模功能仍然被认为是极其重要的。在过去,简单地对有效语法建模而不使用额外的语义关系会导致严重的互操作性问题。

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 design a modeling language defining the semantics of operational data, configuration data, event notifications, and operations, with focus on "human-friendliness", i.e., readability and ease of use. The result is the YANG data modeling language [RFC6020], which now serves for the normative description of NETCONF data models.

NETCONF社区得出结论,需要一个数据建模框架来支持IETF和供应商定义的管理信息模块的持续开发。NETMOD工作组被授权设计一种建模语言,定义操作数据、配置数据、事件通知和操作的语义,重点关注“人性化”,即可读性和易用性。结果是YANG数据建模语言[RFC6020],它现在用于NETCONF数据模型的规范性描述。

Since NETCONF uses XML for encoding its messages, 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

由于NETCONF使用XML对其消息进行编码,因此使用标准XML模式语言表达对NETCONF内容的约束是很自然的。为此,NETMOD工作组选择了正在标准化为ISO/IEC 19757[DSDL]的文档模式定义语言(DSDL)。DSDL框架由一组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 -- Regular Language for XML Next Generation (RELAX NG), Schematron and Document Schema Renaming Language (DSRL) -- already have the status of an ISO/ IEC International Standard and are supported in a number of software tools.

解决语法规则、语义约束和其他数据建模方面的模式语言,但更重要的是,它们以协调一致的方式进行。诚然,一些DSDL部分尚未标准化,仍在进行中,但YANG-to-DSDL映射所依赖的三个部分——XML下一代正则语言(RELAXNG)、Schematron和文档模式重命名语言(DSRL)--已经具有ISO/IEC国际标准的地位,并在许多软件工具中得到支持。

This document contains a 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, signatures of remote procedure call (RPC) operations, and notifications are expressed as the so-called "hybrid schema" -- a single RELAX NG schema with 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 be used for validating specific XML documents such as client requests, server responses or notifications, perhaps also taking into account additional context such as active capabilities or features.

本文档包含一个映射规范,该规范使用DSDL模式语言的子集将数据模型转换为XML模式。映射过程分为两个步骤:在第一步中,数据树的结构、远程过程调用(RPC)操作的签名和通知被表示为所谓的“混合模式”——单个RELAXNG模式,带有表示附加数据模型信息的注释(元数据、文档、语义约束、默认值等)。然后,第二步生成一组协调的DSDL模式,可用于验证特定的XML文档,如客户端请求、服务器响应或通知,可能还考虑了其他上下文,如活动功能或特性。

2. Terminology and Notation
2. 术语和符号

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].

本文件中的关键词“必须”、“不得”、“必需”、“应”、“不应”、“应”、“不应”、“建议”、“可”和“可选”应按照[RFC2119]中所述进行解释。

The following terms are defined in [RFC4741]:

[RFC4741]中定义了以下术语:

o client

o 客户

o datastore

o 数据存储

o message

o 消息

o operation

o 活动

o server

o 服务器

The following terms are defined in [RFC6020]:

[RFC6020]中定义了以下术语:

o augment

o 加强

o base type

o 基本类型

o built-in type

o 内置式

o configuration data

o 配置数据

o container

o 容器

o data model

o 数据模型

o data node

o 数据节点

o data tree

o 数据树

o derived type

o 派生类型

o device deviation

o 设备偏差

o extension

o 扩大

o feature

o 特色

o grouping

o 分组

o instance identifier

o 实例标示符

o leaf-list

o 叶列表

o list

o 列表

o mandatory node

o 强制节点

o module

o 单元

o RPC

o RPC

o RPC operation

o RPC操作

o schema node

o 模式节点

o schema tree

o 模式树

o state data

o 状态数据

o submodule

o 子模块

o top-level data node

o 顶级数据节点

o uses

o 使用

The following terms are defined in [XML-INFOSET]:

[XML-INFOSET]中定义了以下术语:

o attribute

o 属性

o document

o 文件

o document element

o 文档元素

o document type declaration (DTD)

o 文档类型声明(DTD)

o element

o 要素

o information set

o 信息集

o namespace

o 名称空间

In the text, the following typographic conventions are used:

在文本中,使用了以下排版惯例:

o YANG statement keywords are delimited by single quotes.

o YANG语句关键字由单引号分隔。

o XML element names are delimited by "<" and ">" characters.

o XML元素名称由“<”和“>”字符分隔。

o Names of XML attributes are prefixed by the "@" character.

o XML属性的名称以“@”字符作为前缀。

o Other literal values are delimited by double quotes.

o 其他文字值由双引号分隔。

XML element names are always written with explicit namespace prefixes corresponding to the following XML vocabularies:

XML元素名称始终使用与以下XML词汇表对应的显式命名空间前缀编写:

"a" DTD compatibility annotations [RNG-DTD];

“a”DTD兼容性注释[RNG-DTD];

"dc" Dublin Core metadata elements [RFC5013];

“dc”都柏林核心元数据元素[RFC5013];

"dsrl" Document Semantics Renaming Language [DSRL];

“dsrl”文档语义重命名语言[dsrl];

"en" NETCONF event notifications [RFC5277];

“en”NETCONF事件通知[RFC5277];

"nc" NETCONF protocol [RFC4741];

“nc”网络配置协议[RFC4741];

"nma" NETMOD-specific schema annotations (see Section 5.3);

“nma”NETMOD特定模式注释(见第5.3节);

"nmf" NETMOD-specific XML Path Language (XPath) extension functions (see Section 12.7);

“nmf”NETMOD特定的XML路径语言(XPath)扩展函数(见第12.7节);

"rng" RELAX NG [RNG];

“rng”放松NG[rng];

"sch" ISO Schematron [Schematron];

“sch”ISO Schematron[Schematron];

"xsd" W3C XML Schema [XSD].

“xsd”W3CXML模式[xsd]。

The following table shows the mapping of these prefixes to namespace URIs.

下表显示了这些前缀到命名空间URI的映射。

     +--------+-----------------------------------------------------+
     | 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    |
     |        |                                                     |
     | rng    | http://relaxng.org/ns/structure/1.0                 |
     |        |                                                     |
     | sch    | http://purl.oclc.org/dsdl/schematron                |
     |        |                                                     |
     | xsd    | http://www.w3.org/2001/XMLSchema                    |
     +--------+-----------------------------------------------------+
        
     +--------+-----------------------------------------------------+
     | 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    |
     |        |                                                     |
     | 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

表1:使用的名称空间前缀和相应的URI

2.1. Glossary of New Terms
2.1. 新术语表

o ancestor data type: Any data type from which a given data type is (transitively) derived.

o 祖先数据类型:从中(可传递地)派生给定数据类型的任何数据类型。

o ancestor built-in data type: The built-in data type that is at the start of the type derivation chain for a given data type.

o 祖先内置数据类型:位于给定数据类型的类型派生链开头的内置数据类型。

o hybrid schema: A RELAX NG schema with annotations, which embodies the same information as the source YANG module(s). See Section 8.1 for details.

o 混合模式:带有注释的RELAXNG模式,包含与源模块相同的信息。详见第8.1节。

o implicit node: A data node that, if it is not instantiated in a data tree, may be added to the information set of that data tree (configuration, RPC input or output, notification) without changing the semantics of the data tree.

o 隐式节点:如果未在数据树中实例化,则可将其添加到该数据树的信息集(配置、RPC输入或输出、通知),而无需更改数据树的语义。

3. Objectives and Motivation
3. 目标和动机

The main objective of this work is to complement YANG as a data modeling language with validation capabilities of DSDL schema languages, namely RELAX NG, Schematron, and DSRL. This document describes the correspondence between grammatical, semantic, and data type constraints expressed in YANG and equivalent DSDL patterns and rules. 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 may in principle be invertible, the inverse mapping from DSDL to YANG is beyond the scope of this document.

这项工作的主要目标是用DSDL模式语言(即RELAXNG、Schematron和DSRL)的验证功能补充YANG作为数据建模语言。本文档描述了YANG表示的语法、语义和数据类型约束与等效DSDL模式和规则之间的对应关系。最终目标是能够捕获模块中包含的所有实质性信息,并用DSDL模式表示。虽然本文件中描述的从YANG到DSDL的映射原则上是可逆的,但从DSDL到YANG的逆映射超出了本文件的范围。

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 operations are characterized by an inherent diversity resulting from selective availability of capabilities and features. YANG modules can also define new RPC operations. 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.

基于XML的信息模型和XML编码的数据以几种不同的形式出现在数据建模和NETCONF工作流的不同阶段——配置数据存储内容、RPC请求和回复以及通知。此外,RPC操作的特点是由于功能和特性的选择性可用性而产生的固有多样性。模块还可以定义新的RPC操作。映射应该能够适应这种可变性,并生成专门针对特定情况定制的模式,从而比通用的包罗万象模式更有效地进行验证。

In order to cope with this variability, we assume that the DSDL schemas will be generated on demand for a particular purpose 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.

为了应对这种可变性,我们假设DSDL模式将根据需要从可用的模块集合中为特定目的生成,并且它们的生命周期相对较短。换句话说,我们不认为任何DSDL模式的集合将与模块并行地在较长的时间内创建和维护。

The generated schemas are primarily intended as input to 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:

生成的模式主要用作现有XML模式验证器和其他现成工具的输入。但是,开发人员和用户也可以仔细阅读模式,将其作为特定XML编码数据对象上约束的正式表示。因此,我们的第二个目标是尽可能保持模式的可读性。为此,映射的复杂性分为两个步骤:

1. The first step maps one or more YANG modules to the so-called hybrid schema, which is a single RELAX NG schema that describes grammatical constraints for the main data tree as well as for RPC operations and notifications. Semantic constraints and other information appearing in the input YANG modules is recorded in the hybrid schema in the form of foreign namespace annotations. The output of the first step can thus be considered a virtually complete equivalent of the input YANG modules. It cannot, however, be directly used for any validation.

1. 第一步将一个或多个模块映射到所谓的混合模式,这是一个单一的RELAXNG模式,用于描述主数据树以及RPC操作和通知的语法约束。输入模块中出现的语义约束和其他信息以外部名称空间注释的形式记录在混合模式中。因此,第一步的输出可视为输入模块的几乎完全等效。但是,它不能直接用于任何验证。

2. In the second step, the hybrid 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.

2. 在第二步中,将步骤1中的混合模式进一步转换为一组协调的完全一致的DSDL模式,其中包含特定数据对象和特定情况的约束。DSDL模式主要用于使用现成工具进行机器验证。

4. DSDL Schema Languages
4. DSDL模式语言

Document Schema Definition Languages (DSDL) is a framework of schema languages that is being developed as the International Standard ISO/ IEC 19757 [DSDL]. Unlike other approaches to XML document validation, most notably W3C XML Schema Definition (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.

文档模式定义语言(DSDL)是模式语言的一个框架,正在作为国际标准ISO/IEC 19757[DSDL]进行开发。与其他XML文档验证方法(最著名的是W3C XML模式定义(XSD)[XSD])不同,DSDL框架遵循“小型语言”原则:每个DSDL组成部分都是独立的模式语言,目的和重点相对狭窄。这些模式语言可以协同使用,以完成各种验证任务。

The mapping described in this document uses three of the DSDL schema languages, namely RELAX NG [RNG], Schematron [Schematron], and DSRL [DSRL].

本文中描述的映射使用三种DSDL模式语言,即RELAXNG[RNG]、Schematron[Schematron]和DSRL[DSRL]。

4.1. RELAX NG
4.1. 放松

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 XSD, it is able to describe constraints on the structure and contents 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).

RELAXNG(发音为“relaxing”)是一种用于基于语法的验证的XML模式语言,是ISO/IEC DSDL标准系列[RNG]的第2部分。与XSD一样,它能够描述对XML文档的结构和内容的约束。但是,与DTD[XML]和XSD模式语言不同,RELAXNG有意避免任何信息集扩充,例如定义默认值。在DSDL体系结构中,定义和应用默认值的特定任务被委托给另一种模式语言DSRL(参见第4.3节)。

As its base data type library, RELAX NG uses the W3C XML Schema Datatypes [XSD-D]; but unlike XSD, other data type libraries may be used along with it or even replace it if necessary.

作为其基本数据类型库,RELAXNG使用W3CXMLSchema数据类型[XSD-D];但与XSD不同的是,其他数据类型库可以与它一起使用,甚至在必要时替换它。

RELAX NG is very liberal in accepting annotations from other namespaces. With a few exceptions, such annotations may be placed anywhere in the schema and need no encapsulating elements such as <xsd:annotation> in XSD.

RELAXNG在接受来自其他名称空间的注释方面非常自由。除了少数例外,这样的注释可以放在模式中的任何位置,并且不需要像xsd中的<xsd:annotation>这样的封装元素。

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 [Trang].

RELAXNG模式可以用两种等价的语法表示:XML和compact。RELAX NG规范[RNG-CS]的附录C中描述了紧凑语法,该规范于2006年添加到标准中(修改件1)。两种语法之间的自动双向转换可以使用多种工具完成,例如Trang[Trang]。

For its terseness and readability, the compact syntax is often the preferred form for publishing RELAX NG schemas, whereas validators and other software tools usually work with the XML syntax. However, the compact syntax has two drawbacks:

由于简洁易读,紧凑语法通常是发布RELAXNG模式的首选形式,而验证器和其他软件工具通常使用XML语法。但是,紧凑语法有两个缺点:

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 as many as 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 it is for the XML syntax.

o 外部注释使紧凑语法模式的可读性大大降低。在XML语法中,注释元素和属性以简单统一的方式表示(来自外部名称空间的XML元素和属性),而紧凑语法使用多达四种不同的语法结构:文档、语法、初始注释和后续注释。因此,对于紧凑语法,注释对可读性的影响通常比XML语法大得多。

o In a computer program, it is more difficult to generate the compact syntax than the XML syntax. While a number of software libraries exist that make it easy to create an XML tree in the memory and then serialize it, no such aid is available for the compact syntax.

o 在计算机程序中,生成紧凑语法比生成XML语法更困难。虽然存在许多软件库,可以很容易地在内存中创建XML树,然后对其进行序列化,但是对于紧凑语法没有这样的帮助。

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.

出于这些原因,本文中的映射规范专门使用XML语法。但是,在适当的情况下,翻译产生的模式可以用等效的紧凑语法表示。

RELAX NG elements are qualified with the namespace URI "http://relaxng.org/ns/structure/1.0". The namespace of the XSD data type library is "http://www.w3.org/2001/XMLSchema-datatypes".

RELAX NG元素使用命名空间URI进行限定“http://relaxng.org/ns/structure/1.0". XSD数据类型库的命名空间为“http://www.w3.org/2001/XMLSchema-datatypes".

4.2. Schematron
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:

Schematron是DSDL的第3部分,在2006年达到了完整的ISO/IEC标准[Schematron]。与基于形式语法概念的传统模式语言(如DTD、XSD或RELAXNG)不同,Schematron使用基于规则的方法。它的规则可以指定涉及XML文档不同部分数据的任意条件。每个规则由三个基本组成部分组成:

o context - an XPath expression that defines the set of locations where the rule is to be applied;

o 上下文-定义应用规则的位置集的XPath表达式;

o assert or report condition - another XPath expression that is evaluated relative to the location matched by the context expression;

o assert或report condition—另一个XPath表达式,该表达式相对于上下文表达式匹配的位置进行计算;

o human-readable message that is displayed when the assert condition is false or report condition is true.

o 当断言条件为false或报告条件为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.

断言条件和报告条件之间的区别在于前者是肯定的,因为它声明了有效文档必须满足的条件,而后者指定了错误条件。

Schematron draws most of its expressive power from XPath [XPath] and Extensible Stylesheet Language Transformations (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 the future).

Schematron的大部分表达能力来自XPath[XPath]和可扩展样式表语言转换(XSLT)[XSLT]。ISO Schematron允许动态查询语言绑定,以便可以使用以下XML查询语言:STX、XSLT 1.0、XSLT 1.1、EXSLT、XSLT 2.0、XPath 1.0、XPath 2.0和XQuery 1.0(此列表将来可能会扩展)。

Human-readable error messages are another feature that sets Schematron apart from other common schema languages. The messages may even contain XPath expressions that are evaluated in the actual context and thus refer to information items in the XML document being validated.

人类可读的错误消息是将Schematron与其他常见模式语言区分开来的另一个特性。消息甚至可能包含在实际上下文中计算的XPath表达式,从而引用正在验证的XML文档中的信息项。

Another feature of Schematron that is used by the mapping are abstract patterns. These work essentially as macros and may also contain parameters which are supplied when the abstract pattern is used.

映射使用的Schematron的另一个特性是抽象模式。这些基本上是作为宏工作的,还可能包含使用抽象模式时提供的参数。

Schematron elements are qualified with namespace URI "http://purl.oclc.org/dsdl/schematron".

Schematron元素使用命名空间URI进行限定“http://purl.oclc.org/dsdl/schematron".

4.3. Document Semantics Renaming Language (DSRL)
4.3. 文档语义重命名语言(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, DSRL is allowed 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 contents for XML elements or subtrees so that the default contents are inserted if they are missing in the validated documents. The latter feature is used by the YANG-to-DSDL mapping for representing YANG default contents consisting of leaf nodes with default values and their ancestor non-presence containers.

DSRL(发音为“disrule”)是DSDL的第8部分,于2008年达到完整ISO/IEC标准的状态[DSRL]。与RELAXNG和Schematron不同,DSRL允许修改已验证文档的XML信息集。虽然DSRL主要用于重命名XML元素和属性,但它还可以定义XML属性的默认值以及XML元素或子树的默认内容,以便在验证文档中缺少默认内容时插入这些内容。YANG-to-DSDL映射使用后一个特性来表示由具有默认值的叶节点及其祖先不存在容器组成的YANG默认内容。

DSRL elements are qualified with namespace URI "http://purl.oclc.org/dsdl/dsrl".

DSRL元素使用命名空间URI进行限定”http://purl.oclc.org/dsdl/dsrl".

5. Additional Annotations
5. 附加注释

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.

除了DSDL模式语言之外,映射还使用三组注释,这些注释作为外部名称空间属性和元素添加,以放松NG模式。

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 hybrid schema and MAY also appear in the final validation schemas.

其中两个注释集——都柏林核心元素和DTD兼容性注释——分别是表示元数据和文档的标准词汇表。尽管这些数据模型项不用于正式验证,但它们通常为数据模型实现者提供重要信息。因此,它们应该包含在混合模式中,也可能出现在最终验证模式中。

The third set are NETMOD-specific annotations. They are specifically designed for the hybrid schema and convey semantic constraints and other information that cannot be expressed directly in RELAX NG. In the second mapping step, these annotations are converted to Schematron and DSRL rules.

第三组是NETMOD特定的注释。它们是专门为混合模式设计的,并传递语义约束和其他不能在RELAXNG中直接表达的信息。在第二个映射步骤中,这些注释被转换为Schematron和DSRL规则。

5.1. Dublin Core Metadata Elements
5.1. 都柏林核心元数据元素

Dublin Core is a system of metadata elements that was originally created for describing metadata of World Wide Web resources in order to facilitate their automated lookup. Later it was accepted as a standard for describing metadata of arbitrary resources. This specification uses the definition from [RFC5013].

Dublin Core是一个元数据元素系统,最初创建该系统是为了描述万维网资源的元数据,以方便其自动查找。后来,它被接受为描述任意资源元数据的标准。本规范使用[RFC5013]中的定义。

Dublin Core elements are qualified with namespace URI "http://purl.org/dc/terms".

都柏林核心元素使用名称空间URI进行限定”http://purl.org/dc/terms".

5.2. RELAX NG DTD Compatibility Annotations
5.2. RELAXNG DTD兼容性注释

DTD compatibility annotations are a 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.

DTD兼容性注释是RELAXNG DTD兼容性规范[RNG-DTD]的一部分。YANG到DSDL的映射仅使用<a:documentation>注释来表示YANG的“描述”和“参考”文本。

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 formatted by several RELAX NG tools.

请注意,并不打算使生成的模式与DTD兼容,使用这些注释的主要原因是技术性的:它们得到了多个RELAXNG工具的良好支持并得到了充分的格式化。

DTD compatibility annotations are qualified with namespace URI "http://relaxng.org/ns/compatibility/annotations/1.0".

DTD兼容性批注使用命名空间URI进行限定”http://relaxng.org/ns/compatibility/annotations/1.0".

5.3. NETMOD-Specific Annotations
5.3. NETMOD特定注释

NETMOD-specific annotations are XML elements and attributes that are qualified with the namespace URI "urn:ietf:params:xml:ns:netmod:dsdl-annotations:1" and that appear in various locations of the hybrid schema. YANG statements are mapped to these annotations in a straightforward way. In most cases, the annotation attributes and elements have the same name as the corresponding YANG statement.

特定于NETMOD的注释是使用名称空间URI“urn:ietf:params:XML:ns:NETMOD:dsdl annotations:1”限定的XML元素和属性,它们出现在混合模式的不同位置。YANG语句以一种简单的方式映射到这些注释。在大多数情况下,注释属性和元素与相应的语句具有相同的名称。

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 a RELAX NG schema for this annotation vocabulary.

表2按字母顺序列出了NETMOD特定注释属性(前缀为“@”)和元素(尖括号中)的名称,以及对其使用说明部分的引用。附录A包含此注释词汇表的RELAXNG模式。

         +---------------------------+--------------------+------+
         | annotation                | section            | note |
         +---------------------------+--------------------+------+
         | @nma:config               | 10.9               |      |
         |                           |                    |      |
         | <nma:data>                | 8.1                | 4    |
         |                           |                    |      |
         | @nma:default              | 10.12              |      |
         |                           |                    |      |
         | <nma:error-app-tag>       | 10.16              | 1    |
         |                           |                    |      |
         | <nma:error-message>       | 10.17              | 1    |
         |                           |                    |      |
         | @nma:if-feature           | 10.22              |      |
         |                           |                    |      |
         | @nma:implicit             | 10.11, 10.7, 10.12 |      |
         |                           |                    |      |
         | <nma:input>               | 8.1                | 4    |
         |                           |                    |      |
         | <nma:instance-identifier> | 10.53.7            | 2    |
         |                           |                    |      |
         | @nma:key                  | 10.26              |      |
         |                           |                    |      |
         | @nma:leaf-list            | 10.28              |      |
         |                           |                    |      |
         | @nma:leafref              | 10.53.8            |      |
         |                           |                    |      |
         | @nma:mandatory            | 10.8               |      |
         |                           |                    |      |
         | @nma:max-elements         | 10.28              |      |
         |                           |                    |      |
         | @nma:min-elements         | 10.28              |      |
        
         +---------------------------+--------------------+------+
         | annotation                | section            | note |
         +---------------------------+--------------------+------+
         | @nma:config               | 10.9               |      |
         |                           |                    |      |
         | <nma:data>                | 8.1                | 4    |
         |                           |                    |      |
         | @nma:default              | 10.12              |      |
         |                           |                    |      |
         | <nma:error-app-tag>       | 10.16              | 1    |
         |                           |                    |      |
         | <nma:error-message>       | 10.17              | 1    |
         |                           |                    |      |
         | @nma:if-feature           | 10.22              |      |
         |                           |                    |      |
         | @nma:implicit             | 10.11, 10.7, 10.12 |      |
         |                           |                    |      |
         | <nma:input>               | 8.1                | 4    |
         |                           |                    |      |
         | <nma:instance-identifier> | 10.53.7            | 2    |
         |                           |                    |      |
         | @nma:key                  | 10.26              |      |
         |                           |                    |      |
         | @nma:leaf-list            | 10.28              |      |
         |                           |                    |      |
         | @nma:leafref              | 10.53.8            |      |
         |                           |                    |      |
         | @nma:mandatory            | 10.8               |      |
         |                           |                    |      |
         | @nma:max-elements         | 10.28              |      |
         |                           |                    |      |
         | @nma:min-elements         | 10.28              |      |
        
         |                           |                    |      |
         | @nma:module               | 10.34              |      |
         |                           |                    |      |
         | <nma:must>                | 10.35              | 3    |
         |                           |                    |      |
         | <nma:notification>        | 8.1                | 4    |
         |                           |                    |      |
         | <nma:notifications>       | 8.1                | 4    |
         |                           |                    |      |
         | @nma:ordered-by           | 10.38              |      |
         | <nma:output>              | 8.1                | 4    |
         |                           |                    |      |
         | <nma:rpc>                 | 8.1                | 4    |
         |                           |                    |      |
         | <nma:rpcs>                | 8.1                | 4    |
         |                           |                    |      |
         | @nma:status               | 10.51              |      |
         |                           |                    |      |
         | @nma:unique               | 10.55              |      |
         |                           |                    |      |
         | @nma:units                | 10.56              |      |
         |                           |                    |      |
         | @nma:when                 | 10.59              |      |
         +---------------------------+--------------------+------+
        
         |                           |                    |      |
         | @nma:module               | 10.34              |      |
         |                           |                    |      |
         | <nma:must>                | 10.35              | 3    |
         |                           |                    |      |
         | <nma:notification>        | 8.1                | 4    |
         |                           |                    |      |
         | <nma:notifications>       | 8.1                | 4    |
         |                           |                    |      |
         | @nma:ordered-by           | 10.38              |      |
         | <nma:output>              | 8.1                | 4    |
         |                           |                    |      |
         | <nma:rpc>                 | 8.1                | 4    |
         |                           |                    |      |
         | <nma:rpcs>                | 8.1                | 4    |
         |                           |                    |      |
         | @nma:status               | 10.51              |      |
         |                           |                    |      |
         | @nma:unique               | 10.55              |      |
         |                           |                    |      |
         | @nma:units                | 10.56              |      |
         |                           |                    |      |
         | @nma:when                 | 10.59              |      |
         +---------------------------+--------------------+------+
        

Table 2: NETMOD-specific annotations

表2:NETMOD特定注释

Notes:

笔记:

1. Appears only as a subelement of <nma:must>.

1. 仅显示为<nma:must>的子元素。

2. Has an optional attribute @require-instance.

2. 具有可选属性@require instance。

3. Has a mandatory attribute @assert and two optional subelements <nma:error-app-tag> and <nma:error-message>.

3. 具有一个强制属性@assert和两个可选子元素<nma:error-app-tag>和<nma:error-message>。

4. Marker element in the hybrid schema.

4. 混合模式中的Marker元素。

6. Overview of the Mapping
6. 地图概述

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到DSDL的映射及其输入和输出。图1显示了映射的总体结构:

                    +----------------+
                    | YANG module(s) |
                    +----------------+
                            |
                            |T
                            |
          +------------------------------------+
          |           hybrid schema            |
          +------------------------------------+
               /       |           |       \
              /        |           |        \
           Tg/       Tr|           |Tn       \
            /          |           |          \
      +---------+   +-----+    +-------+    +------+
      |get reply|   | rpc |    | notif |    | .... |
      +---------+   +-----+    +-------+    +------+
        
                    +----------------+
                    | YANG module(s) |
                    +----------------+
                            |
                            |T
                            |
          +------------------------------------+
          |           hybrid schema            |
          +------------------------------------+
               /       |           |       \
              /        |           |        \
           Tg/       Tr|           |Tn       \
            /          |           |          \
      +---------+   +-----+    +-------+    +------+
      |get reply|   | rpc |    | notif |    | .... |
      +---------+   +-----+    +-------+    +------+
        

Figure 1: Structure of the mapping

图1:映射的结构

The mapping procedure is divided into two steps:

映射过程分为两个步骤:

1. Transformation T in the first step maps one or more YANG modules to the hybrid schema (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 foreign-namespace annotations.

1. 第一步中的转换T将一个或多个YANG模块映射到混合模式(参见第8.1节)。不能直接在RELAXNG(列出键定义、“必须”语句等)和各种文档文本中表示的约束将作为外部名称空间注释记录在模式中。

2. In the second step, the hybrid schema may be 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 three simple possibilities as examples. In the process, appropriate parts of the hybrid schema are extracted and specific annotations transformed to equivalent, but usually more complex, Schematron patterns, DSRL element maps, etc.

2. 在第二步中,可以以多种方式将混合模式转换为可用于在特定上下文中验证特定数据对象的DSDL模式的协调集。图1显示了三种简单的可能性作为示例。在此过程中,提取混合模式的适当部分,并将特定注释转换为等效但通常更复杂的模式转换器模式、DSRL元素映射等。

An implementation of the mapping algorithm MUST accept one or more valid YANG modules as its input. It is important to be able to process multiple YANG modules together since multiple modules may be negotiated for a NETCONF session and the contents of the configuration datastore is then obtained as the union of data trees specified by the individual modules, which may also lead to multiple root nodes of the datastore hierarchy. In addition, the input modules may be further coupled by the 'augment' statement in which one module augments the data tree of another module.

映射算法的实现必须接受一个或多个有效模块作为其输入。能够同时处理多个模块是很重要的,因为可以为NETCONF会话协商多个模块,然后将配置数据存储的内容作为各个模块指定的数据树的联合来获取,这也可能导致数据存储层次结构的多个根节点。此外,输入模块还可以通过“augment”语句进行耦合,其中一个模块扩充另一个模块的数据树。

It is also assumed that the algorithm has access, perhaps on demand, to all YANG modules that the input modules import (directly or transitively).

还假设算法可以访问(可能是按需)输入模块导入的所有模块(直接或传递)。

Other information contained in input YANG modules, such as semantic constraints and default values, is recorded in the hybrid schema as annotations -- XML attributes or elements qualified with the namespace URI "urn:ietf:params:xml:ns:netmod:dsdl-annotations:1". Metadata describing the YANG modules are mapped to Dublin Core annotations elements (Section 5.1). Finally, documentation strings are mapped to <a:documentation> elements belonging to the DTD compatibility vocabulary (Section 5.2).

输入模块中包含的其他信息(如语义约束和默认值)作为注释记录在混合模式中——XML属性或使用名称空间URI“urn:ietf:params:XML:ns:netmod:dsdl annotations:1”限定的元素。描述YANG模块的元数据映射到都柏林核心注释元素(第5.1节)。最后,文档字符串映射到属于DTD兼容性词汇表的<a:documentation>元素(第5.2节)。

The output of the second step is a coordinated set of three DSDL schemas corresponding to a specific data object and context:

第二步的输出是三个DSDL模式的协调集,对应于特定的数据对象和上下文:

o RELAX NG schema describing the grammatical and data type constraints;

o RELAX NG模式描述语法和数据类型约束;

o Schematron schema expressing other constraints such as uniqueness of list keys or user-specified semantic rules;

o Schematron schema表示其他约束,如列表键的唯一性或用户指定的语义规则;

o DSRL schema containing the specification of default contents.

o 包含默认内容规范的DSRL架构。

7. NETCONF Content Validation
7. NETCONF内容验证

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 contents of a datastore or various NETCONF messages.

本节介绍如何应用YANG到DSDL映射生成的模式来验证XML实例文档,如数据存储或各种NETCONF消息的内容。

The validation proceeds in the following steps, which are also illustrated in Figure 2:

验证按照以下步骤进行,图2中也对这些步骤进行了说明:

1. The XML instance document is checked for grammatical and data type validity using the RELAX NG schema.

1. 使用RELAXNG模式检查XML实例文档的语法和数据类型有效性。

2. Default values for leaf nodes have to be applied and their ancestor containers added where necessary. It is important to add the implicit nodes before the next validation step because YANG specification [RFC6020] requires 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 validated XML document.

2. 必须应用叶节点的默认值,并在必要时添加其祖先容器。在下一个验证步骤之前添加隐式节点很重要,因为YANG规范[RFC6020]要求计算XPath表达式所依据的数据树已经填充了所有默认值。请注意,此步骤将修改已验证XML文档的信息集。

3. The semantic constraints are checked using the Schematron schema.

3. 使用Schematron模式检查语义约束。

         +----------+                        +----------+
         |          |                        |   XML    |
         |   XML    |                        | document |
         | document |-----------o----------->|   with   |
         |          |           ^            | defaults |
         |          |           |            |          |
         +----------+           |            +----------+
              ^                 | filling in       ^
              | grammar,        | defaults         | semantic
              | data types       |                  | constraints
              |                 |                  |
         +----------+       +--------+       +------------+
         | RELAX NG |       |  DSRL  |       | Schematron |
         |  schema  |       | schema |       |   schema   |
         +----------+       +--------+       +------------+
        
         +----------+                        +----------+
         |          |                        |   XML    |
         |   XML    |                        | document |
         | document |-----------o----------->|   with   |
         |          |           ^            | defaults |
         |          |           |            |          |
         +----------+           |            +----------+
              ^                 | filling in       ^
              | grammar,        | defaults         | semantic
              | data types       |                  | constraints
              |                 |                  |
         +----------+       +--------+       +------------+
         | RELAX NG |       |  DSRL  |       | Schematron |
         |  schema  |       | schema |       |   schema   |
         +----------+       +--------+       +------------+
        

Figure 2: Outline of the validation procedure

图2:验证程序概要

8. Design Considerations
8. 设计考虑

YANG data models could, in principle, be mapped to the 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.

原则上,数据模型可以通过多种方式映射到DSDL模式。本文档中描述的映射过程使用了以下小节中讨论的几个特定设计决策。

8.1. Hybrid Schema
8.1. 混合模式

As was explained in Section 6, the first step of the mapping produces an intermediate document -- the hybrid schema, which specifies all constraints for the entire data model using the RELAX NG syntax and additional annotations. In cannot be directly used for validation -- as a matter of fact, it is not even a valid RELAX NG schema because it contains multiple schemas demarcated by special annotation elements.

如第6节所述,映射的第一步生成一个中间文档——混合模式,它使用RELAXNG语法和其他注释指定整个数据模型的所有约束。In不能直接用于验证——事实上,它甚至不是有效的RELAXNG模式,因为它包含由特殊注释元素划分的多个模式。

Every input YANG module corresponds to exactly one embedded grammar in the hybrid schema. This separation of input YANG modules allows each embedded grammar to include named pattern definitions into its own namespace, which is important for mapping YANG groupings (see Section 9.2 for additional details).

每个输入模块在混合模式中只对应一个嵌入式语法。输入模块的这种分离允许每个嵌入式语法将命名模式定义包含到自己的名称空间中,这对于映射YANG分组很重要(更多详细信息,请参见第9.2节)。

In addition to grammatical and data type constraints, YANG modules provide other important information that cannot be expressed in a RELAX NG schema: semantic constraints, default values, metadata, documentation, and so on. Such information items are represented in

除了语法和数据类型约束之外,YANG模块还提供了不能在RELAXNG模式中表达的其他重要信息:语义约束、默认值、元数据、文档等。这些信息项在中表示

the hybrid schema as XML attributes and elements belonging to the namespace with the following URI: "urn:ietf:params:xml:ns:netmod:dsdl-annotations:1". A complete list of these annotations is given in Section 5.3, detailed rules about their use are then contained in the following sections.

混合模式是属于以下URI的命名空间的XML属性和元素:“urn:ietf:params:XML:ns:netmod:dsdl annotations:1”。第5.3节中给出了这些注释的完整列表,有关其使用的详细规则将包含在以下各节中。

YANG modules define data models not only for configuration and state data but also for (multiple) RPC operations [RFC4741] and/or event notifications [RFC5277]. In order to be able to capture all three types of data models in one schema document, the hybrid schema uses special markers that enclose sub-schemas for configuration and state data, individual RPC operations (both input and output part) and individual notifications.

YANG模块不仅为配置和状态数据定义数据模型,还为(多个)RPC操作[RFC4741]和/或事件通知[RFC5277]定义数据模型。为了能够在一个模式文档中捕获所有三种类型的数据模型,混合模式使用特殊的标记,将配置和状态数据、单个RPC操作(输入和输出部分)和单个通知的子模式括起来。

The markers are the following XML elements in the namespace of NETMOD-specific annotations (URI urn:ietf:params:xml:ns:netmod:dsdl-annotations:1):

标记是NETMOD特定注释命名空间中的以下XML元素(URI urn:ietf:params:XML:ns:NETMOD:dsdl注释:1):

       +-------------------+---------------------------------------+
       | Element name      | Role                                  |
       +-------------------+---------------------------------------+
       | nma:data          | encloses configuration and state data |
       |                   |                                       |
       | nma:rpcs          | encloses all RPC operations           |
       |                   |                                       |
       | nma:rpc           | encloses an individual RPC operation  |
       |                   |                                       |
       | nma:input         | encloses an RPC request               |
       |                   |                                       |
       | nma:output        | encloses an RPC reply                 |
       |                   |                                       |
       | nma:notifications | encloses all notifications            |
       |                   |                                       |
       | nma:notification  | encloses an individual notification   |
       +-------------------+---------------------------------------+
        
       +-------------------+---------------------------------------+
       | Element name      | Role                                  |
       +-------------------+---------------------------------------+
       | nma:data          | encloses configuration and state data |
       |                   |                                       |
       | nma:rpcs          | encloses all RPC operations           |
       |                   |                                       |
       | nma:rpc           | encloses an individual RPC operation  |
       |                   |                                       |
       | nma:input         | encloses an RPC request               |
       |                   |                                       |
       | nma:output        | encloses an RPC reply                 |
       |                   |                                       |
       | nma:notifications | encloses all notifications            |
       |                   |                                       |
       | nma:notification  | encloses an individual notification   |
       +-------------------+---------------------------------------+
        

Table 3: Marker elements in the hybrid schema

表3:混合模式中的标记元素

For example, consider a data model formed by two YANG modules "example-a" and "example-b" that define nodes in the namespaces "http://example.com/ns/example-a" and "http://example.com/ns/example-b". Module "example-a" defines configuration/state data, RPC methods and notifications, whereas "example-b" defines only configuration/state data. The hybrid schema can then be schematically represented as follows:

例如,考虑一个由两个杨氏模块组成的数据模型:“示例A”和“示例B”,这些节点定义命名空间中的节点。http://example.com/ns/example-a“和”http://example.com/ns/example-b". 模块“示例-a”定义配置/状态数据、RPC方法和通知,而“示例-b”仅定义配置/状态数据。然后,混合模式可以示意性地表示如下:

  <grammar xmlns="http://relaxng.org/ns/structure/1.0"
           xmlns:nma="urn:ietf:params:xml:ns:netmod:dsdl-annotations:1"
           xmlns:exa="http://example.com/ns/example-a"
           xmlns:exb="http://example.com/ns/example-b"
           datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
    <start>
      <grammar nma:module="example-a"
               ns="http://example.com/ns/example-a">
        <start>
          <nma:data>
            ...configuration and state data defined in "example-a"...
          </nma:data>
          <nma:rpcs>
            <nma:rpc>
              <nma:input>
                <element name="exa:myrpc">
                  ...
                </element>
              </nma:input>
              <nma:output>
                ...
              </nma:output>
            </nma:rpc>
            ...
          </nma:rpcs>
          <nma:notifications>
            <nma:notification>
              <element name="exa:mynotif">
                ...
              </element>
            </nma:notification>
            ...
          </nma:notifications>
        </start>
        ...local named pattern definitions of example-a...
      </grammar>
      <grammar nma:module="example-b"
               ns="http://example.com/ns/example-a">
        <start>
          <nma:data>
            ...configuration and state data defined in "example-b"...
          </nma:data>
          <nma:rpcs/>
          <nma:notifications/>
        </start>
        ...local named pattern definitions of example-b...
      </grammar>
    </start>
        
  <grammar xmlns="http://relaxng.org/ns/structure/1.0"
           xmlns:nma="urn:ietf:params:xml:ns:netmod:dsdl-annotations:1"
           xmlns:exa="http://example.com/ns/example-a"
           xmlns:exb="http://example.com/ns/example-b"
           datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
    <start>
      <grammar nma:module="example-a"
               ns="http://example.com/ns/example-a">
        <start>
          <nma:data>
            ...configuration and state data defined in "example-a"...
          </nma:data>
          <nma:rpcs>
            <nma:rpc>
              <nma:input>
                <element name="exa:myrpc">
                  ...
                </element>
              </nma:input>
              <nma:output>
                ...
              </nma:output>
            </nma:rpc>
            ...
          </nma:rpcs>
          <nma:notifications>
            <nma:notification>
              <element name="exa:mynotif">
                ...
              </element>
            </nma:notification>
            ...
          </nma:notifications>
        </start>
        ...local named pattern definitions of example-a...
      </grammar>
      <grammar nma:module="example-b"
               ns="http://example.com/ns/example-a">
        <start>
          <nma:data>
            ...configuration and state data defined in "example-b"...
          </nma:data>
          <nma:rpcs/>
          <nma:notifications/>
        </start>
        ...local named pattern definitions of example-b...
      </grammar>
    </start>
        

...global named pattern definitions... </grammar>

…全局命名模式定义</语法>

A complete hybrid schema for the data model of a DHCP server is given in Appendix C.2.

附录C.2中给出了DHCP服务器数据模型的完整混合模式。

8.2. Modularity
8.2. 模块化

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 MIB modules. The following differences are important:

YANG和RELAX NG都提供了模块化的方法,即将完整模式的内容拆分为单独的模块,并以各种方式组合或重用它们。然而,杨和吴采取的方法不同。RELAXNG中的模块化适用于少量模式的即席组合,而YANG假设有大量类似于SNMP MIB模块的模块。以下差异很重要:

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 在YANG中,每当模块A导入模块B时,它都可以访问出现在模块B顶层的定义(分组和typedef)。但是,模块B中的数据树的任何部分都不会随之导入。相反,RELAXNG中的<rng:include>模式从包含的模式中导入命名模式的定义和整个模式树。

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 definitions of named patterns must be included from an external schema, which has to be prepared in a special way (see [Vli04], Chapter 11).

o 导入的分组和typedef的名称用导入模块的名称空间限定。另一方面,导入的分组中包含的数据节点的名称在导入模块中使用时,将成为导入模块命名空间的一部分。在RELAXNG中,模式的名称是非限定的,因此导入模块和导入模块中定义的命名模式共享相同的平面名称空间。RELAXNG命名模式的内容可以保留模式的名称空间,也可以继承导入模块的名称空间,类似于YANG。然而,为了实现后一种行为,命名模式的定义必须包含在外部模式中,外部模式必须以特殊的方式准备(参见[Vli04],第11章)。

In order to map, as much as possible, the modularity of YANG to RELAX NG, a validating RELAX NG schema (the result of the second mapping step) has to be split into two files, one of them containing all global definitions that are mapped from top-level YANG groupings appearing in all input YANG module. This RELAX NG schema MUST NOT define any namespace via the @ns attribute.

为了尽可能地将YANG的模块性映射到RELAX NG,验证RELAX NG模式(第二个映射步骤的结果)必须拆分为两个文件,其中一个文件包含从所有输入YANG模块中出现的顶级YANG分组映射的所有全局定义。此RELAX NG架构不能通过@ns属性定义任何命名空间。

The other RELAX NG schema file then defines actual data trees mapped from input YANG modules, each of them enclosed in an own embedded grammar. Those embedded grammars, in which at least one of the global definitions is used, MUST include the first schema with

然后,另一个RELAXNG模式文件定义从输入模块映射的实际数据树,每个模块都包含在自己的嵌入式语法中。这些嵌入语法中至少使用了一个全局定义,必须包含第一个带有

definitions and also MUST define the local namespace using the @ns attribute. This way, the global definitions can be used inside different embedded grammar, each time accepting a different local namespace.

定义,并且还必须使用@ns属性定义本地命名空间。这样,可以在不同的嵌入式语法中使用全局定义,每次都接受不同的本地名称空间。

Named pattern definitions that are mapped from non-top-level YANG groupings MUST be placed inside the embedded grammar corresponding to the YANG module where the grouping is defined.

从非顶级YANG分组映射的命名模式定义必须放在与定义分组的YANG模块对应的嵌入式语法中。

In the hybrid schema, we need to distinguish the global and non-global named pattern definitions while still keeping the hybrid schema in one file. This is accomplished in the following way:

在混合模式中,我们需要区分全局和非全局命名模式定义,同时仍将混合模式保留在一个文件中。这是通过以下方式实现的:

o Every global definition MUST be placed as a child of the outer <rng:grammar> element (the document root of the hybrid schema).

o 每个全局定义都必须作为外部<rng:grammar>元素(混合模式的文档根)的子元素放置。

o Every non-global definitions MUST be placed as a child of the corresponding embedded <rng:grammar> element.

o 每个非全局定义必须作为相应嵌入<rng:grammar>元素的子元素放置。

YANG also allows for splitting a module into a number of submodules. However, as submodules have no impact on the scope of identifiers and namespaces, the modularity based on submodules is not mapped in any way. The contents of submodules is therefore handled as if the submodule text appeared directly in the main module.

YANG还允许将模块拆分为多个子模块。但是,由于子模块对标识符和名称空间的范围没有影响,因此基于子模块的模块性不会以任何方式映射。因此,子模块的内容被处理为子模块文本直接出现在主模块中。

8.3. Granularity
8.3. 粒度

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.

RELAXNG支持不同样式的模式结构:一个极端(通常称为“俄罗斯玩偶”)在单个层次结构中指定XML实例文档的结构。另一个极端是扁平样式,它使用了与数据类型定义(DTD)模式语言类似的方法——每个XML元素对应一个命名模式定义。在实践中,通常会在两个极端之间选择一些折衷方案。

YANG supports both styles in principle, too, but in most cases the modules are organized in a way 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.

YANG原则上也支持这两种样式,但在大多数情况下,模块的组织方式更接近“俄罗斯玩偶”样式,从而更好地了解配置数据的结构。分组通常仅针对通过“uses”语句准备在多个位置重用的内容进行定义。相比之下,RELAXNG模式往往更平坦,因为RELAXNG中还需要更细的粒度以实现模式的可扩展性——只有替换或修改作为命名模式分解出来的模式片段才有可能。对于YANG来说,这不是一个问题,因为它的“augment”和“refine”语句可以通过使用路径表达式深入到现有结构的任意深度。

In general, it is not feasible to map YANG's powerful extension mechanisms to those available in RELAX NG. For this reason, the mapping essentially keeps the granularity of the original YANG data model: YANG groupings and definitions of derived types usually have direct counterparts in definitions of named patterns in the resulting RELAX NG schema.

一般来说,将杨的强大扩展机制映射到RELAXNG中可用的机制是不可行的。因此,映射本质上保持了原始YANG数据模型的粒度:YANG分组和派生类型的定义通常在结果RELAXNG模式中命名模式的定义中具有直接对应项。

8.4. Handling of XML Namespaces
8.4. XML名称空间的处理

Most modern XML schema languages, including RELAX NG, Schematron, and DSRL, support schemas for so-called compound XML documents that contain elements from multiple namespaces. This is useful for our purpose since the YANG-to-DSDL mapping allows for multiple input YANG modules, which naturally leads to compound document schemas.

大多数现代XML模式语言,包括RELAXNG、Schematron和DSRL,都支持包含多个名称空间元素的所谓复合XML文档的模式。这对于我们的目的很有用,因为YANG到DSDL映射允许多个输入YANG模块,这自然会导致复合文档模式。

RELAX NG offers two alternatives for defining the target namespaces in the schema:

RELAX NG为在架构中定义目标命名空间提供了两种选择:

1. First possibility is the traditional XML way via the @xmlns:xxx attribute.

1. 第一种可能是通过@xmlns:xxx属性使用传统的XML方式。

2. One of the target namespace URIs may be declared using the @ns attribute.

2. 可以使用@ns属性声明一个目标命名空间URI。

In both the hybrid schema and validation RELAX NG schemas generated in the second step, the namespaces MUST be declared as follows:

在第二步生成的混合模式和验证模式中,名称空间必须声明如下:

1. The root <rng:grammar> MUST have @xmlns:xxx attributes declaring prefixes of all namespaces that are used in the data model. The prefixes SHOULD be identical to those defined in the 'prefix' statements. An implementation of the mapping MUST resolve all collisions in the prefixes defined by different input modules, if there are any.

1. 根<rng:grammar>必须具有@xmlns:xxx属性,声明数据模型中使用的所有名称空间的前缀。前缀应与“prefix”语句中定义的前缀相同。映射的实现必须解决由不同输入模块定义的前缀中的所有冲突(如果有)。

2. Each embedded <rng:grammar> element MUST declare the namespace of the corresponding module using the @ns attribute. This way, the names of nodes defined by global named patterns are able to adopt the local namespace of each embedded grammar, as explained in Section 8.2.

2. 每个嵌入的<rng:grammar>元素必须使用@ns属性声明相应模块的名称空间。通过这种方式,由全局命名模式定义的节点名称能够采用每个嵌入式语法的本地名称空间,如第8.2节所述。

This setup is illustrated by the example at the end of Section 8.1.

第8.1节末尾的示例说明了该设置。

DSRL schemas may declare any number of target namespaces via the standard XML attributes xmlns:xxx.

DSRL模式可以通过标准XML属性xmlns:xxx声明任意数量的目标名称空间。

In contrast, Schematron requires all used namespaces to be defined in the <sch:ns> subelements of the document element <sch:schema>.

相反,Schematron要求在文档元素<sch:schema>的子元素<sch:ns>中定义所有使用的名称空间。

9. Mapping YANG Data Models to the Hybrid Schema
9. 将数据模型映射到混合模式

This section explains the main principles governing the first step of the mapping. Its result is the hybrid schema that is described in Section 8.1.

本节解释了管理映射第一步的主要原则。其结果是第8.1节中描述的混合模式。

A detailed specification of the mapping of individual YANG statements is contained in Section 10.

第10节详细说明了各个YANG语句的映射。

9.1. Occurrence Rules for Data Nodes
9.1. 数据节点的出现规则

In DSDL schema languages, occurrence constraints for a node are always localized together with that node. In a RELAX NG schema, for example, the <rng:optional> pattern appears as the parent element of the pattern defining a leaf or non-leaf element. Similarly, DSRL specifies default contents separately for every single node, be it a leaf or non-leaf element.

在DSDL模式语言中,节点的引用约束始终与该节点一起本地化。例如,在RELAXNG模式中,<rng:optional>模式显示为定义叶元素或非叶元素的模式的父元素。类似地,DSRL分别为每个节点指定默认内容,无论是叶元素还是非叶元素。

For leaf nodes in YANG modules, the occurrence constraints are also easily inferred from the substatements of 'leaf'. On the other hand, for a YANG container, it is often necessary to examine its entire subtree in order to determine the container's occurrence constraints.

对于YANG模块中的叶节点,也可以很容易地从“叶”的子状态推断出发生约束。另一方面,对于YANG容器,通常需要检查其整个子树以确定容器的发生约束。

Therefore, one of the goals of the first mapping step is to infer the occurrence constraints for all data nodes and mark, accordingly, the corresponding <rng:element> patterns in the hybrid schema so that any transformation procedure in the second mapping step can simply use this information and need not examine the subtree again.

因此,第一个映射步骤的目标之一是推断所有数据节点的发生约束,并相应地在混合模式中标记相应的<rng:element>模式,以便第二个映射步骤中的任何转换过程都可以简单地使用此信息,而无需再次检查子树。

First, it has to be decided whether a given data node must always be present in a valid configuration. If so, such a node is called mandatory, otherwise it is called optional. This constraint is closely related to the notion of mandatory nodes in Section 3.1 in [RFC6020]. The only difference is that this document also considers list keys to be mandatory.

首先,必须确定给定的数据节点是否必须始终存在于有效配置中。如果是,这样的节点称为强制节点,否则称为可选节点。该约束与[RFC6020]第3.1节中强制节点的概念密切相关。唯一的区别是,本文档还认为列表键是强制性的。

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. In this document, such elements are called implicit. In the hybrid schema, they can be identified as RELAX NG patterns having either the @nma:default or the @nma:implicit attribute.

另一个出现约束与“default”语句的语义以及删除空的不存在容器的可能性有关。因此,可以通过添加或删除某些叶元素或容器元素来修改有效配置的信息集,而不改变配置的含义。在本文档中,此类元素称为隐式元素。在混合模式中,可以将它们标识为具有@nma:default或@nma:implicit属性的RELAXNG模式。

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;
               }
           }
       }
        
       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).

这里,容器“outer”具有“presence”子状态,这意味着它是可选的,而不是隐式的。如果配置中不存在“外部”,则其子容器也不存在。然而,如果“outer”确实存在,那么询问它的子容器中哪些是可选的,哪些是隐式的是有意义的。在这种情况下,“c1”是可选的且是隐式的,“c2”是可选的但不是隐式的,“c3”是强制性的(因此不是隐式的)。

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 also for other types of YANG schema nodes, i.e., leaf, list, leaf-list, anyxml, and choice.

以下小节给出了确定容器是可选的还是强制性的以及它是隐式的精确规则。为了简化这些出现特征的递归定义,还可以为其他类型的模式节点(即叶、列表、叶列表、anyxml和choice)定义它们。

9.1.1. Optional and Mandatory Nodes
9.1.1. 可选和强制节点

The decision whether a given node is mandatory or optional is governed by the following rules:

给定节点是强制的还是可选的决定受以下规则管辖:

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 如果叶、anyxml和choice节点包含子状态“mandatory true;”,则它们是必需的。对于选择节点,这意味着必须至少存在一个案例分支中的一个节点。

o In addition, a leaf node is mandatory if it is declared as a list key.

o 此外,如果叶节点声明为列表键,则它是必需的。

o A list or leaf-list node is mandatory if it contains the 'min-elements' substatement with an argument value greater than zero.

o 如果列表或叶列表节点包含参数值大于零的“min elements”子状态,则该节点是必需的。

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.

o 如果容器节点的定义不包含“presence”子状态,并且至少有一个子节点是必需的,则容器节点是必需的。

A node that is not mandatory is said to be optional.

非强制的节点称为可选节点。

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 hybrid schema.

在RELAXNG中,可选节点的定义必须显式包装在<rng:optional>元素中。映射必须使用上述规则来确定YANG节点是否是可选的,如果是,则在混合模式中插入<rng:optional>元素。

However, alternatives in <rng:choice> MUST NOT be defined as optional in the hybrid schema. If a choice in YANG is not mandatory, <rng: optional> MUST be used to wrap the entire <rng:choice> pattern.

但是,<rng:choice>中的备选方案在混合模式中不能定义为可选的。如果杨中的选项不是强制性的,则必须使用<rng:optional>来包装整个<rng:choice>模式。

9.1.2. Implicit Nodes
9.1.2. 隐式节点

The following rules are used to determine whether a given data node is implicit:

以下规则用于确定给定数据节点是否为隐式:

o List, leaf-list, and anyxml nodes are never implicit.

o List、leaf List和anyxml节点从来都不是隐式的。

o A leaf node is implicit if and only if it has a default value, defined either directly or via its data type.

o 叶节点是隐式的,当且仅当其具有直接或通过其数据类型定义的默认值时。

o A container node is implicit if and only if it does not have the 'presence' substatement, none of its children are mandatory, and at least one child is implicit.

o 容器节点是隐式的当且仅当它没有“presence”子状态时,其子节点都不是必需的,并且至少有一个子节点是隐式的。

In the hybrid schema, all implicit containers, as well as leafs that obtain their default value from a typedef and don't have the @nma: default attribute, MUST be marked with @nma:implicit attribute having the value of "true".

在混合模式中,所有隐式容器以及从typedef获取默认值且不具有@nma:default属性的叶都必须标记为@nma:implicit属性,该属性的值为“true”。

Note that Section 7.9.3 in [RFC6020] specifies other rules that must be taken into account when deciding whether or not a given container or leaf appearing inside a case of a choice is ultimately implicit. Specifically, a leaf or container under a case can be implicit only

请注意,[RFC6020]中的第7.9.3节规定了在决定出现在选择案例中的给定容器或叶是否最终隐含时必须考虑的其他规则。具体来说,case下的叶或容器只能是隐式的

if the case appears in the argument of the choice's 'default' statement. However, this is not sufficient by itself but also depends on the particular instance XML document, namely on the presence or absence of nodes from other (non-default) cases. The details are explained in Section 11.3.

如果案例出现在选项的“default”语句的参数中。但是,这本身还不够,还取决于特定的实例XML文档,即是否存在其他(非默认)情况下的节点。详情见第11.3节。

9.2. Mapping YANG Groupings and Typedefs
9.2. 映射杨群和typedef

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.

YANG分组和TypeDef通常映射到RELAXNG命名模式。但是,映射必须考虑几个注意事项。

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 [RFC6020]. Second, top-level symbols from external modules may be 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:

首先,YANG TypeDef和分组可能出现在模块层次结构的所有级别,并受词汇范围的限制,请参见[RFC6020]中的第5.5节。其次,来自外部模块的顶级符号可以作为使用外部模块名称空间前缀和符号名称表示的限定名称导入。相反,RELAXNG中的命名模式(本地模式和通过<rng:include>模式导入的模式)共享相同的名称空间,并且在语法中它们始终是全局的——它们的定义可能仅作为<rng:grammar>元素的子元素出现在顶层。因此,每当YANG分组和TypeDef映射到RELAXNG命名模式定义时,必须消除它们的名称歧义,以避免命名冲突。映射使用以下过程来损坏分组名称和类型定义:

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 出现在模块层次结构顶层的分组和typedef的名称以模块名称和两个下划线字符(“u u”)作为前缀。

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 其他分组和typedef的名称(即不出现在模块顶层的分组和typedef)的前缀为模块名称双下划线,然后是所有祖先数据节点的名称,以双下划线分隔。

o Finally, since the names of groupings and typedefs in YANG have different namespaces, an additional underscore character is added to the beginning of the mangled names of all groupings.

o 最后,由于YANG中groupings和TypeDef的名称具有不同的名称空间,因此在所有分组的损坏名称的开头添加了一个额外的下划线字符。

   An additional complication is caused by the YANG rules for subelement
   ordering (see, e.g., Section 7.5.7 in [RFC6020]): in RPC input and
   output parameters, subelements must follow the order specified in the
   data model; otherwise, the order is arbitrary.  Consequently, if a
   grouping is used both in RPC input/output parameters and elsewhere,
   it MUST be mapped to two different named pattern definitions -- one
   with fixed order and the other with arbitrary order.  To distinguish
   them, the "__rpc" suffix MUST be appended to the version with fixed
   order.
        
   An additional complication is caused by the YANG rules for subelement
   ordering (see, e.g., Section 7.5.7 in [RFC6020]): in RPC input and
   output parameters, subelements must follow the order specified in the
   data model; otherwise, the order is arbitrary.  Consequently, if a
   grouping is used both in RPC input/output parameters and elsewhere,
   it MUST be mapped to two different named pattern definitions -- one
   with fixed order and the other with arbitrary order.  To distinguish
   them, the "__rpc" suffix MUST be appended to the version with fixed
   order.
        

EXAMPLE. Consider the following YANG module that imports the standard module "ietf-inet-types" [RFC6021]:

实例考虑下面的杨氏模块,导入标准模块“IETF IN类型”[RCF6021]:

   module example1 {
       namespace "http://example.com/ns/example1";
       prefix ex1;
       typedef vowels {
           type string {
               pattern "[aeiouy]*";
           }
       }
       grouping "grp1" {
           leaf "void" {
               type "empty";
           }
       }
       container "cont" {
           leaf foo {
               type vowels;
           }
           uses "grp1";
       }
   }
        
   module example1 {
       namespace "http://example.com/ns/example1";
       prefix ex1;
       typedef vowels {
           type string {
               pattern "[aeiouy]*";
           }
       }
       grouping "grp1" {
           leaf "void" {
               type "empty";
           }
       }
       container "cont" {
           leaf foo {
               type vowels;
           }
           uses "grp1";
       }
   }
        

The hybrid schema generated by the first mapping step will then contain the following two (global) named pattern definitions:

然后,由第一个映射步骤生成的混合模式将包含以下两个(全局)命名模式定义:

   <rng:define name="example1__vowels">
     <rng:data type="string">
       <rng:param name="pattern">[aeiouy]*</rng:param>
     </rng:data>
   </rng:define>
        
   <rng:define name="example1__vowels">
     <rng:data type="string">
       <rng:param name="pattern">[aeiouy]*</rng:param>
     </rng:data>
   </rng:define>
        
   <rng:define name="_example1__grp1">
     <rng:optional>
       <rng:element name="void">
         <rng:empty/>
       </rng:element>
     </rng:optional>
   </rng:define>
        
   <rng:define name="_example1__grp1">
     <rng:optional>
       <rng:element name="void">
         <rng:empty/>
       </rng:element>
     </rng:optional>
   </rng:define>
        
9.2.1. YANG Refinements and Augments
9.2.1. 杨精加

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 provides two substatements of 'uses', which modify expansions of groupings:

YANG分组代表了与RELAXNG中命名模式定义相似的概念,两种语言都提供了后续修改的机制。然而,在RELAX NG中,定义本身被修改,而YANG提供了两个“使用”子状态,用于修改分组的扩展:

o The 'refine' statement allows for changing parameters of a schema node inside the grouping referenced by the parent 'uses' statement;

o “refine”语句允许更改父“uses”语句引用的分组内架构节点的参数;

o The 'augment' statement can be used for adding new schema nodes to the grouping contents.

o “augment”语句可用于向分组内容添加新的架构节点。

Both 'refine' and 'augment' statements are quite powerful in that they can address, using XPath-like expressions as their arguments, schema nodes that are arbitrarily deep inside the grouping contents. In contrast, modifications of named pattern definitions in RELAX NG are applied exclusively at the topmost level of the named pattern contents. In order to achieve a modifiability of named patterns comparable to YANG, a RELAX NG schema would have to be extremely flat (cf. Section 8.3) and very difficult to read.

“refine”和“augment”语句都非常强大,因为它们可以使用类似XPath的表达式作为参数来处理任意深入分组内容的模式节点。相反,RELAXNG中命名模式定义的修改只应用于命名模式内容的最顶层。为了实现与YANG相似的命名模式的可修改性,RELAX NG模式必须非常平坦(参见第8.3节),并且非常难以阅读。

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 that has 'refine' and/or 'augment' substatements is replaced by the contents 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.

由于本文档中描述的映射的目标是生成特殊的DSDL模式,因此我们决定避免这些复杂情况,而是扩展分组并“就地”对其进行细化和/或扩充。换句话说,每个具有“refine”和/或“augment”子语句的“uses”语句都会被相应分组的内容替换,应用“refine”和“augment”语句中指定的更改,并映射生成的模式片段,就好像“uses”/“grouping”间接寻址不存在一样。

If there are further 'uses' statements inside the grouping contents, 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.

如果分组内容中还有其他“uses”语句,它们也可能需要扩展:如果包含的“uses”/“grouping”对位于“refine”或“augment”语句的参数中指定的“修改路径”上,则有必要进行扩展。

EXAMPLE. Consider the following YANG module:

实例考虑以下杨氏模块:

   module example2 {
       namespace "http://example.com/ns/example2";
       prefix ex2;
       grouping leaves {
           uses fr;
           uses es;
       }
       grouping fr {
           leaf feuille {
               type string;
           }
       }
       grouping es {
           leaf hoja {
               type string;
           }
       }
       uses leaves;
   }
        
   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 hybrid schema contains three global named pattern definitions corresponding to the three groupings, namely:

生成的混合模式包含三个与三个分组相对应的全局命名模式定义,即:

   <rng:define name="_example2__leaves">
     <rng:interleave>
       <rng:ref name="_example2__fr"/>
       <rng:ref name="_example2__es"/>
     </rng:interleave>
   </rng:define>
        
   <rng:define name="_example2__leaves">
     <rng:interleave>
       <rng:ref name="_example2__fr"/>
       <rng:ref name="_example2__es"/>
     </rng:interleave>
   </rng:define>
        
   <rng:define name="_example2__fr">
     <rng:optional>
       <rng:element name="feuille">
         <rng:data type="string"/>
       </rng:element>
     </rng:optional>
   </rng:define>
        
   <rng:define name="_example2__fr">
     <rng:optional>
       <rng:element name="feuille">
         <rng:data type="string"/>
       </rng:element>
     </rng:optional>
   </rng:define>
        
   <rng:define name="_example2__es">
     <rng:optional>
       <rng:element name="hoja">
         <rng:data type="string"/>
       </rng:element>
     </rng:optional>
   </rng:define>
        
   <rng:define name="_example2__es">
     <rng:optional>
       <rng:element name="hoja">
         <rng:data type="string"/>
       </rng:element>
     </rng:optional>
   </rng:define>
        

and the configuration data part of the hybrid schema is a single named pattern reference:

混合模式的配置数据部分是单个命名模式引用:

   <nma:data>
     <rng:ref name="_example2__leaves"/>
   </nma:data>
        
   <nma:data>
     <rng:ref name="_example2__leaves"/>
   </nma:data>
        

Now assume that the "uses leaves" statement contains a 'refine' substatement, for example:

现在假设“uses leaves”语句包含“refine”子语句,例如:

   uses leaves {
       refine "hoja" {
           default "alamo";
       }
   }
        
   uses leaves {
       refine "hoja" {
           default "alamo";
       }
   }
        
   The resulting hybrid 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 hybrid schema now looks like this:
        
   The resulting hybrid 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 hybrid schema now looks like this:
        
   <nma:data>
     <rng:interleave>
       <rng:ref name="_example2__fr"/>
       <rng:optional>
         <rng:element name="ex2:hoja" nma:default="alamo">
           <rng:data type="string"/>
         </rng:element>
       </rng:optional>
     </rng:interleave>
   </nma:data>
        
   <nma:data>
     <rng:interleave>
       <rng:ref name="_example2__fr"/>
       <rng:optional>
         <rng:element name="ex2:hoja" nma:default="alamo">
           <rng:data type="string"/>
         </rng:element>
       </rng:optional>
     </rng:interleave>
   </nma:data>
        
9.2.2. Type Derivation Chains
9.2.2. 类型派生链

RELAX NG has no equivalent of the type derivation mechanism in YANG that allows one to restrict a built-in type (perhaps in multiple steps) by adding new constraints. Whenever a derived YANG type is used without restrictions -- as a substatement of either 'leaf' or another 'typedef' -- then the 'type' statement is mapped simply to a named pattern reference <rng:ref>, and the type definition is mapped to a RELAX NG named pattern definition <rng:define>. However, if any 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 hybrid schema, restricted with facets that correspond to the combination of all restrictions found along the type derivation chain and also in the 'type' statement.

RELAXNG没有类似于YANG中类型派生机制的机制,它允许通过添加新约束来限制内置类型(可能是多个步骤)。无论何时,只要使用派生的YANG类型而没有任何限制(作为“leaf”或另一个“typedef”的子状态),那么“type”语句只映射到命名模式引用<rng:ref>,类型定义映射到RELAX NG命名模式定义<rng:define>。但是,如果将任何限制指定为“type”语句的子语句,则必须在该点扩展类型定义,以便在混合模式中仅显示祖先内置类型,使用与类型派生链以及“type”语句中的所有限制的组合相对应的方面进行限制。

EXAMPLE. Consider this YANG module:

实例考虑这个阳模块:

   module example3 {
       namespace "http://example.com/ns/example3";
       prefix ex3;
       typedef dozen {
           type uint8 {
               range 1..12;
           }
       }
       leaf month {
           type dozen;
       }
   }
        
   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" has no restrictions and is
   therefore mapped simply to the reference <rng:ref
   name="example3__dozen"/> and the corresponding named pattern is
   defined as follows:
        
   The 'type' statement in "leaf month" has no restrictions and is
   therefore 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</rng:param>
       <rng:param name="maxInclusive">12</rng:param>
     </rng:data>
   </rng:define>
        
   <rng:define name="example3__dozen">
     <rng:data type="unsignedByte">
       <rng:param name="minInclusive">1</rng:param>
       <rng:param name="maxInclusive">12</rng:param>
     </rng:data>
   </rng:define>
        

Assume now that the definition of leaf "month" is changed to:

现在假设叶“月”的定义更改为:

   leaf month {
       type dozen {
           range 7..max;
       }
   }
        
   leaf month {
       type dozen {
           range 7..max;
       }
   }
        

The output RELAX NG schema then will not contain any named pattern definition and the leaf "month" will be mapped directly to:

然后,输出RELAX NG模式将不包含任何命名模式定义,叶“月”将直接映射到:

   <rng:element name="ex3:month">
     <rng:data type="unsignedByte">
       <rng:param name="minInclusive">7</rng:param>
       <rng:param name="maxInclusive">12</rng:param>
     </rng:data>
   </rng:element>
        
   <rng:element name="ex3:month">
     <rng:data type="unsignedByte">
       <rng:param name="minInclusive">7</rng:param>
       <rng:param name="maxInclusive">12</rng: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'

由于类型定义中存在“default”语句,类型派生链的映射可能会进一步复杂化。在简单情况下,当包含“default”的类型定义

statement is used without restrictions, the 'default' statement is mapped to the @nma:default attribute attached to the <rng:define> element.

语句的使用没有限制,“default”语句映射到附加到<rng:define>元素的@nma:default属性。

However, if that type definition has to be expanded due to restrictions, the @nma:default attribute arising from the expanded type or ancestor types in the type derivation chain MUST be attached to the pattern 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.

但是,如果由于限制必须扩展该类型定义,则类型派生链中扩展的类型或祖先类型所产生的@nma:default属性必须附加到进行扩展的模式。如果在类型派生的连续步骤中有多个“default”语句,则只使用最接近扩展类型的“default”语句。

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;
       }
   }
        
   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:

此模块中的“typedef”语句映射到以下命名模式定义:

   <rng:define name="example3bis__dozen" @nma:default="7">
     <rng:data type="unsignedByte">
       <rng:param name="minInclusive">1</rng:param>
       <rng:param name="maxInclusive">12</rng:param>
     </rng:data>
   </rng:define>
        
   <rng:define name="example3bis__dozen" @nma:default="7">
     <rng:data type="unsignedByte">
       <rng:param name="minInclusive">1</rng:param>
       <rng:param name="maxInclusive">12</rng: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:

如果在叶“月”定义中使用“打”类型时受到限制,如前一示例中所示,“打”类型必须展开,@nma:default成为<ex3bis:month>元素定义的一个属性:

   <rng:element name="ex3bis:month" @nma:default="7">
     <rng:data type="unsignedByte">
       <rng:param name="minInclusive">7</rng:param>
       <rng:param name="maxInclusive">12</rng:param>
     </rng:data>
   </rng:element>
        
   <rng:element name="ex3bis:month" @nma:default="7">
     <rng:data type="unsignedByte">
       <rng:param name="minInclusive">7</rng:param>
       <rng:param name="maxInclusive">12</rng:param>
     </rng:data>
   </rng:element>
        

However, if the definition of the leaf "month" itself contained the 'default' substatement, the default specified for the "dozen" type would be ignored.

但是,如果叶“month”本身的定义包含“default”子语句,那么为“tide”类型指定的默认值将被忽略。

9.3. Translation of XPath Expressions
9.3. XPath表达式的翻译

YANG uses full XPath 1.0 syntax [XPath] for the arguments of 'must', 'when', and 'path' statements. As 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 in XPath expressions needn't carry a namespace prefix inside the module where they are defined and the local module's namespace is assumed.

YANG对'must'、'when'和'path'语句的参数使用完整的XPath 1.0语法[XPath]。由于在YANG模块中定义的数据节点的名称始终属于该YANG模块的名称空间,YANG采用了类似于XPath 2.0中默认名称空间概念的简化:XPath表达式中的节点名称不必在定义它们的模块内部带有名称空间前缀,并且假定本地模块的名称空间。

Consequently, all XPath expressions MUST be translated into a fully conformant XPath 1.0 expression: every unprefixed node name MUST be prepended with the local module's namespace prefix as declared by the 'prefix' statement.

因此,必须将所有XPath表达式转换为完全一致的XPath 1.0表达式:每个未固定的节点名称必须在“prefix”语句声明的本地模块名称空间前缀之前。

XPath expressions appearing inside top-level groupings require special attention because all unprefixed node names contained in them must adopt the namespace of each module where the grouping is used (cf. Section 8.2). In order to achieve this, the local prefix MUST be represented using the variable "$pref" in the hybrid schema. A Schematron schema which encounters such an XPath expression then supplies an appropriate value for this variable via a parameter to an abstract pattern to which the YANG grouping is mapped (see Section 11.2).

顶级分组中出现的XPath表达式需要特别注意,因为其中包含的所有未固定节点名称必须采用使用分组的每个模块的名称空间(参见第8.2节)。为了实现这一点,必须在混合模式中使用变量“$pref”表示本地前缀。遇到这样一个XPath表达式的Schematron模式然后通过一个参数为这个变量提供一个合适的值,该参数被映射到一个抽象模式(见第11.2节)。

For example, XPath expression "/dhcp/max-lease-time" appearing in a YANG module with the "dhcp" prefix will be translated to:

例如,带有“dhcp”前缀的模块中出现的XPath表达式“/dhcp/max lease time”将转换为:

   o  "$pref:dhcp/$pref:max-lease-time", if the expression is inside a
      top-level grouping;
        
   o  "$pref:dhcp/$pref:max-lease-time", if the expression is inside a
      top-level grouping;
        

o "dhcp:dhcp/dhcp:max-lease-time", otherwise.

o “dhcp:dhcp/dhcp:max租赁时间”,否则。

YANG also uses other XPath-like expressions, namely key identifiers and "descendant schema node identifiers" (see the ABNF production for and "descendant-schema-nodeid" in Section 12 of [RFC6020]). These expressions MUST be translated by adding local module prefixes as well.

YANG还使用其他类似XPath的表达式,即键标识符和“后代模式节点标识符”(参见[RFC6020]第12节中的ABNF产品和“后代模式节点标识符”)。必须通过添加本地模块前缀来翻译这些表达式。

9.4. YANG Language Extensions
9.4. 杨语言扩展

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 they can be used as the standard YANG statements, from which they are distinguished by 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 any place of a RELAX NG schema.

YANG允许通过添加带有特殊名称空间关键字的新语句来在线扩展自己的语言。这些扩展首先必须使用“extension”语句声明,然后可以将它们用作标准的YANG语句,通过限定extension关键字的名称空间前缀将它们与之区分开来。RELAXNG有一个类似的扩展机制——可以在RELAXNG模式的几乎任何位置插入具有外来名称空间名称的XML元素和属性。

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, see Section 11.1 in [RFC6020].

YANG语言扩展在DSDL模式的上下文中可能有意义,也可能没有意义。因此,实现可能会忽略任何或所有扩展。但是,未被忽略的扩展必须映射到与扩展形式完全匹配的XML元素和/或属性,请参见[RFC6020]中的第11.1节。

EXAMPLE. Consider the following extension defined by the "acme" module:

实例考虑由“ACME”模块定义的以下扩展:

   extension documentation-flag {
       argument number;
   }
        
   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;
   }
        
   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>
        
   <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.

请注意,“extension”语句本身没有以任何方式映射。

10. Mapping YANG Statements to the Hybrid Schema
10. 将YANG语句映射到混合模式

Each subsection in this section is devoted to one YANG statement and provides the specification of how the statement is mapped to the hybrid schema. The subsections are sorted alphabetically by the statement keyword.

本节中的每一小节都专门讨论一条YANG语句,并提供该语句如何映射到混合模式的规范。子部分按语句关键字的字母顺序排序。

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片段,通常是一个元素或属性,但也可能是一个更大的结构。映射过程本质上是递归的,这意味着在完成一条语句后,映射将继续进行其子语句(如果有),并且生成的片段的某个元素将成为子语句映射生成的其他片段的父级。明确指定对此默认递归过程的任何更改。

YANG XML encoding rules translate to the following rules for ordering multiple subelements:

XML编码规则转换为以下规则,用于对多个子元素进行排序:

1. Within the <nma:rpcs> subtree (i.e., for input and output parameters of an RPC operation) the order of subelements is fixed and their definitions in the hybrid schema MUST follow the order specified in the source YANG module.

1. 在<nma:rpcs>子树中(即,对于RPC操作的输入和输出参数),子元素的顺序是固定的,它们在混合模式中的定义必须遵循源模块中指定的顺序。

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 hybrid schema MUST be enclosed in the <rng:interleave> element.

2. 映射“list”语句时,所有键必须位于任何其他子元素之前,且顺序与在“key”语句中声明的顺序相同。未指定剩余(非键)子元素的顺序,因此它们在混合模式中的定义必须包含在<rng:interleave>元素中。

3. Otherwise, the order of subelements is arbitrary and, consequently, all definitions of subelements in the hybrid schema MUST be enclosed in the <rng:interleave> element.

3. 否则,子元素的顺序是任意的,因此,混合模式中所有子元素的定义都必须包含在<rng:interleave>元素中。

The following conventions are used in this section:

本节使用了以下约定:

o The argument of the statement being mapped is denoted by ARGUMENT.

o 被映射语句的参数由参数表示。

o The element in the RELAX NG schema that becomes the parent of the resulting XML fragment is denoted by PARENT.

o RELAXNG模式中成为结果XML片段父元素的元素由parent表示。

10.1. The 'anyxml' Statement
10.1. “anyxml”语句

This statement is mapped to the <rng:element> element and ARGUMENT with prepended local namespace prefix becomes the value of its @name attribute. The contents of <rng:element> are:

此语句被映射到<rng:element>元素,带有前置本地名称空间前缀的参数将成为其@name属性的值。<rng:element>的内容包括:

   <rng:ref name="__anyxml__"/>
        
   <rng:ref name="__anyxml__"/>
        

Substatements of the 'anyxml' statement, if any, MAY be mapped to additional children of the <rng:element> element.

“anyxml”语句的子语句(如果有)可以映射到<rng:element>元素的其他子级。

If at least one '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 root <rng:grammar> element (cf. [Vli04], p. 172):

如果在任何输入模块中至少出现一条“anyxml”语句,则以下模式定义必须作为根<rng:grammar>元素的子元素添加到RELAXNG模式中一次(参见[Vli04],第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>
        
   <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"

示例:名称空间前缀为“yam”的模块中的YANG语句

   anyxml data {
       description "Any XML content allowed here.";
   }
        
   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>
        
   <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).

如果没有“强制true;”子状态,则anyxml节点是可选的。然后必须将<rng:element>元素包装在<rng:optional>中,除非'anyxml'语句是'choice'语句的子语句,因此构成该选项的简写形式(有关详细信息,请参见第9.1.1节)。

10.2. The 'argument' Statement
10.2. “论点”陈述

This statement is not mapped to the output schema, but see the rules for handling extensions in Section 9.4.

此语句未映射到输出模式,但请参阅第9.4节中处理扩展的规则。

10.3. The 'augment' Statement
10.3. “增强”语句

As a substatement of 'uses', this statement is handled as a part of 'uses' mapping, see Section 10.57.

作为“uses”的子语句,此语句作为“uses”映射的一部分处理,请参见第10.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 augmented 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.

在模块或子模块的顶层,“augment”语句用于扩充另一个模块的模式树。如果未在同一映射会话中处理增强模块,则必须忽略顶级“augment”语句。否则,该语句的内容将添加到外部模块中,并使用出现“augment”语句的模块的名称空间。

10.4. The 'base' Statement
10.4. “基本”陈述

This statement is ignored as a substatement of 'identity' and handled within the 'identityref' type if it appears as a substatement of that type definition, see Section 10.53.6.

此语句作为“identity”的子语句被忽略,如果它作为该类型定义的子语句出现,则在“identityref”类型内处理,请参见第10.53.6节。

10.5. The 'belongs-to' Statement
10.5. “属于”语句

This statement is not used since the processing of submodules is always initiated from the main module, see Section 10.24.

由于子模块的处理总是从主模块开始,因此不使用此语句,请参见第10.24节。

10.6. The 'bit' Statement
10.6. “比特”声明

This statement is handled within the "bits" type, see Section 10.53.4.

该语句在“bits”类型内处理,见第10.53.4节。

10.7. The 'case' Statement
10.7. “案例”陈述

This statement is mapped to the <rng:group> or <rng:interleave> element, depending on whether or not the statement belongs to an definition of an RPC operation. If the argument of a sibling 'default' statement equals to ARGUMENT, the @nma:implicit attribute with the value of "true" MUST be added to that <rng:group> or <rng: interleave> element. The @nma:implicit attribute MUST NOT be used for nodes at the top-level of a non-default case (see Section 7.9.3 in [RFC6020]).

此语句映射到<rng:group>或<rng:interleave>元素,具体取决于该语句是否属于RPC操作的定义。如果同级“default”语句的参数等于参数,则必须将值为“true”的@nma:implicit属性添加到该<rng:group>或<rng:interleave>元素中。@nma:implicit属性不得用于非默认情况的顶层节点(请参阅[RFC6020]中的第7.9.3节)。

10.8. The 'choice' Statement
10.8. “选择”声明

This statement is mapped to the <rng:choice> element.

此语句映射到<rng:choice>元素。

   If 'choice' has the 'mandatory' substatement with the value of
   "true", the attribute @nma:mandatory MUST be added to the <rng:
   choice> element with the value of ARGUMENT.  This case may require
        
   If 'choice' has the 'mandatory' substatement with the value of
   "true", the attribute @nma:mandatory MUST be added to the <rng:
   choice> element with the value of ARGUMENT.  This case may require
        

additional handling, see Section 11.2.1. Otherwise, if "mandatory true;" is not present, the <rng:choice> element MUST be wrapped in <rng:optional>.

附加处理,见第11.2.1节。否则,如果“mandatory true;”不存在,则必须将<rng:choice>元素包装在<rng:optional>中。

The alternatives in <rng:choice> -- mapped from either the 'case' statement or a shorthand case -- MUST NOT be defined as optional.

<rng:choice>中的可选项(从“case”语句或简写大小写映射而来)不能定义为可选项。

10.9. The 'config' Statement
10.9. “config”语句

This statement is mapped to the @nma:config attribute, and ARGUMENT becomes its value.

此语句映射到@nma:config属性,参数成为其值。

10.10. The 'contact' Statement
10.10. “联系”声明

This statement SHOULD NOT be used by the mapping since the hybrid schema may be mapped from multiple YANG modules created by different authors. The hybrid schema contains references to all input modules in the Dublin Core elements <dc:source>, see Section 10.34. The original YANG modules are the authoritative sources of the authorship information.

映射不应使用此语句,因为混合模式可以从不同作者创建的多个模块映射。混合模式包含对都柏林核心元素<dc:source>中所有输入模块的引用,参见第10.34节。原始YANG模块是作者信息的权威来源。

10.11. The 'container' Statement
10.11. “容器”语句

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.

使用第9.1.1节中指定的规则,映射算法必须确定语句是否定义了可选容器,如果是,则插入<rng:optional>元素并使其成为新的父元素。

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.

然后,由该语句定义的容器映射到<rng:element>元素,该元素成为父元素的子元素,并使用带有前缀本地名称空间前缀的参数作为其@name属性的值。

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 of "true" to the <rng:element> element.

最后,使用第9.1.2节中指定的规则,映射算法必须确定容器是否是隐式的,如果是,则将值为“true”的属性@nma:implicit添加到<rng:element>元素中。

10.12. The 'default' Statement
10.12. “默认”语句

If this statement is a substatement of 'leaf', it is mapped to the @nma:default attribute of PARENT and ARGUMENT becomes its value.

如果此语句是“leaf”的子语句,它将映射到父级的@nma:default属性,参数将成为其值。

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:

作为“typedef”的子语句,“default”语句还映射到@nma:default属性,其值为ARGUMENT。此属性的位置取决于使用类型定义时是否必须展开类型定义:

o If the type definition is not expanded, @nma:default becomes an attribute of the <rng:define> pattern resulting from the parent 'typedef' mapping.

o 如果类型定义未展开,@nma:default将成为父“typedef”映射产生的<rng:define>模式的属性。

o Otherwise, @nma:default becomes an attribute of the ancestor RELAX NG pattern inside which the expansion takes place.

o 否则,@nma:default将成为进行扩展的祖先RELAXNG模式的属性。

Details and an example are given in Section 9.2.2.

第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 10.7. If the default case uses the shorthand notation where the 'case' statement is omitted, the @nma:implicit attribute with the value of "true" is either attached to the node representing the default case in the shorthand notation or, alternatively, an extra <rng:group> element MAY be inserted and the @nma:implicit attribute attached to it. In the latter case, the net result is the same as if the 'case' statement wasn't omitted for the default case.

最后,“default”语句作为“choice”的子语句,标识默认情况,并在“case”语句中处理,请参见第10.7节。如果默认情况使用省略“case”语句的速记符号,则值为“true”的@nma:implicit属性将附加到速记符号中表示默认情况的节点,或者,可以插入额外的<rng:group>元素并附加@nma:implicit属性。在后一种情况下,净结果与默认情况下没有省略“case”语句的结果相同。

EXAMPLE. The following 'choice' statement in a module with namespace prefix "yam"

实例命名空间前缀为“yam”的模块中的以下“choice”语句

   choice leaves {
       default feuille;
       leaf feuille { type empty; }
       leaf hoja { type empty; }
   }
        
   choice leaves {
       default feuille;
       leaf feuille { type empty; }
       leaf hoja { type empty; }
   }
        

is either mapped directly to:

直接映射到:

   <rng:choice>
     <rng:element name="yam:feuille" nma:implicit="true">
       <rng:empty/>
     </rng:element>
     <rng:element name="yam:hoja">
       <rng:empty/>
     </rng:element/>
   </rng:choice>
        
   <rng:choice>
     <rng:element name="yam:feuille" nma:implicit="true">
       <rng:empty/>
     </rng:element>
     <rng:element name="yam:hoja">
       <rng:empty/>
     </rng:element/>
   </rng:choice>
        

or the default case may be wrapped in an extra <rng:group>:

或者,默认的大小写可以包装在一个额外的<rng:group>中:

   <rng:choice>
     <rng:group nma:implicit="true">
       <rng:element name="yam:feuille">
         <rng:empty/>
       </rng:element>
     </rng:group>
     <rng:element name="yam:hoja">
       <rng:empty/>
     </rng:element/>
   </rng:choice>
        
   <rng:choice>
     <rng:group nma:implicit="true">
       <rng:element name="yam:feuille">
         <rng:empty/>
       </rng:element>
     </rng:group>
     <rng:element name="yam:hoja">
       <rng:empty/>
     </rng:element/>
   </rng:choice>
        
10.13. The 'description' Statement
10.13. “描述”语句

This statement is mapped to the DTD compatibility element <a:documentation> and ARGUMENT becomes its text.

此语句映射到DTD兼容性元素<a:documentation>,参数成为其文本。

In order to get properly formatted in the RELAX NG compact syntax, this element SHOULD be inserted as the first child of PARENT.

为了在RELAX NG compact语法中正确格式化,应该将此元素作为父元素的第一个子元素插入。

10.14. The 'deviation' Statement
10.14. “偏差”声明

This statement is ignored. However, it is assumed that all deviations are known beforehand and the corresponding changes have already been applied to the input YANG modules.

此语句被忽略。但是,假设所有偏差事先已知,且相应的变化已应用于输入模块。

10.15. The 'enum' Statement
10.15. “enum”语句

This statement is mapped to the <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.

此语句映射到<rng:value>元素,参数成为其文本。忽略除“status”之外的所有子状态,因为<rng:value>元素不能包含注释元素,请参见[rng],第6节。

10.16. The 'error-app-tag' Statement
10.16. “error-app-tag”语句

This statement is ignored unless it is a substatement of 'must'. In the latter case, it is mapped to the <nma:error-app-tag> element. See also Section 10.35.

除非该语句是“必须”的子语句,否则将忽略该语句。在后一种情况下,它被映射到<nma:error-app-tag>元素。另见第10.35节。

10.17. The 'error-message' Statement
10.17. “错误消息”语句

This statement is ignored unless it is a substatement of 'must'. In the latter case, it is mapped to the <nma:error-message> element. See also Section 10.35.

除非该语句是“必须”的子语句,否则将忽略该语句。在后一种情况下,它被映射到<nma:error message>元素。另见第10.35节。

10.18. The 'extension' Statement
10.18. “扩展”语句

This statement is ignored. However, extensions to the YANG language MAY be mapped as described in Section 9.4.

此语句被忽略。但是,YANG语言的扩展可以按照第9.4节所述进行映射。

10.19. The 'feature' Statement
10.19. “特色”声明

This statement is ignored.

此语句被忽略。

10.20. The 'grouping' Statement
10.20. “分组”语句

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.

此语句映射到RELAX NG命名的模式定义<rng:define>,但仅当此语句定义的分组在至少一个输入模块中未进行优化和扩充时使用。在这种情况下,命名模式定义成为<rng:grammar>元素的子元素,其名称根据第9.2节中指定的规则被参数损坏。

As explained in Section 8.2, a named pattern definition MUST be placed:

如第8.2节所述,必须放置命名模式定义:

o as a child of the root <rng:grammar> element if the corresponding grouping is defined at the top level of an input YANG module;

o 如果在输入模块的顶层定义了相应的分组,则作为根<rng:grammar>元素的子元素;

o otherwise as a child of the embedded <rng:grammar> element corresponding to the module in which the grouping is defined.

o 否则,作为与定义分组的模块相对应的嵌入式<rng:grammar>元素的子元素。

Whenever a grouping is used with refinements and/or augments, it is expanded so that the refinements and augments may be applied in place to the prescribed schema nodes. See Section 9.2.1 for further details and an example.

每当分组与细化和/或扩充一起使用时,都会对其进行扩展,以便细化和扩充可以适当地应用于指定的模式节点。更多详情和示例见第9.2.1节。

An implementation MAY offer the option of mapping all 'grouping' statements as named pattern definitions in the output RELAX NG schema even if they are not referenced. This is useful for mapping YANG "library" modules that typically contain only 'typedef' and/or 'grouping' statements.

实现可以提供将所有“分组”语句映射为输出RELAXNG模式中的命名模式定义的选项,即使它们没有被引用。这对于映射通常只包含“typedef”和/或“grouping”语句的“library”模块非常有用。

10.21. The 'identity' Statement
10.21. “身份”声明

This statement is mapped to the following named pattern definition which is placed as a child of the root <rng:grammar> element:

此语句映射到以下命名模式定义,该定义作为根<rng:grammar>元素的子元素放置:

   <rng:define name="__PREFIX_ARGUMENT">
     <rng:choice>
       <rng:value type="QName">PREFIX:ARGUMENT</rng:value>
       <rng:ref name="IDENTITY1"/>
       ...
     </rng:choice>
   </rng:define>
        
   <rng:define name="__PREFIX_ARGUMENT">
     <rng:choice>
       <rng:value type="QName">PREFIX:ARGUMENT</rng:value>
       <rng:ref name="IDENTITY1"/>
       ...
     </rng:choice>
   </rng:define>
        

where:

哪里:

PREFIX is the prefix used in the hybrid schema for the namespace of the module where the current identity is defined.

PREFIX是混合模式中用于定义当前标识的模块命名空间的前缀。

IDENTITY1 is the name of the named pattern corresponding to an identity that is derived from the current identity. Exactly one <rng:ref> element MUST be present for every such identity.

IDENTITY1是与从当前标识派生的标识相对应的命名模式的名称。对于每个这样的标识,必须正好有一个<rng:ref>元素。

EXAMPLE ([RFC6020], Section 7.16.3). Consider the following identities defined in two input YANG modules:

示例([RFC6020],第7.16.3节)。考虑在两个输入阳模块中定义的下列恒等式:

   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 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";
     }
   }
        
   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";
     }
   }
        

The identities will be mapped to the following named pattern definitions:

标识将映射到以下命名模式定义:

   <define name="__crypto_crypto-alg">
     <choice>
       <value type="QName">crypto:crypto-alg</value>
       <ref name="__des_des"/>
       <ref name="__des_des3"/>
     </choice>
   </define>
   <define name="__des_des">
     <value type="QName">des:des</value>
   </define>
   <define name="__des_des3">
     <value type="QName">des:des3</value>
   </define>
        
   <define name="__crypto_crypto-alg">
     <choice>
       <value type="QName">crypto:crypto-alg</value>
       <ref name="__des_des"/>
       <ref name="__des_des3"/>
     </choice>
   </define>
   <define name="__des_des">
     <value type="QName">des:des</value>
   </define>
   <define name="__des_des3">
     <value type="QName">des:des3</value>
   </define>
        
10.22. The 'if-feature' Statement
10.22. “if feature”语句

ARGUMENT together with arguments of all sibling 'if-feature' statements (with added prefixes, if missing) MUST be collected in a space-separated list that becomes the value of the @nma:if-feature attribute. This attribute is attached to PARENT.

参数以及所有同级“if-feature”语句(如果缺少前缀,则添加前缀)的参数必须收集在一个空格分隔的列表中,该列表将成为@nma:if-feature属性的值。此属性附加到父级。

10.23. The 'import' Statement
10.23. “进口”声明

This statement is not specifically mapped. The module whose name is in ARGUMENT has to be parsed so that the importing module is able to use its top-level groupings, typedefs and identities, and also augment the data tree of the imported module.

此语句没有专门映射。必须解析名称在参数中的模块,以便导入模块能够使用其顶级分组、typedef和标识,并扩充导入模块的数据树。

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.

如果“import”语句具有“revision”子语句,则必须使用导入模块的相应版本。查找给定模块版本的机制不在本文件范围内。

10.24. The 'include' Statement
10.24. “包括”声明

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 appeared directly in 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.

如果“include”语句包含“revision”子语句,则必须使用子模块的相应版本。查找给定子模块版本的机制不在本文件范围内。

10.25. The 'input' Statement
10.25. “输入”语句

This statement is handled within 'rpc' statement, see Section 10.50.

此语句在“rpc”语句中处理,请参见第10.50节。

10.26. The 'key' Statement
10.26. “关键”声明

This statement is mapped to @nma:key attribute. ARGUMENT 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.

此语句映射到@nma:key属性。必须转换参数,以便每个键都以本地模块的名称空间前缀作为前缀。然后,此转换的结果将成为@nma:key属性的值。

10.27. The 'leaf' Statement
10.27. “叶子”声明

This statement is mapped to the <rng:element> element and ARGUMENT with prepended local namespace prefix becomes the value of its @name attribute.

此语句被映射到<rng:element>元素,带有前置本地名称空间前缀的参数将成为其@name属性的值。

If the leaf is optional, i.e., if there is no "mandatory true;" substatement and the leaf is not declared among the keys of an enclosing list, then the <rng:element> element MUST be enclosed in <rng:optional>, except when the 'leaf' statement is a child of the 'choice' statement and thus represents a shorthand case for that choice (see Section 9.1.1 for details).

如果叶是可选的,即如果没有“mandatory true;”子状态,并且叶未在封闭列表的键中声明,则<rng:element>元素必须封闭在<rng:optional>中,除非“叶”语句是“choice”语句的子语句,因此表示该选择的简写形式(详见第9.1.1节)。

10.28. The 'leaf-list' Statement
10.28. “叶列表”语句

This statement is mapped to a block enclosed by either the <rng: zeroOrMore> or the <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:zeroOrMore>或<rng:oneOrMore>元素包围的块,具体取决于“min elements”子语句的参数分别是“0”还是正(默认为零)。此<rng:zeroOrMore>或<rng:oneOrMore>元素成为父元素。

<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. Another attribute, @nma:leaf-list, MUST also be added to this <rng:element> element with the value of "true". 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.

然后将<rng:element>添加为父元素的子元素,带有前置本地名称空间前缀的参数将成为其@name属性的值。另一个属性@nma:leaf list也必须以“true”的值添加到此<rng:element>元素。如果'leaf list'语句具有'min elements'子状态且其参数大于1,则附加属性@nma:min elements附加到<rng:element>,并且'min elements'的参数成为此属性的值。类似地,如果存在“max elements”子状态且其参数值不是“无界”,则属性@nma:max elements将附加到此元素,并且“max elements”的参数将成为此属性的值。

EXAMPLE. Consider the following 'leaf-list' appearing in a module with the namespace prefix "yam":

实例考虑在命名空间前缀“YAM”中出现的下面的“叶子列表”:

   leaf-list foliage {
       min-elements 3;
       max-elements 6378;
       ordered-by user;
       type string;
   }
        
   leaf-list foliage {
       min-elements 3;
       max-elements 6378;
       ordered-by user;
       type string;
   }
        

It is mapped to the following RELAX NG fragment:

它被映射到以下RELAX NG片段:

   <rng:oneOrMore>
     <rng:element name="yam:foliage" nma:leaf-list="true"
                  nma:ordered-by="user"
                  nma:min-elements="3" nma:max-elements="6378">
       <rng:data type="string"/>
     </rng:element>
   </rng:oneOrMore>
        
   <rng:oneOrMore>
     <rng:element name="yam:foliage" nma:leaf-list="true"
                  nma:ordered-by="user"
                  nma:min-elements="3" nma:max-elements="6378">
       <rng:data type="string"/>
     </rng:element>
   </rng:oneOrMore>
        
10.29. The 'length' Statement
10.29. “长度”声明

This statement is handled within the "string" type, see Section 10.53.10.

该语句在“字符串”类型内处理,见第10.53.10节。

10.30. The 'list' Statement
10.30. “列表”语句

This statement is mapped exactly as the 'leaf-list' statement, see Section 10.28. The only difference is that the @nma:leaf-list annotation either MUST NOT be present or MUST have the value of "false".

此语句与“叶列表”语句完全对应,请参见第10.28节。唯一的区别是@nma:leaf-list注释不能存在,或者必须具有“false”值。

When mapping the substatements of 'list', the order of children of the list element MUST be specified so that list keys, if there are any, always appear in the same order as they are defined in the 'key' substatement and before other children, see [RFC6020], Section 7.8.5. In particular, if a list key is defined in a grouping but the list node itself is not a part of 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.

映射“列表”的子状态时,必须指定列表元素的子级顺序,以便列表键(如果有)始终以与“键”子状态中定义的顺序相同的顺序出现在其他子级之前,请参见[RFC6020],第7.8.5节。特别是,如果在分组中定义了列表键,但列表节点本身不是同一分组的一部分,并且“uses”语句的位置将违反上述排序要求,则必须扩展分组,即用分组内容替换“uses”语句。

For example, consider the following YANG fragment of a module with the prefix "yam":

例如,考虑以下模块的阳片段,前缀“YAM”:

   grouping keygrp {
     leaf clef {
       type uint8;
     }
   }
   list foo {
     key clef;
     leaf bar {
       type string;
     }
     leaf baz {
       type string;
     }
     uses keygrp;
   }
        
   grouping keygrp {
     leaf clef {
       type uint8;
     }
   }
   list foo {
     key clef;
     leaf bar {
       type string;
     }
     leaf baz {
       type string;
     }
     uses keygrp;
   }
        

It is mapped to the following RELAX NG fragment:

它被映射到以下RELAX NG片段:

   <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>
        
   <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 definition of "yam:clef" is moved before the <rng:interleave> pattern.

注意,“keygrp”分组被扩展,“yam:clef”的定义被移动到<rng:interleave>模式之前。

10.31. The 'mandatory' Statement
10.31. “强制性”声明

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.

此语句可能显示为“leaf”、“choice”或“anyxml”语句的子语句。如果参数为“true”,则父数据节点映射为必填项,请参见第9.1.1节。

As a substatement of 'choice', this statement is also mapped to the @nma:mandatory attribute, which is added to PARENT. The value of this attribute is the argument of the parent 'choice' statement.

作为“choice”的子语句,该语句还映射到@nma:mandatory属性,该属性被添加到PARENT。此属性的值是父“choice”语句的参数。

10.32. The 'max-elements' Statement
10.32. “max elements”语句

This statement is handled within 'leaf-list' or 'list' statements, see Section 10.28.

该语句在“叶列表”或“列表”语句中处理,见第10.28节。

10.33. The 'min-elements' Statement
10.33. “最小元素”语句

This statement is handled within 'leaf-list' or 'list' statements, see Section 10.28.

该语句在“叶列表”或“列表”语句中处理,见第10.28节。

10.34. The 'module' Statement
10.34. “模块”语句

This statement is mapped to an embedded <rng:grammar> pattern having the @nma:module attribute with the value of ARGUMENT. In addition, a <dc:source> element SHOULD be created as a child of this <rng: grammar> element and contain ARGUMENT as a metadata reference to the input YANG module. See also Section 10.49.

此语句映射到一个嵌入的<rng:grammar>模式,该模式具有@nma:module属性,其值为ARGUMENT。此外,应创建一个<dc:source>元素作为该<rng:grammar>元素的子元素,并包含参数作为输入模块的元数据引用。另见第10.49节。

Substatements of the 'module' statement MUST be mapped so that:

必须映射“module”语句的子语句,以便:

o statements representing configuration/state data are mapped to descendants of the <nma:data> element;

o 表示配置/状态数据的语句映射到<nma:data>元素的后代;

o statements representing the contents of RPC requests or replies are mapped to descendants of the <nma:rpcs> element;

o 表示RPC请求或应答内容的语句映射到<nma:rpcs>元素的后代;

o statements representing the contents of event notifications are mapped to descendants of the <nma:notifications> element.

o 表示事件通知内容的语句映射到<nma:notifications>元素的后代。

10.35. The 'must' Statement
10.35. “必须”声明

This statement is mapped to the <nma:must> element. It has one mandatory attribute @assert (with no namespace) that contains ARGUMENT transformed into a valid XPath expression (see Section 9.3). The <nma:must> element may have other subelements resulting from mapping the 'error-app-tag' and 'error-message' substatements. Other substatements of 'must', i.e., 'description' and 'reference', are ignored.

此语句映射到<nma:must>元素。它有一个强制属性@assert(不带命名空间),其中包含转换为有效XPath表达式的参数(请参见第9.3节)。<nma:must>元素可能有其他子元素,这些子元素是由于映射了“error-app-tag”和“error-message”子语句而产生的。“必须”的其他子语句,即“说明”和“参考”被忽略。

EXAMPLE. YANG statement in the "dhcp" module

实例“dhcp”模块中的YANG语句

   must 'current() <= ../max-lease-time' {
       error-message
           "The default-lease-time must be less than max-lease-time";
   }
        
   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()&lt;=../dhcp:max-lease-time">
     <nma:error-message>
       The default-lease-time must be less than max-lease-time
     </nma:error-message>
   </nma:must>
        
   <nma:must assert="current()&lt;=../dhcp:max-lease-time">
     <nma:error-message>
       The default-lease-time must be less than max-lease-time
     </nma:error-message>
   </nma:must>
        
10.36. The 'namespace' Statement
10.36. “namespace”语句

This statement is mapped simultaneously in two ways:

此语句以两种方式同时映射:

1. to the @xmlns:PREFIX attribute of the root <rng:grammar> element where PREFIX is the namespace prefix specified by the sibling 'prefix' statement. ARGUMENT becomes the value of this attribute;

1. 指向根<rng:grammar>元素的@xmlns:PREFIX属性,其中PREFIX是同级“PREFIX”语句指定的命名空间前缀。参数成为该属性的值;

2. to the @ns attribute of PARENT, which is an embedded <rng: grammar> pattern. ARGUMENT becomes the value of this attribute.

2. 到父级的@ns属性,这是一个嵌入的<rng:grammar>模式。参数将成为此属性的值。

10.37. The 'notification' Statement
10.37. “通知”声明

This statement is mapped to the following subtree of the <nma: notifications> element in the hybrid schema (where PREFIX is the prefix of the local YANG module):

此语句映射到混合模式中<nma:notifications>元素的以下子树(其中PREFIX是本地模块的前缀):

   <nma:notification>
     <rng:element name="PREFIX:ARGUMENT">
       ...
     </rng:element>
   </nma:notification>
        
   <nma:notification>
     <rng:element name="PREFIX:ARGUMENT">
       ...
     </rng:element>
   </nma:notification>
        

Substatements of 'notification' are mapped under <rng:element name="PREFIX:ARGUMENT">.

“通知”的子状态映射在<rng:element name=“PREFIX:ARGUMENT”>下。

10.38. The 'ordered-by' Statement
10.38. “ordered by”语句

This statement is mapped to @nma:ordered-by attribute and ARGUMENT becomes the value of this attribute. See Section 10.28 for an example.

此语句映射到@nma:ordered by属性,参数成为此属性的值。有关示例,请参见第10.28节。

10.39. The 'organization' Statement
10.39. “组织”声明

This statement is ignored by the mapping because the hybrid schema may be mapped from multiple YANG modules authored by different parties. The hybrid schema SHOULD contain references to all input modules in the Dublin Core <dc:source> elements, see Section 10.34.

映射会忽略此语句,因为混合模式可以从由不同方编写的多个模块映射。混合模式应包含对都柏林核心<dc:source>元素中所有输入模块的引用,见第10.34节。

The original YANG modules are the authoritative sources of the authorship information.

原始YANG模块是作者信息的权威来源。

10.40. The 'output' Statement
10.40. “output”语句

This statement is handled within the 'rpc' statement, see Section 10.50.

此语句在“rpc”语句中处理,请参见第10.50节。

10.41. The 'path' Statement
10.41. “路径”语句

This statement is handled within the "leafref" type, see Section 10.53.8.

该语句在“leafref”类型中处理,见第10.53.8节。

10.42. The 'pattern' Statement
10.42. “模式”语句

This statement is handled within the "string" type, see Section 10.53.10.

该语句在“字符串”类型内处理,见第10.53.10节。

10.43. The 'position' Statement
10.43. “立场”声明

This statement is ignored.

此语句被忽略。

10.44. The 'prefix' Statement
10.44. “prefix”语句

This statement is handled within the sibling 'namespace' statement, see Section 10.36, or within the parent 'import' statement, see Section 10.23. As a substatement of 'belongs-to' (in submodules), the 'prefix' statement is ignored.

此语句在同级“namespace”语句中处理,请参见第10.36节,或在父“import”语句中处理,请参见第10.23节。作为“属于”(在子模块中)的子语句,“prefix”语句被忽略。

10.45. The 'presence' Statement
10.45. “在场”声明

This statement influences the mapping of the parent container (Section 10.11): the parent container definition MUST be wrapped in <rng:optional>, regardless of its contents. See also Section 9.1.1.

此语句影响父容器的映射(第10.11节):父容器定义必须包装在<rng:optional>中,无论其内容如何。另见第9.1.1节。

10.46. The 'range' Statement
10.46. “范围”声明

This statement is handled within numeric types, see Section 10.53.9.

该语句在数字类型中处理,见第10.53.9节。

10.47. The 'reference' Statement
10.47. “参考”声明

This statement is mapped to <a:documentation> element and its text is set to ARGUMENT prefixed with "See: ".

此语句映射到<a:documentation>元素,其文本设置为前缀为“See:”的参数。

10.48. The 'require-instance' Statement
10.48. “require instance”语句

This statement is handled within "instance-identifier" type (Section 10.53.7).

该语句在“实例标识符”类型中处理(第10.53.7节)。

10.49. The 'revision' Statement
10.49. “修订”声明

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 [RFC6020]. This date SHOULD be recorded, together with the name of the YANG module, in the corresponding Dublin Core <dc:source> element (see Section 10.34), for example in this form:

映射仅使用“revision”语句的最新实例,即参数中具有最新日期的实例,该实例指定输入模块[RFC6020]的当前版本。该日期应与YANG模块的名称一起记录在相应的都柏林核心<dc:source>元素中(参见第10.34节),例如,以以下形式:

   <dc:source>YANG module 'foo', revision 2010-03-02</dc:source>
        
   <dc:source>YANG module 'foo', revision 2010-03-02</dc:source>
        

The 'description' substatement of 'revision' is ignored.

“修订”的“说明”子项被忽略。

10.50. The 'rpc' Statement
10.50. “rpc”语句

This statement is mapped to the following subtree in the RELAX NG schema (where PREFIX is the prefix of the local YANG module):

此语句映射到RELAX NG模式中的以下子树(其中PREFIX是本地模块的前缀):

   <nma:rpc>
     <nma:input>
       <rng:element name="PREFIX:ARGUMENT">
         ... mapped contents of 'input' ...
       </rng:element>
     </nma:input>
     <nma:output">
       ... mapped contents of 'output' ...
     </nma:output>
   </nma:rpc>
        
   <nma:rpc>
     <nma:input>
       <rng:element name="PREFIX:ARGUMENT">
         ... mapped contents of 'input' ...
       </rng:element>
     </nma:input>
     <nma:output">
       ... mapped contents of 'output' ...
     </nma:output>
   </nma:rpc>
        

As indicated in the schema fragment, contents of the 'input' substatement (if any) are mapped under <rng:element name="PREFIX: ARGUMENT">. Similarly, contents of the 'output' substatement are mapped under <nma:output>. If there is no 'output' substatement, the <nma:output> element MUST NOT be present.

如模式片段所示,“输入”子状态(如果有)的内容映射在<rng:element name=“PREFIX:ARGUMENT”>下。类似地,“output”子语句的内容映射到<nma:output>下。如果没有“output”子语句,则<nma:output>元素不得存在。

The <nma:rpc> element is a child of <nma:rpcs>.

<nma:rpc>元素是<nma:rpcs>的子元素。

10.51. The 'status' Statement
10.51. “地位”声明

This statement MAY be ignored. Otherwise, it is mapped to @nma: status attribute and ARGUMENT becomes its value.

此语句可能被忽略。否则,它将映射到@nma:status属性,参数将成为其值。

10.52. The 'submodule' Statement
10.52. “submodule”语句

This statement is not specifically mapped. Its substatements are mapped as if they appeared directly in the module to which the submodule belongs.

此语句没有专门映射。它的子状态被映射,就好像它们直接出现在子模块所属的模块中一样。

10.53. The 'type' Statement
10.53. “type”语句

Most YANG built-in data types have an equivalent in the XSD data type library [XSD-D] as shown in Table 4.

大多数内置数据类型在XSD数据类型库[XSD-D]中都有一个等价项,如表4所示。

      +-----------+---------------+--------------------------------+
      | 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               |
      |           |               |                                |
      | binary    | base64Binary  | binary data in base64 encoding |
      +-----------+---------------+--------------------------------+
        
      +-----------+---------------+--------------------------------+
      | 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               |
      |           |               |                                |
      | binary    | base64Binary  | binary data in base64 encoding |
      +-----------+---------------+--------------------------------+
        

Table 4: YANG built-in data types with equivalents in the W3C XML Schema Type Library

表4:W3CXML模式类型库中的内置数据类型及其等价物

Two important data types of the XSD data type library -- "dateTime" and "anyURI" -- are not built-in types in YANG but instead are defined as derived types in the standard modules [RFC6021]: "date-and-time" in the "ietf-yang-types" module and "uri" in the "ietf-inet-types" module. However, the formal restrictions in the YANG type definitions are rather weak. Therefore, implementations of the YANG-to-DSDL mapping SHOULD detect these derived types in source YANG modules and map them to "dateType" and "anyURI", respectively.

XSD数据类型库的两个重要数据类型——“dateTime”和“anyURI”——不是YANG中的内置类型,而是在标准模块[RFC6021]中定义为派生类型:“ietf YANG types”模块中的“date and time”和“ietf inet types”模块中的“uri”。然而,杨类型定义中的形式限制相当薄弱。所以,YANG到DSDL映射的实现应该在源YANG模块中检测这些派生类型,并将它们分别映射到“dateType”和“anyURI”。

Details about the mapping of individual YANG built-in types are given in the following subsections.

以下小节提供了有关各个内置类型映射的详细信息。

10.53.1. The "empty" Type
10.53.1. “空”类型

This type is mapped to <rng:empty/>.

此类型映射到<rng:empty/>。

10.53.2. The "boolean" Type
10.53.2. “布尔”类型

This built-in type does not allow any restrictions and is mapped to the following XML fragment:

此内置类型不允许任何限制,并映射到以下XML片段:

   <rng:choice>
     <rng:value>true</rng:value>
     <rng:value>false</rng:value>
   </rng:choice>
        
   <rng:choice>
     <rng:value>true</rng:value>
     <rng:value>false</rng:value>
   </rng:choice>
        

Note that the XSD "boolean" type cannot be used here because it allows, unlike YANG, an alternative numeric representation of boolean values: 0 for "false" and 1 for "true".

请注意,这里不能使用XSD“boolean”类型,因为与YANG不同,它允许布尔值的替代数字表示:0表示“false”,1表示“true”。

10.53.3. The "binary" Type
10.53.3. “二进制”类型

This built-in type does not allow any restrictions and is mapped simply by inserting an <rng:data> element whose @type attribute value is set to "base64Binary" (see also Table 4).

该内置类型不允许任何限制,只需插入@type属性值设置为“base64Binary”的<rng:data>元素即可映射(另请参见表4)。

10.53.4. The "bits" Type
10.53.4. “比特”类型

This type is mapped to the <rng:list> and for each 'bit' substatement the following XML fragment is inserted as a child of <rng:list>:

此类型映射到<rng:list>,对于每个“bit”子状态,以下XML片段作为<rng:list>的子级插入:

   <rng:optional>
     <rng:value>bit_name</rng:value>
   </rng:optional>
        
   <rng:optional>
     <rng:value>bit_name</rng:value>
   </rng:optional>
        

where bit_name is the name of the bit as found in the argument of a 'bit' substatement.

其中,bit_name是在“bit”子状态的参数中找到的位的名称。

10.53.5. The "enumeration" and "union" Types
10.53.5. “枚举”和“并集”类型

These types are mapped to the <rng:choice> element.

这些类型映射到<rng:choice>元素。

10.53.6. The "identityref" Type
10.53.6. “identityref”类型

This type is mapped to the following named pattern reference:

此类型映射到以下命名模式引用:

   <rng:ref name="__PREFIX_BASE"/>
        
   <rng:ref name="__PREFIX_BASE"/>
        

where PREFIX:BASE is the qualified name of the identity appearing in the argument of the 'base' substatement.

其中PREFIX:BASE是“BASE”子语句的参数中出现的标识的限定名称。

For example, assume that module "des" in Section 10.21 contains the following leaf definition:

例如,假设第10.21节中的模块“des”包含以下叶定义:

   leaf foo {
     type identityref {
       base crypto:crypto-alg;
     }
   }
        
   leaf foo {
     type identityref {
       base crypto:crypto-alg;
     }
   }
        

This leaf would then be mapped to the following element pattern:

然后,此叶将映射到以下元素模式:

   <element name="des:foo">
     <ref name="__crypto_crypto-alg"/>
   </element>
        
   <element name="des:foo">
     <ref name="__crypto_crypto-alg"/>
   </element>
        
10.53.7. The "instance-identifier" Type
10.53.7. “实例标识符”类型

This type is mapped to <rng:data> element with @type attribute set to "string". In addition, an empty <nma:instance-identifier> element MUST be inserted as a child of PARENT.

此类型映射到@type属性设置为“string”的<rng:data>元素。此外,必须将空的<nma:instance identifier>元素作为父元素的子元素插入。

The argument of the 'require-instance' substatement, if it exists, becomes the value of the @require-instance attribute of the <nma: instance-identifier> element.

“require instance”子语句的参数(如果存在)将成为<nma:instance identifier>元素的@require instance属性的值。

10.53.8. The "leafref" Type
10.53.8. “leafref”类型

This type is mapped exactly as the type of the leaf given in the argument of 'path' substatement. However, if the type of the referred leaf defines a default value, this default value MUST be ignored by the mapping.

此类型的映射与“path”substation参数中给定的叶的类型完全相同。但是,如果引用叶的类型定义了默认值,则映射必须忽略此默认值。

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.

此外,必须将@nma:leafref属性添加到父级。根据第9.3节翻译的“path”子语句的参数设置为该属性的值。

10.53.9. The Numeric Types
10.53.9. 数字类型

YANG built-in numeric types are "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64", and "decimal64". They are mapped to the <rng:data> element with the @type attribute set to ARGUMENT translated according to Table 4 above.

内置的数字类型有“int8”、“int16”、“int32”、“int64”、“uint8”、“uint16”、“uint32”、“uint64”和“decimal64”。它们被映射到<rng:data>元素,@type属性被设置为参数,并根据上面的表4进行转换。

An exception is the "decimal64" type, which is mapped to the "decimal" type of the XSD data type library. Its precision and number of fractional digits are controlled with the following facets, which MUST always be present:

一个例外是“decimal64”类型,它映射到XSD数据类型库的“decimal”类型。其精度和小数位数由以下方面控制,这些方面必须始终存在:

o "totalDigits" facet set to the value of 19.

o “totalDigits”方面设置为19的值。

o "fractionDigits" facet set to the argument of the 'fraction-digits' substatement.

o “分数位数”方面设置为“分数位数”子状态的参数。

The fixed value of "totalDigits" corresponds to the maximum of 19 decimal digits for 64-bit integers.

“totalDigits”的固定值对应于64位整数的最大19位十进制数字。

For example, the statement:

例如,声明:

   type decimal64 {
       fraction-digits 2;
   }
        
   type decimal64 {
       fraction-digits 2;
   }
        

is mapped to the following RELAX NG data type:

映射到以下RELAX NG数据类型:

   <rng:data type="decimal">
     <rng:param name="totalDigits">19</rng:param>
     <rng:param name="fractionDigits">2</rng:param>
   </rng:data>
        
   <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 mapped as follows:

所有数字类型都支持“范围”限制,其映射如下:

If the range expression consists of just a single range LO..HI, then it is mapped to a pair of data type facets:

如果范围表达式仅由单个范围LO..HI组成,则它将映射到一对数据类型方面:

         <rng:param name="minInclusive">LO</rng:param>
        
         <rng:param name="minInclusive">LO</rng:param>
        

and

          <rng:param name="maxInclusive">HI</rng:param>
        
          <rng:param name="maxInclusive">HI</rng:param>
        

If the range consists of a single number, the values of both facets are set to this value. If LO is equal to the string "min", the "minInclusive" facet is omitted. If HI is equal to the string "max", the "maxInclusive" facet is omitted.

如果范围由单个数字组成,则两个面的值都设置为该值。如果LO等于字符串“min”,则省略“minInclusive”方面。如果HI等于字符串“max”,则忽略“maxInclusive”方面。

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 such <rng:data> elements are wrapped in <rng:choice> element. Each <rng:data> element contains the "minInclusive" and "maxInclusive" facets for one part of the range expression as described in the previous paragraph.

如果范围表达式有多个由“|”分隔的部分,则父级<rng:data>元素必须对每个范围部分重复一次,并且所有此类<rng:data>元素都包装在<rng:choice>元素中。如前一段所述,每个<rng:data>元素包含范围表达式一部分的“minInclusive”和“maxInclusive”面。

For the "decimal64" type, the "totalDigits" and "fractionDigits" must be repeated inside each of the <rng:data> elements.

对于“decimal64”类型,“totalDigits”和“fractionDigits”必须在每个<rng:data>元素内重复。

For example,

例如

   type int32 {
       range "-6378..0|42|100..max";
   }
        
   type int32 {
       range "-6378..0|42|100..max";
   }
        

is mapped to the following RELAX NG fragment:

映射到以下RELAX NG片段:

   <rng:choice>
     <rng:data type="int">
       <rng:param name="minInclusive">-6378</rng:param>
       <rng:param name="maxInclusive">0</rng:param>
     </rng:data>
     <rng:data type="int">
       <rng:param name="minInclusive">42</rng:param>
       <rng:param name="maxInclusive">42</rng:param>
     </rng:data>
     <rng:data type="int">
       <rng:param name="minInclusive">100</rng:param>
     </rng:data>
   </rng:choice>
        
   <rng:choice>
     <rng:data type="int">
       <rng:param name="minInclusive">-6378</rng:param>
       <rng:param name="maxInclusive">0</rng:param>
     </rng:data>
     <rng:data type="int">
       <rng:param name="minInclusive">42</rng:param>
       <rng:param name="maxInclusive">42</rng:param>
     </rng:data>
     <rng:data type="int">
       <rng:param name="minInclusive">100</rng:param>
     </rng:data>
   </rng:choice>
        

See Section 9.2.2 for further details on mapping the restrictions.

有关限制映射的更多详细信息,请参见第9.2.2节。

10.53.10. The "string" Type
10.53.10. “字符串”类型

This type is mapped to the <rng:data> element with the @type attribute set to "string".

此类型映射到@type属性设置为“string”的<rng:data>元素。

The 'length' restriction is handled analogically to the 'range' restriction for the numeric types (Section 10.53.9):

“长度”限制的处理方式与数字类型的“范围”限制类似(第10.53.9节):

If the length expression has just a single range:

如果长度表达式只有一个范围:

o and if the length range consists of a single number LENGTH, the following data type facet is inserted:

o 如果长度范围由单个数字长度组成,则插入以下数据类型方面:

<rng:param name="length">LENGTH</rng:param>.

<rng:param name=“length”>length</rng:param>。

o if the length range is of the form LO..HI, i.e., it consists of both the lower and upper bound. The following two data type facets are then inserted:

o 如果长度范围的形式为LO..HI,即它由下限和上限组成。然后插入以下两个数据类型方面:

         <rng:param name="minLength">LO</rng:param>
        
         <rng:param name="minLength">LO</rng:param>
        

and

         <rng:param name="maxLength">HI</rng:param>
        
         <rng:param name="maxLength">HI</rng:param>
        

If LO is equal to the string "min", the "minLength" facet is omitted. If HI is equal to the string "max", the "maxLength" facet is omitted.

如果LO等于字符串“min”,则忽略“minLength”方面。如果HI等于字符串“max”,则忽略“maxLength”方面。

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 such <rng:data> elements are wrapped in <rng:choice> element. Each <rng:data> element contains the "length" or "minLength" and "maxLength" facets for one part of the length expression as described in the previous paragraph.

如果长度表达式包含由“|”分隔的多个部分,则父级<rng:data>元素必须对每个范围部分重复一次,并且所有此类<rng:data>元素都包装在<rng:choice>元素中。如前一段所述,每个<rng:data>元素包含长度表达式一部分的“length”或“minLength”和“maxLength”面。

Every 'pattern' restriction of the "string" data type is mapped to the "pattern" facet:

“字符串”数据类型的每个“模式”限制都映射到“模式”方面:

   <rng:param name="pattern">...</rng:param>
        
   <rng:param name="pattern">...</rng:param>
        

with text 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.

文本等于“pattern”语句的参数。所有此类“图案”面必须在<rng:data>元素的每个副本内重复,即,每个长度范围重复一次。

For example,

例如

   type string {
       length "1|3..8";
       pattern "[A-Z][a-z]*";
   }
        
   type string {
       length "1|3..8";
       pattern "[A-Z][a-z]*";
   }
        

is mapped to the following RELAX NG fragment:

映射到以下RELAX NG片段:

   <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>
        
   <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>
        
10.53.11. Derived Types
10.53.11. 派生类型

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:

如果“type”语句引用派生类型,则根据它是否包含任何限制作为其子状态,以以下方式之一对其进行映射:

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 hybrid schema yet, the corresponding type definition MUST be found and its mapping installed as a subelement of either the root or an embedded <rng:grammar> element, see Section 10.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.

1. 没有限制,“type”语句只映射到<rng:ref>元素,即对命名模式的引用。如果此命名模式的RELAXNG定义尚未添加到混合模式中,则必须找到相应的类型定义,并将其映射安装为根元素或嵌入的<rng:grammar>元素的子元素,请参见第10.54节。即使给定的派生类型在输入模块中多次使用,相应的“typedef”映射也只能安装一次。

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 MUST be used. Restrictions appearing at all stages of the type derivation chain MUST be taken into account and their conjunction added to the <rng:data> element that defines the basic type.

2. 如果存在任何限制,则必须确定给定派生类型的祖先内置类型,并且必须使用此基类型的映射。必须考虑在类型派生链的所有阶段出现的限制,并将它们的连词添加到定义基本类型的<rng:data>元素中。

See Section 9.2.2 for more details and an example.

有关更多详细信息和示例,请参见第9.2.2节。

10.54. The 'typedef' Statement
10.54. “typedef”语句

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 either the root or an embedded <rng:grammar> element, depending on whether or not the 'typedef' statement appears at the top level of a YANG module. The name of this named pattern definition is set to ARGUMENT mangled according to the rules specified in Section 9.2.

此语句映射到RELAX NG命名模式定义<rng:define>,但仅当此语句定义的类型在至少一个输入模块中使用时没有限制。在这种情况下,命名模式定义成为根元素或嵌入的<rng:grammar>元素的子元素,具体取决于“typedef”语句是否出现在模块的顶层。根据第9.2节中指定的规则,将此命名模式定义的名称设置为参数mangled。

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 10.53.11 for further details and an example.

每当派生类型与其他限制一起使用时,派生类型的祖先内置类型将与限制(facet)一起使用,这些限制是沿类型派生链指定的所有限制的组合。更多详情和示例见第10.53.11节。

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.

实现可以提供将所有“typedef”语句记录为输出RELAX NG模式中的命名模式的选项,即使它们没有被引用。这对于映射仅包含“typedef”和/或“grouping”语句的“library”模块非常有用。

10.55. The 'unique' Statement
10.55. “独特”声明

This statement is mapped to the @nma:unique attribute. ARGUMENT MUST be 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.

此语句映射到@nma:unique属性。必须转换参数,以便其每个组件中的每个节点标识符都以本地模块的名称空间前缀作为前缀,除非该前缀已经存在。然后,此转换的结果将成为@nma:unique属性的值。

For example, assuming that the local module prefix is "ex",

例如,假设本地模块前缀为“ex”,

unique "foo ex:bar/baz"

独特的“foo ex:bar/baz”

is mapped to the following attribute/value pair:

映射到以下属性/值对:

   nma:unique="ex:foo ex:bar/ex:baz"
        
   nma:unique="ex:foo ex:bar/ex:baz"
        
10.56. The 'units' Statement
10.56. “单位”声明

This statement is mapped to the @nma:units attribute and ARGUMENT becomes its value.

此语句映射到@nma:units属性,参数成为其值。

10.57. The 'uses' Statement
10.57. “使用”声明

If this statement has neither 'refine' nor 'augment' substatements, it is mapped to the <rng:ref> element, i.e., a reference to a named pattern, and the value of its @name attribute is set to ARGUMENT mangled according to Section 9.2. If the RELAX NG definition of the referenced named pattern has not been added to the hybrid schema yet, the corresponding grouping MUST be found and its mapping installed as a subelement of <rng:grammar>, see Section 10.20.

如果此语句既没有“refine”子语句,也没有“augment”子语句,则它将映射到<rng:ref>元素,即对命名模式的引用,并且其@name属性的值将根据第9.2节设置为参数mangled。如果引用的命名模式的RELAX NG定义尚未添加到混合模式中,则必须找到相应的分组,并将其映射安装为<rng:grammar>的子元素,请参见第10.20节。

Otherwise, if the 'uses' statement has any 'refine' or 'augment' substatements, the corresponding grouping must be looked up and its contents inserted under PARENT. See Section 9.2.1 for further details and an example.

否则,如果“uses”语句有任何“refine”或“augment”子语句,则必须查找相应的分组,并将其内容插入父项下。更多详情和示例见第9.2.1节。

10.58. The 'value' Statement
10.58. “价值”陈述

This statement is ignored.

此语句被忽略。

10.59. The 'when' Statement
10.59. “何时”声明

This statement is mapped to the @nma:when attribute and ARGUMENT, translated according to Section 9.3, becomes it value.

该语句被映射到@nma:when属性和参数(根据第9.3节进行翻译)成为它的值。

10.60. The 'yang-version' Statement
10.60. "杨版"声明

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). In the case of a mismatch, the implementation SHOULD report an error and terminate.

此语句未映射到输出架构。但是,实现应该检查它是否与语句声明的YANG版本(当前版本1)兼容。在不匹配的情况下,实现应该报告错误并终止。

10.61. The 'yin-element' Statement
10.61. “阴元素”的说法

This statement is not mapped to the output schema, but see the rules for extension handling in Section 9.4.

此语句未映射到输出模式,但请参阅第9.4节中的扩展处理规则。

11. Mapping the Hybrid Schema to DSDL
11. 将混合模式映射到DSDL

As explained in Section 6, the second step of the YANG-to-DSDL mapping takes the hybrid schema and transforms it to various DSDL schemas capable of validating instance XML documents. As an input parameter, this step takes, in the simplest case, just a specification of the NETCONF XML document type that is to be validated. These document types can be, for example, the contents of a datastore, a reply to <nc:get> or <nc:get-config>, contents of other RPC requests/replies and event notifications, and so on.

如第6节所述,YANG到DSDL映射的第二步采用混合模式,并将其转换为能够验证实例XML文档的各种DSDL模式。作为一个输入参数,在最简单的情况下,该步骤只需要一个待验证的NETCONF XML文档类型的规范。例如,这些文档类型可以是数据存储的内容、对<nc:get>或<nc:get config>的回复、其他RPC请求/回复和事件通知的内容,等等。

The second mapping step has to accomplish the following three general tasks:

第二个映射步骤必须完成以下三个一般任务:

1. Extract the parts of the hybrid schema that are appropriate for the requested document type. For example, if a <nc:get> reply is to be validated, the subtree under <nma:data> has to be selected.

1. 提取混合模式中适合所请求文档类型的部分。例如,如果要验证<nc:get>回复,则必须选择<nma:data>下的子树。

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 <nc:get> reply or <en:notification> for a notification.

2. 模式必须适应RPC层要求的特定封装XML元素。例如,在回复或通知的情况下,这些元素是<nc:rpc>和<nc:data>元素。

3. Finally, NETMOD-specific annotations that are relevant for the schema language of the generated schema must be mapped to the corresponding patterns or rules.

3. 最后,与生成模式的模式语言相关的NETMOD特定注释必须映射到相应的模式或规则。

These three tasks are together much simpler than the first mapping step and can be effectively implemented using XSL transformations [XSLT].

这三个任务结合在一起比第一个映射步骤简单得多,并且可以使用XSL转换[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.

以下小节描述了各个DSDL模式语言的第二个映射步骤的详细信息。第12节包含所有NETMOD特定注释映射的详细规范。

11.1. Generating RELAX NG Schemas for Various Document Types
11.1. 为各种文档类型生成RELAXNG模式

With one minor exception, obtaining a validating RELAX NG schema from the hybrid schema only means taking appropriate parts of the hybrid schema and assembling them in a new RELAX NG grammar, perhaps after removing all unwanted annotations.

除了一个小的例外,从混合模式中获取验证RELAX NG模式只意味着获取混合模式的适当部分并将它们组装到新的RELAX NG语法中,可能是在删除所有不需要的注释之后。

The structure of the resulting RELAX NG schema is similar to that of the hybrid schema: the root grammar contains embedded grammars, one for each input YANG module. However, as explained in Section 8.2, global named pattern definitions (children of the root <rng:grammar> element) MUST be moved to a separate schema file.

生成的RELAXNG模式的结构与混合模式的结构类似:根语法包含嵌入式语法,每个输入模块对应一个语法。但是,如第8.2节所述,全局命名模式定义(根<rng:grammar>元素的子元素)必须移动到单独的模式文件中。

Depending on the XML document type that is the target for validation, such as <nc:get> or <nc:get-config> reply, RPC operations or notifications, patterns defining corresponding top-level information items MUST be added, such as <nc:rpc-reply> with the @message-id attribute and so on.

根据验证目标的XML文档类型,例如<nc:get>或<nc:get config>reply、RPC操作或通知,必须添加定义相应顶级信息项的模式,例如带有@message id属性的<nc:RPC reply>,等等。

In order to avoid copying common named pattern definitions for common NETCONF elements and attributes to every single output RELAX NG file, such schema-independent definitions SHOULD be collected in a library file that is then included by the validating RELAX NG schemas. Appendix B has the listing of such a library file.

为了避免将公共NETCONF元素和属性的公共命名模式定义复制到每个单独的输出RELAX NG文件中,应将此类独立于模式的定义收集到库文件中,然后由验证RELAX NG模式包含。附录B列出了此类库文件。

The minor exception mentioned above is the annotation @nma:config, which must be observed if the target document type is a reply to <nc: get-config>. In this case, each element definition that has this attribute with the value of "false" MUST be removed from the schema together with its descendants. See Section 12.1 for more details.

上面提到的次要例外是@nma:config注释,如果目标文档类型是对<nc:get-config>的回复,则必须遵守该注释。在这种情况下,必须将具有该属性且值为“false”的每个元素定义及其子体从模式中删除。详见第12.1节。

11.2. Mapping Semantic Constraints to Schematron
11.2. 将语义约束映射到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>.

与RELAXNG相比,Schematron模式更平坦、更统一。它们有四个层次的XML层次结构:<sch:schema>、<sch:pattern>、<sch:rule>和<sch:assert>或<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. The following NETMOD-specific annotations from the hybrid schema (henceforth called "semantic annotations") are mapped to corresponding Schematron rules: <nma:must>, @nma:key, @nma:unique, @nma:max-elements, @nma:min-elements, @nma:when, @nma:leafref, @nma: leaf-list, and also @nma:mandatory appearing as an attribute of <rng: choice> (see Section 11.2.1).

在第二个映射步骤生成的Schematron模式中,组织的基本单元是由<sch:rule>元素表示的规则。混合模式中的以下NETMOD特定注释(以下称为“语义注释”)映射到相应的Schematron规则:<nma:must>、@nma:key、@nma:unique、@nma:max-elements、@nma:min-elements、@nma:when、@nma:leafref、@nma:leaf-list,以及作为<rng:choice>(见第11.2.1节)。

Each input YANG module is mapped to a Schematron pattern whose @id attribute is set to the module name. Every <rng:element> pattern containing at least one of the above-mentioned semantic annotations is then mapped to a Schematron rule:

每个输入模块都映射到Schematron模式,其@id属性设置为模块名称。然后,包含至少一个上述语义注释的每个<rng:element>模式映射到Schematron规则:

   <sch:rule context="XELEM">
     ...
   </sch:rule>
        
   <sch:rule context="XELEM">
     ...
   </sch:rule>
        

The value of the mandatory @context attribute of <sch:rule> (denoted as XELEM) MUST be set to the absolute path of the context element in the data tree. The <sch:rule> element contains the mappings of all contained semantic annotations in the form of Schematron asserts or reports.

<sch:rule>的强制@context属性(表示为XELEM)的值必须设置为数据树中上下文元素的绝对路径。<sch:rule>元素以Schematron断言或报告的形式包含所有包含的语义注释的映射。

Semantic annotations appearing inside a named pattern definition (i.e., having <rng:define> among its ancestors) require special treatment because they may be potentially used in different contexts. This is accomplished by using Schematron abstract patterns that use the "$pref" variable in place of the local namespace prefix. The value of the @id attribute of such an abstract pattern MUST be set to the name of the named pattern definition that is being mapped (i.e., the mangled name of the original YANG grouping).

出现在命名模式定义中的语义注释(即,在其祖先中具有<rng:define>)需要特殊处理,因为它们可能在不同的上下文中使用。这是通过使用Schematron抽象模式实现的,该模式使用“$pref”变量代替本地名称空间前缀。此类抽象模式的@id属性的值必须设置为正在映射的命名模式定义的名称(即原始分组的损坏名称)。

When the abstract pattern is instantiated, the values of the following two parameters MUST be provided:

实例化抽象模式时,必须提供以下两个参数的值:

o pref: the actual namespace prefix,

o pref:实际的名称空间前缀,

o start: XPath expression defining the context in which the grouping is used.

o 开始:定义使用分组的上下文的XPath表达式。

EXAMPLE. Consider the following YANG module:

实例考虑以下杨氏模块:

   module example4 {
     namespace "http://example.com/ns/example4";
     prefix ex4;
     uses sorted-leaf-list;
     grouping sorted-leaf-list {
       leaf-list sorted-entry {
         must "not(preceding-sibling::sorted-entry > .)" {
           error-message "Entries must appear in ascending order.";
         }
         type uint8;
       }
     }
   }
        
   module example4 {
     namespace "http://example.com/ns/example4";
     prefix ex4;
     uses sorted-leaf-list;
     grouping sorted-leaf-list {
       leaf-list sorted-entry {
         must "not(preceding-sibling::sorted-entry > .)" {
           error-message "Entries must appear in ascending order.";
         }
         type uint8;
       }
     }
   }
        

The resulting Schematron schema for a reply to <nc:get> is then as follows:

回复<nc:get>的结果Schematron模式如下所示:

   <?xml version="1.0" encoding="utf-8"?>
   <sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron">
     <sch:ns uri="http://example.com/ns/example4" prefix="ex4"/>
     <sch:ns uri="urn:ietf:params:xml:ns:netconf:base:1.0"
             prefix="nc"/>
     <sch:pattern abstract="true"
                  id="_example4__sorted-leaf-list">
       <sch:rule context="$start/$pref:sorted-entry">
         <sch:report
             test=". = preceding-sibling::$pref:sorted-entry">
           Duplicate leaf-list entry "<sch:value-of select="."/>".
         </sch:report>
         <sch:assert
             test="not(preceding-sibling::$pref:sorted-entry &gt; .)">
           Entries must appear in ascending order.
         </sch:assert>
       </sch:rule>
     </sch:pattern>
     <sch:pattern id="example4"/>
     <sch:pattern id="id2573371" is-a="_example4__sorted-leaf-list">
       <sch:param name="start" value="/nc:rpc-reply/nc:data"/>
       <sch:param name="pref" value="ex4"/>
     </sch:pattern>
   </sch:schema>
        
   <?xml version="1.0" encoding="utf-8"?>
   <sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron">
     <sch:ns uri="http://example.com/ns/example4" prefix="ex4"/>
     <sch:ns uri="urn:ietf:params:xml:ns:netconf:base:1.0"
             prefix="nc"/>
     <sch:pattern abstract="true"
                  id="_example4__sorted-leaf-list">
       <sch:rule context="$start/$pref:sorted-entry">
         <sch:report
             test=". = preceding-sibling::$pref:sorted-entry">
           Duplicate leaf-list entry "<sch:value-of select="."/>".
         </sch:report>
         <sch:assert
             test="not(preceding-sibling::$pref:sorted-entry &gt; .)">
           Entries must appear in ascending order.
         </sch:assert>
       </sch:rule>
     </sch:pattern>
     <sch:pattern id="example4"/>
     <sch:pattern id="id2573371" is-a="_example4__sorted-leaf-list">
       <sch:param name="start" value="/nc:rpc-reply/nc:data"/>
       <sch:param name="pref" value="ex4"/>
     </sch:pattern>
   </sch:schema>
        
   The "sorted-leaf-list" grouping from the input module is mapped to an
   abstract pattern with an @id value of "_example4__sorted-leaf-list"
   in which the 'must' statement corresponds to the <sch:assert>
   element.  The abstract pattern is the instantiated by the pattern
   with an @id value of "id2573371", which sets the "start" and "pref"
   parameters to appropriate values.
        
   The "sorted-leaf-list" grouping from the input module is mapped to an
   abstract pattern with an @id value of "_example4__sorted-leaf-list"
   in which the 'must' statement corresponds to the <sch:assert>
   element.  The abstract pattern is the instantiated by the pattern
   with an @id value of "id2573371", which sets the "start" and "pref"
   parameters to appropriate values.
        

Note that another Schematron element, <sch:report>, was automatically added, checking for duplicate leaf-list entries.

请注意,另一个Schematron元素<sch:report>已自动添加,用于检查重复的叶列表条目。

The mapping from the hybrid schema to Schematron proceeds in the following steps:

从混合模式到Schematron的映射按以下步骤进行:

1. First, the active subtree(s) of the hybrid 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 <nc:get-config> reply.

1. 首先,必须根据请求的目标文档类型选择混合模式的活动子树。此过程与RELAX NG案例相同,包括在目标文档类型为<nc:get config>reply时处理@nma:config。

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:

2. 必须使用<sch:ns>元素声明所有输入模块的名称空间,以及基本NETCONF(“nc”前缀)或通知(“en”前缀)的名称空间,例如:

   <sch:ns uri="http://example.com/ns/example4" prefix="ex4"/>
        
   <sch:ns uri="http://example.com/ns/example4" prefix="ex4"/>
        

3. One pattern is created for every input module. In addition, an abstract pattern is created for every named pattern definition containing one or more semantic annotations.

3. 为每个输入模块创建一个模式。此外,将为包含一个或多个语义注释的每个命名模式定义创建一个抽象模式。

4. A <sch:rule> element is created for each element pattern containing semantic annotations.

4. 为包含语义注释的每个元素模式创建一个<sch:rule>元素。

5. Every such annotation is then mapped to an <sch:assert> or <sch: report> element, which is installed as a child of the <sch:rule> element.

5. 然后将每个这样的注释映射到<sch:assert>或<sch:report>元素,该元素作为<sch:rule>元素的子元素安装。

11.2.1. Constraints on Mandatory Choice
11.2.1. 强制性选择的限制

In order to fully represent the semantics of YANG's 'choice' statement with the "mandatory true;" substatement, the RELAX NG grammar has to be combined with a special Schematron rule.

为了用“强制true;”子状态充分表示杨的“choice”语句的语义,RELAX NG语法必须与特殊的Schematron规则相结合。

EXAMPLE. Consider the following module:

实例考虑以下模块:

   module example5 {
       namespace "http://example.com/ns/example5";
       prefix ex5;
       choice foobar {
           mandatory true;
           case foo {
               leaf foo1 {
                   type uint8;
               }
               leaf foo2 {
                   type uint8;
               }
           }
           leaf bar {
               type uint8;
           }
       }
   }
        
   module example5 {
       namespace "http://example.com/ns/example5";
       prefix ex5;
       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' statement from this module is mapped to the following fragment of the RELAX NG schema:

在这个模块中,两个case分支中的所有三个叶节点都是可选的,但是由于“mandatory true;”语句,它们中至少有一个必须存在于有效的配置中。此模块中的“choice”语句映射到RELAX NG架构的以下片段:

   <rng:choice>
     <rng:interleave>
       <rng:optional>
         <rng:element name="ex5:foo1">
           <rng:data type="unsignedByte"/>
         </rng:element>
       </rng:optional>
       <rng:optional>
         <rng:element name="ex5:foo2">
           <rng:data type="unsignedByte"/>
         </rng:element>
       </rng:optional>
     </rng:interleave>
     <rng:element name="ex5:bar">
       <rng:data type="unsignedByte"/>
     </rng:element>
   </rng:choice>
        
   <rng:choice>
     <rng:interleave>
       <rng:optional>
         <rng:element name="ex5:foo1">
           <rng:data type="unsignedByte"/>
         </rng:element>
       </rng:optional>
       <rng:optional>
         <rng:element name="ex5:foo2">
           <rng:data type="unsignedByte"/>
         </rng:element>
       </rng:optional>
     </rng:interleave>
     <rng:element name="ex5:bar">
       <rng:data type="unsignedByte"/>
     </rng:element>
   </rng:choice>
        

In the second case branch, the "ex5: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 are present.

在第二个分支中,“ex5:bar”元素被定义为必需元素,因此如果选择了该分支,则该元素必须存在于有效配置中。但是,第一个分支“foo”中的两个元素不能同时声明为强制元素,因为它们中的每一个元素都足以进行有效配置。因此,上述RELAXNG片段将成功验证三个叶元素都不存在的配置。

Therefore, mandatory choices, which can be recognized in the hybrid schema as <rng:choice> elements with the @nma:mandatory annotation, 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 Schematron rule MUST be added 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.).

因此,在混合模式中可以识别为带有@nma:mandatory注释的<rng:choice>元素的强制选择必须以特殊方式处理:对于每个强制选择,其中至少一个案例包含多个节点,必须添加一个Schematron规则,强制任何情况下至少存在一个元素。(RELAXNG模式保证不同情况下的元素不能混合在一起,所有必需的节点都存在,等等)。

For the example module above, the Schematron rule will be as follows:

对于上面的示例模块,Schematron规则如下:

   <sch:rule context="/nc:rpc-reply/nc:data">
     <sch:assert test="ex5:foo1 or ex5:foo2 or ex5:bar">
       Node(s) from at least one case of choice "foobar" must exist.
     </sch:assert>
   </sch:rule>
        
   <sch:rule context="/nc:rpc-reply/nc:data">
     <sch:assert test="ex5:foo1 or ex5:foo2 or ex5:bar">
       Node(s) from at least one case of choice "foobar" must exist.
     </sch:assert>
   </sch:rule>
        
11.3. Mapping Default Values to DSRL
11.3. 将默认值映射到DSRL

DSRL is the only component of DSDL that is allowed to change the information set of the validated XML document. While DSRL also has other functions, YANG-to-DSDL mapping uses it only for specifying and applying default contents. For XML instance documents based on YANG data models, insertion of default contents may potentially take place for all implicit nodes identified by the rules in Section 9.1.2.

DSRL是DSDL中唯一允许更改已验证XML文档的信息集的组件。虽然DSRL还有其他功能,但YANG-to-DSDL映射仅将其用于指定和应用默认内容。对于基于数据模型的XML实例文档,可能会为第9.1.2节中规则标识的所有隐式节点插入默认内容。

In DSRL, the default contents of an element are 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 the application of the default contents, see [DSRL]:

在DSRL中,使用<DSRL:default content>元素指定元素的默认内容,该元素是<DSRL:element map>的子元素。<dsrl:default content>的两个同级元素确定应用默认内容的上下文,请参见[dsrl]:

o the <dsrl:parent> element contains an XSLT pattern specifying the parent element; the default contents are applied only if the parent element exists in the instance document;

o <dsrl:parent>元素包含指定父元素的XSLT模式;仅当实例文档中存在父元素时,才会应用默认内容;

o the <dsrl:name> contains the XML name of the element that, if missing or empty, is inserted together with the contents of <dsrl: default-content>.

o <dsrl:name>包含元素的XML名称,如果缺少或为空,则该元素将与<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 a proper application of default contents.

在一般dsrl模式中,<dsrl:parent>元素是可选的,但为了实现从YANG到DSDL的映射,必须始终存在该元素,以确保正确应用默认内容。

DSRL mapping only deals with <rng:element> patterns in the hybrid schema that define implicit nodes (see Section 9.1.2). Such element patterns are distinguished by having NETMOD-specific annotation attributes @nma:default or @nma:implicit, i.e., either:

DSRL映射只处理混合模式中定义隐式节点的<rng:element>模式(参见第9.1.2节)。此类元素模式的区别在于具有NETMOD特定的注释属性@nma:default或@nma:implicit,即:

   <rng:element name="ELEM" nma:default="DEFVALUE">
     ...
   </rng:element>
        
   <rng:element name="ELEM" nma:default="DEFVALUE">
     ...
   </rng:element>
        

or

   <rng:element name="ELEM" nma:implicit="true">
     ...
   </rng:element>
        
   <rng:element name="ELEM" nma:implicit="true">
     ...
   </rng:element>
        

The former case applies to leaf nodes having the 'default' substatement, but also to leaf nodes that obtain their default value from a typedef, if this typedef is expanded according to the rules in Section 9.2.2 so that the @nma:default annotation is attached directly to the leaf's element pattern.

前一种情况适用于具有“default”子状态的叶节点,但也适用于从typedef获取默认值的叶节点,前提是根据第9.2.2节中的规则展开该typedef,以便@nma:default注释直接附加到叶的元素模式。

The latter case is used for all implicit containers (see Section 9.1) and for leafs that obtain the default value from a typedef and don't have the @nma:default annotation.

后一种情况用于所有隐式容器(见第9.1节)和从typedef获取默认值且没有@nma:default注释的leaf。

In the simplest case, both element patterns are mapped to the following DSRL element map:

在最简单的情况下,两种元素模式都映射到以下DSRL元素映射:

   <dsrl:element-map>
     <dsrl:parent>XPARENT</dsrl:parent>
     <dsrl:name>ELEM</dsrl:name>
     <dsrl:default-content>DEFCONT</dsrl:default-content>
   </dsrl:element-map>
        
   <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:

其中XPARENT是数据树中ELEM的父元素的绝对XPath,DEFCONT的构造如下:

o If the implicit node ELEM is a leaf and has the @nma:default attribute, DEFCONT is set to the value of this attribute (denoted above as DEFVALUE).

o 如果隐式节点ELEM是一个叶,并且具有@nma:default属性,那么DEFCONT将设置为该属性的值(上面表示为DEFVALUE)。

o If the implicit node ELEM is a leaf and has the @nma:implicit attribute with the value of "true", the default value has to be determined from the @nma:default attribute of the definition of ELEM's type (perhaps recursively) and used in place of DEFCONT in the above DSRL element map. See also Section 9.2.2.

o 如果隐式节点ELEM是一个叶,并且具有值为“true”的@nma:implicit属性,则必须根据ELEM类型定义的@nma:default属性确定默认值(可能是递归的),并在上述DSRL元素映射中替代DEFCONT使用。另见第9.2.2节。

o Otherwise, the implicit node ELEM is a container and DEFCONT is constructed as an XML fragment containing all descendant elements of ELEM that have either the @nma:implicit or the @nma:default attribute.

o 否则,隐式节点ELEM是一个容器,DEFCONT被构造为一个XML片段,包含ELEM的所有子元素,这些子元素具有@nma:implicit或@nma:default属性。

In addition, when mapping the default case of a choice, it has to be guaranteed that the default contents are not applied if any node from any non-default case is present. This is accomplished by setting <dsrl:parent> in a special way:

此外,在映射选项的默认情况时,必须确保如果存在任何非默认情况下的节点,则不会应用默认内容。这是通过以特殊方式设置<dsrl:parent>来实现的:

   <dsrl:parent>XPARENT[not (ELEM1|ELEM2|...|ELEMn)]</dsrl:parent>
        
   <dsrl:parent>XPARENT[not (ELEM1|ELEM2|...|ELEMn)]</dsrl:parent>
        

where ELEM1, ELEM2, ... ELEMn are the names of all top-level nodes from all non-default cases. The rest of the element map is exactly as before.

其中ELEM1,ELEM2。。。ELEMn是所有非默认情况下的所有顶级节点的名称。元素映射的其余部分与之前完全相同。

EXAMPLE. Consider the following YANG module:

实例考虑以下杨氏模块:

   module example6 {
     namespace "http://example.com/ns/example6";
     prefix ex6;
     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;
         }
       }
     }
   }
        
   module example6 {
     namespace "http://example.com/ns/example6";
     prefix ex6;
     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:

为“get reply”目标文档类型生成的DSRL架构为:

   <?xml version="1.0" encoding="utf-8"?>
   <dsrl:maps xmlns:dsrl="http://purl.oclc.org/dsdl/dsrl"
              xmlns:ex6="http://example.com/ns/example6"
              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>ex6:outer</dsrl:name>
       <dsrl:default-content>
         <ex6:leaf1>1</ex6:leaf1>
         <ex6:one>
           <ex6:leaf2>2</ex6:leaf2>
         </ex6:one>
       </dsrl:default-content>
     </dsrl:element-map>
     <dsrl:element-map>
       <dsrl:parent>/nc:rpc-reply/nc:data/ex6:outer</dsrl:parent>
       <dsrl:name>ex6:leaf1</dsrl:name>
       <dsrl:default-content>1</dsrl:default-content>
     </dsrl:element-map>
     <dsrl:element-map>
       <dsrl:parent>
         /nc:rpc-reply/nc:data/ex6:outer[not(ex6:leaf3)]
       </dsrl:parent>
       <dsrl:name>ex6:one</dsrl:name>
       <dsrl:default-content>
         <ex6:leaf2>2</ex6:leaf2>
       </dsrl:default-content>
     </dsrl:element-map>
     <dsrl:element-map>
       <dsrl:parent>
         /nc:rpc-reply/nc:data/ex6:outer/ex6:one
       </dsrl:parent>
       <dsrl:name>ex6:leaf2</dsrl:name>
       <dsrl:default-content>2</dsrl:default-content>
     </dsrl:element-map>
   </dsrl:maps>
        
   <?xml version="1.0" encoding="utf-8"?>
   <dsrl:maps xmlns:dsrl="http://purl.oclc.org/dsdl/dsrl"
              xmlns:ex6="http://example.com/ns/example6"
              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>ex6:outer</dsrl:name>
       <dsrl:default-content>
         <ex6:leaf1>1</ex6:leaf1>
         <ex6:one>
           <ex6:leaf2>2</ex6:leaf2>
         </ex6:one>
       </dsrl:default-content>
     </dsrl:element-map>
     <dsrl:element-map>
       <dsrl:parent>/nc:rpc-reply/nc:data/ex6:outer</dsrl:parent>
       <dsrl:name>ex6:leaf1</dsrl:name>
       <dsrl:default-content>1</dsrl:default-content>
     </dsrl:element-map>
     <dsrl:element-map>
       <dsrl:parent>
         /nc:rpc-reply/nc:data/ex6:outer[not(ex6:leaf3)]
       </dsrl:parent>
       <dsrl:name>ex6:one</dsrl:name>
       <dsrl:default-content>
         <ex6:leaf2>2</ex6:leaf2>
       </dsrl:default-content>
     </dsrl:element-map>
     <dsrl:element-map>
       <dsrl:parent>
         /nc:rpc-reply/nc:data/ex6:outer/ex6:one
       </dsrl:parent>
       <dsrl:name>ex6: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 never becomes an implicit element.

请注意,在YANG模块中定义的“leaf3”的默认值被忽略,因为“leaf3”表示选择的非默认替代值,因此不会成为隐式元素。

12. Mapping NETMOD-Specific Annotations to DSDL Schema Languages
12. 将NETMOD特定注释映射到DSDL模式语言

This section contains the mapping specification for the 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 11. The context is determined by the element pattern in the hybrid schema to which the annotation is attached. In the rest of this section, CONTELEM will denote the name of this context element properly qualified with its namespace prefix.

本节包含各个NETMOD特定注释的映射规范。在每种情况下,映射的结果都必须插入到目标DSDL模式的适当上下文中,如第11节所述。上下文由附加注释的混合模式中的元素模式确定。在本节的其余部分中,CONTELEM将表示此上下文元素的名称,并使用其名称空间前缀进行适当限定。

12.1. The @nma:config Annotation
12.1. @nma:config注释

If this annotation is present with the value of "false", the following rules MUST be observed for DSDL schemas of <nc:get-config> reply:

如果此注释的值为“false”,则对于<nc:get config>reply的DSDL架构,必须遵守以下规则:

o When generating RELAX NG, the contents of the CONTELEM definition MUST be changed to <rng:notAllowed>.

o 生成RELAX NG时,contellem定义的内容必须更改为<rng:notAllowed>。

o When generating Schematron or DSRL, the CONTELEM definition and all its descendants in the hybrid schema MUST be ignored.

o 生成Schematron或DSRL时,必须忽略混合模式中的CONTELEM定义及其所有子代。

12.2. The @nma:default Annotation
12.2. @nma:default注释

This annotation is used for generating the DSRL schema as described in Section 11.3.

该注释用于生成第11.3节所述的DSRL模式。

12.3. The <nma:error-app-tag> Annotation
12.3. <nma:error-app-tag>注释

This annotation currently has no mapping defined.

此批注当前未定义映射。

12.4. The <nma:error-message> Annotation
12.4. <nma:error message>注释

This annotation is handled within <nma:must>, see Section 12.13.

此注释在<nma:must>中处理,请参见第12.13节。

12.5. The @if-feature Annotation
12.5. @if要素注释

The information about available features MAY be supplied as an input parameter to an implementation. In this case, the following changes MUST be performed for all features that are considered unavailable:

关于可用特性的信息可以作为输入参数提供给实现。在这种情况下,必须对所有被视为不可用的功能执行以下更改:

o When generating RELAX NG, the contents of the CONTELEM definition MUST be changed to <rng:notAllowed>.

o 生成RELAX NG时,contellem定义的内容必须更改为<rng:notAllowed>。

o When generating Schematron or DSRL, the CONTELEM definition and all its descendants in the hybrid schema MUST be ignored.

o 生成Schematron或DSRL时,必须忽略混合模式中的CONTELEM定义及其所有子代。

12.6. The @nma:implicit Annotation
12.6. @nma:implicit注释

This annotation is used for generating the DSRL schema as described in Section 11.3.

该注释用于生成第11.3节所述的DSRL模式。

12.7. The <nma:instance-identifier> Annotation
12.7. <nma:instance identifier>注释

If this annotation element has the @require-instance attribute with the value of "false", it is ignored. Otherwise, it is mapped to the following Schematron assert:

如果此注释元素的@require instance属性的值为“false”,则将忽略它。否则,它将映射到以下Schematron断言:

   <sch:assert test="nmf:evaluate(.)">
     The element pointed to by "CONTELEM" must exist.
   </sch:assert>
        
   <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 run time. Such an extension function is available in Extended XSLT (EXSLT) or provided as a proprietary extension by some XSLT processors, for example Saxon.

evaluate()函数是一个XSLT扩展函数(请参阅[XSLT]中的扩展函数),它在运行时对XPath表达式求值。这种扩展函数在扩展XSLT(EXSLT)中可用,或者由一些XSLT处理器(例如Saxon)作为专有扩展提供。

12.8. The @nma:key Annotation
12.8. @nma:key注释

Assume this annotation attribute contains "k_1 k_2 ... k_n", i.e., specifies n children of CONTELEM as list keys. The annotation is then mapped to the following Schematron report:

假设此注释属性包含“k_1 k_2…k_n”,即指定contellem的n个子项作为列表键。然后将注释映射到以下Schematron报告:

   <sch:report test="CONDITION">
     Duplicate key of list "CONTELEM"
   </sch: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]

其中条件具有以下形式:前面的同级::contellem[C_1和C_2和…和C_n]

Each sub-expression C_i, for i=1,2,...,n, specifies the condition for violated uniqueness of the key k_i, namely

对于i=1,2,…,n,每个子表达式C_i指定密钥k_i违反唯一性的条件,即

   k_i=current()/k_i
        
   k_i=current()/k_i
        
12.9. The @nma:leaf-list Annotation
12.9. @nma:leaf列表注释

This annotation is mapped to the following Schematron rule, which detects duplicate entries of a leaf-list:

此注释映射到以下Schematron规则,该规则检测叶列表的重复条目:

   <sch:report
       test=". = preceding-sibling::PREFIX:sorted-entry">
     Duplicate leaf-list entry "<sch:value-of select="."/>".
   </sch:report>
        
   <sch:report
       test=". = preceding-sibling::PREFIX:sorted-entry">
     Duplicate leaf-list entry "<sch:value-of select="."/>".
   </sch:report>
        

See Section 11.2 for a complete example.

完整示例见第11.2节。

12.10. The @nma:leafref Annotation
12.10. @nma:leafref注释

This annotation is mapped to the following assert:

此批注映射到以下断言:

   <sch:assert test="PATH=.">
     Leaf "PATH" does not exist for leafref value "VALUE"
   </sch:assert>
        
   <sch:assert test="PATH=.">
     Leaf "PATH" does not exist for leafref value "VALUE"
   </sch:assert>
        

where PATH is the value of @nma:leafref and VALUE is the value of the context element in the instance document for which the referred leaf doesn't exist.

其中PATH是@nma:leafref的值,value是引用的叶不存在的实例文档中上下文元素的值。

12.11. The @nma:min-elements Annotation
12.11. @nma:min元素注释

This annotation is mapped to the following Schematron assert:

此注释映射到以下Schematron assert:

   <sch:assert test="count(../CONTELEM)&gt;=MIN">
     List "CONTELEM" - item count must be at least MIN
   </sch:assert>
        
   <sch:assert test="count(../CONTELEM)&gt;=MIN">
     List "CONTELEM" - item count must be at least MIN
   </sch:assert>
        

where MIN is the value of @nma:min-elements.

其中MIN是@nma:MIN元素的值。

12.12. The @nma:max-elements Annotation
12.12. @nma:max元素注释

This annotation is mapped to the following Schematron assert:

此注释映射到以下Schematron assert:

<sch:assert
    test="count(../CONTELEM)&lt;=MAX or preceding-sibling::../CONTELEM">
  Number of list items must be at most MAX
</sch:assert>
        
<sch:assert
    test="count(../CONTELEM)&lt;=MAX or preceding-sibling::../CONTELEM">
  Number of list items must be at most MAX
</sch:assert>
        

where MAX is the value of @nma:min-elements.

其中MAX是@nma:min元素的值。

12.13. The <nma:must> Annotation
12.13. <nma:must>注释

This annotation is mapped to the following Schematron assert:

此注释映射到以下Schematron assert:

   <sch:assert test="EXPRESSION">
     MESSAGE
   </sch: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 contents; otherwise, it is set to the default message "Condition EXPRESSION must be true".

其中EXPRESSION是<nma:must>的强制@assert属性的值。如果存在<nma:error message>子元素,则将消息设置为其内容;否则,它将设置为默认消息“条件表达式必须为true”。

12.14. The <nma:ordered-by> Annotation
12.14. <nma:ordered by>注释

This annotation currently has no mapping defined.

此批注当前未定义映射。

12.15. The <nma:status> Annotation
12.15. <nma:status>注释

This annotation currently has no mapping defined.

此批注当前未定义映射。

12.16. The @nma:unique Annotation
12.16. @nma:unique注释

The mapping of this annotation is almost identical as for @nma:key, see Section 12.8, with two small differences:

此注释的映射与@nma:key的映射几乎相同,请参见第12.8节,但有两个小差异:

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.8 work without any modifications if the descendant schema node identifiers are substituted for k_1, k_2, ..., k_n.

o @nma:unique的值是后代模式节点标识符的列表,而不是简单的叶名称。但是,如果将子模式节点标识符替换为k_1、k_2、…、k_n,则第12.8节中指定的XPath表达式可以在不做任何修改的情况下工作。

o The message appearing as the text of <sch:report> is different: "Violated uniqueness for list CONTELEM".

o 显示为<sch:report>文本的消息不同:“违反了列表内容的唯一性”。

12.17. The @nma:when Annotation
12.17. @nma:when注释

This annotation is mapped to the following Schematron assert:

此注释映射到以下Schematron assert:

   <sch:assert test="EXPRESSION">
     Node "CONTELEM" is only valid when "EXPRESSION" is true.
   </sch:assert>
        
   <sch:assert test="EXPRESSION">
     Node "CONTELEM" is only valid when "EXPRESSION" is true.
   </sch:assert>
        

where EXPRESSION is the value of @nma:when.

其中表达式是@nma:when的值。

13. IANA Considerations
13. IANA考虑

This document requests the following two registrations of namespace URIs in the IETF XML registry [RFC3688]:

本文档要求在IETF XML注册表[RFC3688]中注册以下两个名称空间URI:

   -----------------------------------------------------
   URI: urn:ietf:params:xml:ns:netmod:dsdl-annotations:1
        
   -----------------------------------------------------
   URI: urn:ietf:params:xml:ns:netmod:dsdl-annotations:1
        

Registrant Contact: The IESG.

注册人联系人:IESG。

   XML: N/A, the requested URI is an XML namespace.
   -----------------------------------------------------
        
   XML: N/A, the requested URI is an XML namespace.
   -----------------------------------------------------
        
   -----------------------------------------------------
   URI: urn:ietf:params:xml:ns:netmod:xpath-extensions:1
        
   -----------------------------------------------------
   URI: urn:ietf:params:xml:ns:netmod:xpath-extensions:1
        

Registrant Contact: The IESG.

注册人联系人:IESG。

   XML: N/A, the requested URI is an XML namespace.
   -----------------------------------------------------
        
   XML: N/A, the requested URI is an XML namespace.
   -----------------------------------------------------
        
14. Security Considerations
14. 安全考虑

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.

本文档定义了一个过程,该过程将用YANG语言表示的数据模型映射到一组协调的DSDL模式。该过程本身对Internet没有安全影响。

DSDL schemas obtained by the mapping procedure may be used for validating the contents of NETCONF messages or entire datastores, and thus they 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.

通过映射过程获得的DSDL模式可用于验证NETCONF消息或整个数据存储的内容,因此它们提供了比NETCONF服务器和支持数据模型的客户端实现执行的有效性检查更多的有效性检查。此验证的严格性直接源自验证的XML数据所遵循的源模块。

15. Contributors
15. 贡献者

The following people contributed significantly to the initial version of this document:

以下人员对本文件的初始版本做出了重大贡献:

o Rohan Mahy

o 罗汉·马希

o Sharon Chisholm (Ciena)

o 莎伦·奇肖姆(西纳)

16. Acknowledgments
16. 致谢

The editor wishes to thank the following individuals who provided helpful suggestions and/or comments on various versions of this document: Andy Bierman, Martin Bjorklund, Jirka Kosek, Juergen Schoenwaelder, and Phil Shafer.

编辑谨感谢以下人士就本文件的不同版本提供了有益的建议和/或意见:安迪·比尔曼、马丁·比约克隆德、吉尔卡·科塞克、尤尔根·舍恩瓦埃尔德和菲尔·沙弗。

17. References
17. 工具书类
17.1. Normative References
17.1. 规范性引用文件

[DSDL] ISO/IEC, "Document Schema Definition Languages (DSDL) - Part 1: Overview", ISO/IEC 19757-1, November 2004.

[DSDL]ISO/IEC,“文件模式定义语言(DSDL)-第1部分:概述”,ISO/IEC 19757-12004年11月。

[DSRL] ISO/IEC, "Information Technology - Document Schema Definition Languages (DSDL) - Part 8: Document Semantics Renaming Language - DSRL", ISO/ IEC 19757-8:2008(E), December 2008.

[DSRL]ISO/IEC,“信息技术-文档模式定义语言(DSDL)-第8部分:文档语义重命名语言-DSRL”,ISO/IEC 19757-8:2008(E),2008年12月。

[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997.

[RFC2119]Bradner,S.,“RFC中用于表示需求水平的关键词”,BCP 14,RFC 2119,1997年3月。

[RFC3688] Mealling, M., "The IETF XML Registry", BCP 81, RFC 3688, January 2004.

[RFC3688]Mealling,M.“IETF XML注册表”,BCP 81,RFC 3688,2004年1月。

[RFC4741] Enns, R., "NETCONF Configuration Protocol", RFC 4741, December 2006.

[RFC4741]Enns,R.,“网络配置协议”,RFC 47412006年12月。

[RFC6020] Bjorklund, M., Ed., "YANG - A Data Modeling Language for Network Configuration Protocol (NETCONF)", RFC 6020, October 2010.

[RFC6020]Bjorklund,M.,Ed.“YANG-网络配置协议的数据建模语言(NETCONF)”,RFC 602020,2010年10月。

[RFC6021] Schoenwaelder, J., Ed., "Common YANG Data Types", RFC 6021, October 2010.

[RFC6021]Schoenwaeld,J.,Ed.,“常见的杨氏数据类型”,RFC 602112010年10月。

[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), December 2008.

[RNG]ISO/IEC,“信息技术-文档模式定义语言(DSDL)-第2部分:基于规则语法的验证-RELAX NG.第二版”,ISO/IEC 19757-2:2008(E),2008年12月。

[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), January 2006.

[RNG-CS]ISO/IEC,“信息技术-文档模式定义语言(DSDL)-第2部分:基于规则语法的验证-RELAX NG.修改件1:紧凑语法”,ISO/IEC 19757-2:2003/Amd。1:2006(E),2006年1月。

[RNG-DTD] Clark, J., Ed. and M. Murata, Ed., "RELAX NG DTD Compatibility", OASIS Committee Specification, 3 December 2001.

[RNG-DTD]Clark,J.,Ed.和M.Murata,Ed.,“RELAX NG DTD兼容性”,OASIS委员会规范,2001年12月3日。

[Schematron] ISO/IEC, "Information Technology - Document Schema Definition Languages (DSDL) - Part 3: Rule-Based Validation - Schematron", ISO/IEC 19757-3:2006(E), June 2006.

[Schematron]ISO/IEC,“信息技术-文档模式定义语言(DSDL)-第3部分:基于规则的验证-Schematron”,ISO/IEC 19757-3:2006(E),2006年6月。

[XML] Bray, T., Paoli, J., Sperberg-McQueen, C., Maler, E., and F. Yergeau, "Extensible Markup Language (XML) 1.0 (Fifth Edition)", World Wide Web Consortium Recommendation REC-xml-20081126, November 2008, <http://www.w3.org/TR/2006/REC-xml-20060816>.

[XML]Bray,T.,Paoli,J.,Sperberg McQueen,C.,Maler,E.,和F.Yergeau,“可扩展标记语言(XML)1.0(第五版)”,万维网联盟建议REC-XML-20081126,2008年11月<http://www.w3.org/TR/2006/REC-xml-20060816>.

[XML-INFOSET] Tobin, R. and J. Cowan, "XML Information Set (Second Edition)", World Wide Web Consortium Recommendation REC-xml-infoset-20040204, February 2004, <http://www.w3.org/TR/2004/REC-xml-infoset-20040204>.

[XML-INFOSET]Tobin,R.和J.Cowan,“XML信息集(第二版)”,万维网联盟建议REC-XML-INFOSET-200402042004年2月<http://www.w3.org/TR/2004/REC-xml-infoset-20040204>.

[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>.

[XPath]Clark,J.和S.DeRose,“XML路径语言(XPath)1.0版”,万维网联盟建议REC-XPath-19991116,1999年11月<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>.

[XSD-D]Biron,P.和A.Malhotra,“XML模式第2部分:数据类型第二版”,万维网联盟建议REC-xmlschema-2-20041028,2004年10月<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.

[XSLT]Clark,J.,“XSL转换(XSLT)1.0版”,万维网联盟建议REC-XSLT-19991116,1999年11月。

17.2. Informative References
17.2. 资料性引用

[DHCPtut] Bjorklund, M., "DHCP Tutorial", November 2007, <http:/ /www.yang-central.org/twiki/bin/view/Main/ DhcpTutorial>.

[DHCPtut]Bjorklund,M.,“DHCP教程”,2007年11月,<http://www.yang-central.org/twiki/bin/view/Main/DhcpTutorial>。

[RFC1157] Case, J., Fedor, M., Schoffstall, M., and J. Davin, "Simple Network Management Protocol (SNMP)", RFC 1157, May 1990.

[RFC1157]Case,J.,Fedor,M.,Schoffstall,M.,和J.Davin,“简单网络管理协议(SNMP)”,RFC 1157,1990年5月。

[RFC2578] McCloghrie, K., Ed., Perkins, D., Ed., and J. Schoenwaelder, Ed., "Structure of Management Information Version 2 (SMIv2)", STD 58, RFC 2578, April 1999.

[RFC2578]McCloghrie,K.,Ed.,Perkins,D.,Ed.,和J.Schoenwaeld,Ed.“管理信息的结构版本2(SMIv2)”,STD 58,RFC 2578,1999年4月。

[RFC5013] Kunze, J., "The Dublin Core Metadata Element Set", RFC 5013, August 2007.

[RFC5013]Kunze,J.,“都柏林核心元数据元素集”,RFC 5013,2007年8月。

[RFC5277] Chisholm, S. and H. Trevino, "NETCONF Event Notifications", RFC 5277, July 2008.

[RFC5277]Chisholm,S.和H.Trevino,“NETCONF事件通知”,RFC 5277,2008年7月。

[Trang] Clark, J., "Trang: Multiformat schema converter based on RELAX NG", 2008, <http://www.thaiopensource.com/relaxng/trang.html>.

[Trang]Clark,J.,“Trang:基于RELAXNG的多格式模式转换器”,2008<http://www.thaiopensource.com/relaxng/trang.html>.

[Vli04] van der Vlist, E., "RELAX NG", O'Reilly, 2004.

[Vli04]范德维斯特,E.,“放松”,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>.

[XSD]Thompson,H.,Beech,D.,Maloney,M.,和N.Mendelsohn,“XML模式第1部分:结构第二版”,万维网联盟建议REC-xmlschema-1-20041028,2004年10月<http://www.w3.org/TR/2004/REC-xmlschema-1-20041028>.

[pyang] Bjorklund, M. and L. Lhotka, "pyang: An extensible YANG validator and converter in Python", 2010, <http://code.google.com/p/pyang/>.

[pyang]Bjorklund,M.和L.Lhotka,“pyang:Python中的可扩展YANG验证程序和转换器”,2010年<http://code.google.com/p/pyang/>.

Appendix A. RELAX NG Schema for NETMOD-Specific Annotations
附录A.NETMOD特定注释的RELAX NG模式

This appendix defines the content model for all NETMOD-specific annotations in the form of RELAX NG named pattern definitions.

本附录以RELAX NG命名模式定义的形式定义了所有NETMOD特定注释的内容模型。

<CODE BEGINS> file "nmannot.rng"

<CODE start>文件“nmanno.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">
        
  <?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">
    <attribute name="nma:config">
      <data type="boolean"/>
    </attribute>
  </define>
        
  <define name="config-attribute">
    <attribute name="nma:config">
      <data type="boolean"/>
    </attribute>
  </define>
        
  <define name="data-element">
    <element name="nma:data">
      <ref name="__anyxml__"/>
    </element>
  </define>
        
  <define name="data-element">
    <element name="nma:data">
      <ref name="__anyxml__"/>
    </element>
  </define>
        
  <define name="default-attribute">
    <attribute name="nma:default">
      <data type="string"/>
    </attribute>
  </define>
        
  <define name="default-attribute">
    <attribute name="nma:default">
      <data type="string"/>
    </attribute>
  </define>
        
  <define name="error-app-tag-element">
    <element name="nma:error-app-tag">
      <text/>
    </element>
  </define>
        
  <define name="error-app-tag-element">
    <element name="nma:error-app-tag">
      <text/>
    </element>
  </define>
        
  <define name="error-message-element">
    <element name="nma:error-message">
      <text/>
    </element>
  </define>
        
  <define name="error-message-element">
    <element name="nma:error-message">
      <text/>
    </element>
  </define>
        
  <define name="if-feature-attribute">
    <attribute name="nma:if-feature">
      <list>
        <data type="QName"/>
      </list>
    </attribute>
  </define>
        
  <define name="if-feature-attribute">
    <attribute name="nma:if-feature">
      <list>
        <data type="QName"/>
      </list>
    </attribute>
  </define>
        
  <define name="implicit-attribute">
    <attribute name="nma:implicit">
      <data type="boolean"/>
    </attribute>
  </define>
        
  <define name="implicit-attribute">
    <attribute name="nma:implicit">
      <data type="boolean"/>
    </attribute>
  </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="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">
    <attribute name="nma:key">
      <list>
        <data type="QName"/>
      </list>
    </attribute>
  </define>
        
  <define name="key-attribute">
    <attribute name="nma:key">
      <list>
        <data type="QName"/>
      </list>
    </attribute>
  </define>
        
  <define name="leaf-list-attribute">
    <attribute name="nma:leaf-list">
      <data type="boolean"/>
    </attribute>
  </define>
        
  <define name="leaf-list-attribute">
    <attribute name="nma:leaf-list">
      <data type="boolean"/>
    </attribute>
  </define>
        
  <define name="leafref-attribute">
    <attribute name="nma:leafref">
      <data type="string"/>
    </attribute>
  </define>
        
  <define name="leafref-attribute">
    <attribute name="nma:leafref">
      <data type="string"/>
    </attribute>
  </define>
        
  <define name="mandatory-attribute">
    <attribute name="nma:mandatory">
      <data type="Name"/>
    </attribute>
  </define>
        
  <define name="mandatory-attribute">
    <attribute name="nma:mandatory">
      <data type="Name"/>
    </attribute>
  </define>
        
  <define name="max-elements-attribute">
    <attribute name="nma:max-elements">
      <data type="nonNegativeInteger"/>
    </attribute>
  </define>
        
  <define name="max-elements-attribute">
    <attribute name="nma:max-elements">
      <data type="nonNegativeInteger"/>
    </attribute>
  </define>
        
  <define name="min-elements-attribute">
    <attribute name="nma:min-elements">
      <data type="nonNegativeInteger"/>
    </attribute>
  </define>
        
  <define name="min-elements-attribute">
    <attribute name="nma:min-elements">
      <data type="nonNegativeInteger"/>
    </attribute>
  </define>
        
  <define name="module-attribute">
    <attribute name="nma:module">
      <data type="Name"/>
    </attribute>
  </define>
        
  <define name="module-attribute">
    <attribute name="nma:module">
      <data type="Name"/>
    </attribute>
  </define>
        
  <define name="must-element">
    <element name="nma:must">
      <attribute name="assert">
        <data type="string"/>
      </attribute>
      <interleave>
        <optional>
          <ref name="error-app-tag-element"/>
        </optional>
        <optional>
          <ref name="error-message-element"/>
        </optional>
      </interleave>
    </element>
  </define>
        
  <define name="must-element">
    <element name="nma:must">
      <attribute name="assert">
        <data type="string"/>
      </attribute>
      <interleave>
        <optional>
          <ref name="error-app-tag-element"/>
        </optional>
        <optional>
          <ref name="error-message-element"/>
        </optional>
      </interleave>
    </element>
  </define>
        
  <define name="notifications-element">
    <element name="nma:notifications">
      <zeroOrMore>
        <element name="nma:notification">
          <ref name="__anyxml__"/>
        </element>
      </zeroOrMore>
    </element>
  </define>
        
  <define name="notifications-element">
    <element name="nma:notifications">
      <zeroOrMore>
        <element name="nma:notification">
          <ref name="__anyxml__"/>
        </element>
      </zeroOrMore>
    </element>
  </define>
        
  <define name="rpcs-element">
    <element name="nma:rpcs">
      <zeroOrMore>
        <element name="nma:rpc">
          <interleave>
            <element name="nma:input">
              <ref name="__anyxml__"/>
            </element>
            <optional>
              <element name="nma:output">
                <ref name="__anyxml__"/>
              </element>
            </optional>
          </interleave>
        </element>
      </zeroOrMore>
    </element>
  </define>
        
  <define name="rpcs-element">
    <element name="nma:rpcs">
      <zeroOrMore>
        <element name="nma:rpc">
          <interleave>
            <element name="nma:input">
              <ref name="__anyxml__"/>
            </element>
            <optional>
              <element name="nma:output">
                <ref name="__anyxml__"/>
              </element>
            </optional>
          </interleave>
        </element>
      </zeroOrMore>
    </element>
  </define>
        
  <define name="ordered-by-attribute">
    <attribute name="nma:ordered-by">
      <choice>
        <value>user</value>
        <value>system</value>
      </choice>
    </attribute>
  </define>
        
  <define name="ordered-by-attribute">
    <attribute name="nma:ordered-by">
      <choice>
        <value>user</value>
        <value>system</value>
      </choice>
    </attribute>
  </define>
        
  <define name="status-attribute">
    <optional>
      <attribute name="nma:status">
        <choice>
          <value>current</value>
          <value>deprecated</value>
          <value>obsolete</value>
        </choice>
      </attribute>
    </optional>
  </define>
        
  <define name="status-attribute">
    <optional>
      <attribute name="nma:status">
        <choice>
          <value>current</value>
          <value>deprecated</value>
          <value>obsolete</value>
        </choice>
      </attribute>
    </optional>
  </define>
        
  <define name="unique-attribute">
    <optional>
      <attribute name="nma:unique">
        <list>
          <data type="token"/>
        </list>
      </attribute>
    </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="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>
        
  <define name="when-attribute">
    <optional>
      <attribute name="nma:when">
        <data type="string"/>
      </attribute>
    </optional>
  </define>
        
  <define name="__anyxml__">
    <zeroOrMore>
      <choice>
        <attribute>
          <anyName/>
        </attribute>
        <element>
          <anyName/>
          <ref name="__anyxml__"/>
        </element>
        <text/>
      </choice>
    </zeroOrMore>
  </define>
        
  <define name="__anyxml__">
    <zeroOrMore>
      <choice>
        <attribute>
          <anyName/>
        </attribute>
        <element>
          <anyName/>
          <ref name="__anyxml__"/>
        </element>
        <text/>
      </choice>
    </zeroOrMore>
  </define>
        
  </grammar>
        
  </grammar>
        

<CODE ENDS>

<代码结束>

Appendix B. Schema-Independent Library
附录B.独立于模式的库

In order to avoid copying the common named pattern definitions to every RELAX NG schema generated in the second mapping step, the definitions are collected in 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].

为了避免将通用命名模式定义复制到在第二个映射步骤中生成的每个relaxng模式中,这些定义收集在一个库文件(与模式无关的库)中,该库由验证模式包含在文件名“relaxng lib.rng”(XML语法)和“relaxng lib.rnc”(紧凑语法)下。所包含的定义涵盖了基本NETCONF[RFC4741]和事件通知[RFC5277]中公共元素的模式。

<CODE BEGINS> file "relaxng-lib.rng"

<CODE start>文件“relaxng lib.rng”

  <?xml version="1.0" encoding="UTF-8"?>
        
  <?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">
        
  <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="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="ok-element">
      <element name="nc:ok">
        <empty/>
      </element>
    </define>
        
    <define name="eventTime-element">
      <element name="en:eventTime">
        <data type="dateTime"/>
      </element>
    </define>
  </grammar>
        
    <define name="eventTime-element">
      <element name="en:eventTime">
        <data type="dateTime"/>
      </element>
    </define>
  </grammar>
        

<CODE ENDS>

<代码结束>

Appendix C. Mapping DHCP Data Model - A Complete Example
附录C.映射DHCP数据模型-完整示例

This appendix demonstrates both steps of the YANG-to-DSDL mapping applied to the "canonical" DHCP tutorial [DHCPtut] data model. The input YANG module is shown in Appendix C.1 and the output schemas in the following two subsections.

本附录演示了应用于“规范”DHCP教程[DHCPtut]数据模型的YANG到DSDL映射的两个步骤。输入模块如附录C.1所示,输出模式如以下两小节所示。

The hybrid schema was obtained by the "dsdl" plugin of the pyang tool [pyang] and the validating DSDL schemas were obtained by XSLT stylesheets that are also part of pyang distribution.

混合模式由pyang工具[pyang]的“dsdl”插件获得,验证dsdl模式由XSLT样式表获得,XSLT样式表也是pyang发行版的一部分。

Due to the limit of 72 characters per line, a few long strings required manual editing, in particular the regular expression patterns for IP addresses, etc. These were replaced by the placeholder string "... regex pattern ...". Also, line breaks were added to several documentation strings and Schematron messages.

由于每行72个字符的限制,一些长字符串需要手动编辑,特别是IP地址的正则表达式模式等。这些字符串被占位符字符串“…regex pattern…”替换。此外,在几个文档字符串和Schematron消息中添加了换行符。

Other than that, the results of the automatic translations were not changed.

除此之外,自动翻译的结果没有改变。

C.1. Input YANG Module
C.1. 输入阳模
   module dhcp {
     namespace "http://example.com/ns/dhcp";
     prefix dhcp;
        
   module dhcp {
     namespace "http://example.com/ns/dhcp";
     prefix dhcp;
        
     import ietf-yang-types { prefix yang; }
     import ietf-inet-types { prefix inet; }
        
     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.";
        
     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.";
        
     container dhcp {
       description
         "configuration and operational parameters for a DHCP server.";
        
       leaf max-lease-time {
         type uint32;
         units seconds;
         default 7200;
       }
        
       leaf max-lease-time {
         type uint32;
         units seconds;
         default 7200;
       }
        
       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;
       }
        
       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;
        
       container shared-networks {
         list shared-network {
           key name;
        
           leaf name {
             type string;
           }
           uses subnet-list;
         }
       }
        
           leaf name {
             type string;
           }
           uses subnet-list;
         }
       }
        
       container status {
         config false;
         list leases {
           key address;
        
       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;
             }
           }
         }
       }
     }
        
           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;
             }
           }
         }
       }
     }
        
     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";
           }
        
     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;
           }
         }
        
           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";
           }
         }
        
         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;
         }
       }
     }
   }
        
         leaf max-lease-time {
           type uint32;
           units seconds;
           default 7200;
         }
       }
     }
   }
        
C.2. Hybrid Schema
C.2. 混合模式
   <?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"
       xmlns:dc="http://purl.org/dc/terms"
       xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
       xmlns:dhcp="http://example.com/ns/dhcp"
       datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
    <dc:creator>Pyang 1.0a, DSDL plugin</dc:creator>
    <dc:date>2010-06-17</dc:date>
    <start>
     <grammar nma:module="dhcp" ns="http://example.com/ns/dhcp">
      <dc:source>YANG module 'dhcp'</dc:source>
      <start>
        
   <?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"
       xmlns:dc="http://purl.org/dc/terms"
       xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
       xmlns:dhcp="http://example.com/ns/dhcp"
       datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
    <dc:creator>Pyang 1.0a, DSDL plugin</dc:creator>
    <dc:date>2010-06-17</dc:date>
    <start>
     <grammar nma:module="dhcp" ns="http://example.com/ns/dhcp">
      <dc:source>YANG module 'dhcp'</dc:source>
      <start>
        
       <nma:data>
        <optional>
         <element nma:implicit="true" name="dhcp:dhcp">
          <interleave>
           <a:documentation>
            configuration and operational parameters for a DHCP server.
           </a:documentation>
           <optional>
            <element nma:default="7200"
                     name="dhcp:max-lease-time"
                     nma:units="seconds">
             <data type="unsignedInt"/>
            </element>
           </optional>
           <optional>
            <element nma:default="600"
                     name="dhcp:default-lease-time"
                     nma:units="seconds">
             <data type="unsignedInt"/>
             <nma:must assert=". &lt;= ../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">
             <zeroOrMore>
              <element nma:key="dhcp:name"
                       name="dhcp:shared-network">
               <element name="dhcp:name">
                <data type="string"/>
               </element>
               <ref name="_dhcp__subnet-list"/>
              </element>
             </zeroOrMore>
            </element>
           </optional>
           <optional>
            <element name="dhcp:status" nma:config="false">
             <zeroOrMore>
              <element nma:key="dhcp:address"
                       name="dhcp:leases">
               <element name="dhcp:address">
                <ref name="ietf-inet-types__ip-address"/>
               </element>
        
       <nma:data>
        <optional>
         <element nma:implicit="true" name="dhcp:dhcp">
          <interleave>
           <a:documentation>
            configuration and operational parameters for a DHCP server.
           </a:documentation>
           <optional>
            <element nma:default="7200"
                     name="dhcp:max-lease-time"
                     nma:units="seconds">
             <data type="unsignedInt"/>
            </element>
           </optional>
           <optional>
            <element nma:default="600"
                     name="dhcp:default-lease-time"
                     nma:units="seconds">
             <data type="unsignedInt"/>
             <nma:must assert=". &lt;= ../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">
             <zeroOrMore>
              <element nma:key="dhcp:name"
                       name="dhcp:shared-network">
               <element name="dhcp:name">
                <data type="string"/>
               </element>
               <ref name="_dhcp__subnet-list"/>
              </element>
             </zeroOrMore>
            </element>
           </optional>
           <optional>
            <element name="dhcp:status" nma:config="false">
             <zeroOrMore>
              <element nma:key="dhcp:address"
                       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>
            </element>
           </optional>
          </interleave>
         </element>
        </optional>
       </nma:data>
       <nma:rpcs/>
       <nma:notifications/>
      </start>
     </grammar>
    </start>
    <define name="ietf-yang-types__phys-address">
     <data type="string">
      <param name="pattern">([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?</param>
        
               <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>
            </element>
           </optional>
          </interleave>
         </element>
        </optional>
       </nma:data>
       <nma:rpcs/>
       <nma:notifications/>
      </start>
     </grammar>
    </start>
    <define name="ietf-yang-types__phys-address">
     <data type="string">
      <param name="pattern">([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?</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__ip-prefix">
     <choice>
      <ref name="ietf-inet-types__ipv4-prefix"/>
      <ref name="ietf-inet-types__ipv6-prefix"/>
     </choice>
    </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-yang-types__date-and-time">
     <data type="string">
      <param name="pattern">... regex pattern ...</param>
     </data>
    </define>
    <define name="_dhcp__subnet-list">
     <a:documentation>A reusable list of subnets</a:documentation>
     <zeroOrMore>
      <element nma:key="net" name="subnet">
       <element name="net">
        <ref name="ietf-inet-types__ip-prefix"/>
       </element>
       <interleave>
        <optional>
         <element name="range">
          <interleave>
           <optional>
            <element name="dynamic-bootp">
             <a:documentation>
              Allows BOOTP clients to get addresses in this range
             </a:documentation>
             <empty/>
            </element>
           </optional>
           <element name="low">
            <ref name="ietf-inet-types__ip-address"/>
           </element>
           <element name="high">
        
     </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__ip-prefix">
     <choice>
      <ref name="ietf-inet-types__ipv4-prefix"/>
      <ref name="ietf-inet-types__ipv6-prefix"/>
     </choice>
    </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-yang-types__date-and-time">
     <data type="string">
      <param name="pattern">... regex pattern ...</param>
     </data>
    </define>
    <define name="_dhcp__subnet-list">
     <a:documentation>A reusable list of subnets</a:documentation>
     <zeroOrMore>
      <element nma:key="net" name="subnet">
       <element name="net">
        <ref name="ietf-inet-types__ip-prefix"/>
       </element>
       <interleave>
        <optional>
         <element name="range">
          <interleave>
           <optional>
            <element name="dynamic-bootp">
             <a:documentation>
              Allows BOOTP clients to get addresses in this range
             </a:documentation>
             <empty/>
            </element>
           </optional>
           <element name="low">
            <ref name="ietf-inet-types__ip-address"/>
           </element>
           <element name="high">
        
            <ref name="ietf-inet-types__ip-address"/>
           </element>
          </interleave>
         </element>
        </optional>
        <optional>
         <element name="dhcp-options">
          <interleave>
           <a:documentation>
            Options in the DHCP protocol
           </a:documentation>
           <zeroOrMore>
            <element nma:leaf-list="true" name="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="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 nma:default="7200" name="max-lease-time"
                  nma:units="seconds">
          <data type="unsignedInt"/>
         </element>
        </optional>
       </interleave>
      </element>
     </zeroOrMore>
    </define>
    <define name="ietf-inet-types__domain-name">
     <data type="string">
      <param name="pattern">... regex pattern ...</param>
      <param name="minLength">1</param>
      <param name="maxLength">253</param>
     </data>
    </define>
        
            <ref name="ietf-inet-types__ip-address"/>
           </element>
          </interleave>
         </element>
        </optional>
        <optional>
         <element name="dhcp-options">
          <interleave>
           <a:documentation>
            Options in the DHCP protocol
           </a:documentation>
           <zeroOrMore>
            <element nma:leaf-list="true" name="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="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 nma:default="7200" name="max-lease-time"
                  nma:units="seconds">
          <data type="unsignedInt"/>
         </element>
        </optional>
       </interleave>
      </element>
     </zeroOrMore>
    </define>
    <define name="ietf-inet-types__domain-name">
     <data type="string">
      <param name="pattern">... regex pattern ...</param>
      <param name="minLength">1</param>
      <param name="maxLength">253</param>
     </data>
    </define>
        
    <define name="ietf-inet-types__ipv4-prefix">
     <data type="string">
      <param name="pattern">... regex pattern ...</param>
     </data>
    </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-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>
   </grammar>
        
    <define name="ietf-inet-types__ipv4-prefix">
     <data type="string">
      <param name="pattern">... regex pattern ...</param>
     </data>
    </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-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>
   </grammar>
        
C.3. Final DSDL Schemas
C.3. 最终DSDL模式

This appendix contains DSDL schemas that were obtained from the hybrid schema in Appendix C.2 by XSL transformations. These schemas can be directly used for validating a reply to unfiltered <nc:get> with the contents corresponding to the DHCP data model.

本附录包含通过XSL转换从附录C.2中的混合模式获得的DSDL模式。这些模式可直接用于验证对未筛选<nc:get>的回复,其内容与DHCP数据模型对应。

The RELAX NG schema (in two parts, as explained in Section 8.2) also includes the schema-independent library from Appendix B.

RELAXNG模式(分为两部分,如第8.2节所述)还包括附录B中的独立于模式的库。

C.3.1. Main RELAX NG Schema for <nc:get> Reply
C.3.1. <nc:get>回复的主RELAX NG模式
   <?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"
       xmlns:dhcp="http://example.com/ns/dhcp"
       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">
        
   <?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"
       xmlns:dhcp="http://example.com/ns/dhcp"
       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>
        <grammar ns="http://example.com/ns/dhcp">
         <include href="dhcp-gdefs.rng"/>
         <start>
          <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">
               <zeroOrMore>
                <element name="dhcp:shared-network">
                 <element name="dhcp:name">
                  <data type="string"/>
                 </element>
                 <ref name="_dhcp__subnet-list"/>
                </element>
               </zeroOrMore>
              </element>
             </optional>
             <optional>
              <element name="dhcp:status">
               <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>
        
       <interleave>
        <grammar ns="http://example.com/ns/dhcp">
         <include href="dhcp-gdefs.rng"/>
         <start>
          <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">
               <zeroOrMore>
                <element name="dhcp:shared-network">
                 <element name="dhcp:name">
                  <data type="string"/>
                 </element>
                 <ref name="_dhcp__subnet-list"/>
                </element>
               </zeroOrMore>
              </element>
             </optional>
             <optional>
              <element name="dhcp:status">
               <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>
              </element>
             </optional>
            </interleave>
           </element>
          </optional>
         </start>
        </grammar>
       </interleave>
      </element>
     </element>
    </start>
   </grammar>
        
                  <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>
              </element>
             </optional>
            </interleave>
           </element>
          </optional>
         </start>
        </grammar>
       </interleave>
      </element>
     </element>
    </start>
   </grammar>
        
C.3.2. RELAX NG Schema - Global Named Pattern Definitions
C.3.2. RELAXNG模式-全局命名模式定义
   <?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"
       xmlns:dhcp="http://example.com/ns/dhcp"
       datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
    <define name="ietf-yang-types__phys-address">
     <data type="string">
      <param name="pattern">
       ([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?
        
   <?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"
       xmlns:dhcp="http://example.com/ns/dhcp"
       datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
    <define name="ietf-yang-types__phys-address">
     <data type="string">
      <param name="pattern">
       ([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?
        
      </param>
     </data>
    </define>
    <define name="ietf-inet-types__ipv6-address">
     <data type="string">
      <param name="pattern">... regex pattern ...</param>
     </data>
    </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__host">
     <choice>
      <ref name="ietf-inet-types__ip-address"/>
      <ref name="ietf-inet-types__domain-name"/>
     </choice>
    </define>
    <define name="ietf-yang-types__date-and-time">
     <data type="string">
      <param name="pattern">... regex pattern ...</param>
     </data>
    </define>
    <define name="_dhcp__subnet-list">
     <zeroOrMore>
      <element name="subnet">
       <element name="net">
        <ref name="ietf-inet-types__ip-prefix"/>
       </element>
       <interleave>
        <optional>
         <element name="range">
          <interleave>
           <optional>
            <element name="dynamic-bootp">
             <empty/>
            </element>
           </optional>
           <element name="low">
            <ref name="ietf-inet-types__ip-address"/>
           </element>
           <element name="high">
            <ref name="ietf-inet-types__ip-address"/>
           </element>
          </interleave>
         </element>
        
      </param>
     </data>
    </define>
    <define name="ietf-inet-types__ipv6-address">
     <data type="string">
      <param name="pattern">... regex pattern ...</param>
     </data>
    </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__host">
     <choice>
      <ref name="ietf-inet-types__ip-address"/>
      <ref name="ietf-inet-types__domain-name"/>
     </choice>
    </define>
    <define name="ietf-yang-types__date-and-time">
     <data type="string">
      <param name="pattern">... regex pattern ...</param>
     </data>
    </define>
    <define name="_dhcp__subnet-list">
     <zeroOrMore>
      <element name="subnet">
       <element name="net">
        <ref name="ietf-inet-types__ip-prefix"/>
       </element>
       <interleave>
        <optional>
         <element name="range">
          <interleave>
           <optional>
            <element name="dynamic-bootp">
             <empty/>
            </element>
           </optional>
           <element name="low">
            <ref name="ietf-inet-types__ip-address"/>
           </element>
           <element name="high">
            <ref name="ietf-inet-types__ip-address"/>
           </element>
          </interleave>
         </element>
        
        </optional>
        <optional>
         <element name="dhcp-options">
          <interleave>
           <zeroOrMore>
            <element name="router">
             <ref name="ietf-inet-types__host"/>
            </element>
           </zeroOrMore>
           <optional>
            <element name="domain-name">
             <ref name="ietf-inet-types__domain-name"/>
            </element>
           </optional>
          </interleave>
         </element>
        </optional>
        <optional>
         <element name="max-lease-time">
          <data type="unsignedInt"/>
         </element>
        </optional>
       </interleave>
      </element>
     </zeroOrMore>
    </define>
    <define name="ietf-inet-types__domain-name">
     <data type="string">
      <param name="pattern">... regex pattern ...</param>
      <param name="minLength">1</param>
      <param name="maxLength">253</param>
     </data>
    </define>
    <define name="ietf-inet-types__ipv4-prefix">
     <data type="string">
      <param name="pattern">... regex pattern ...</param>
     </data>
    </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-prefix">
     <data type="string">
      <param name="pattern">... regex pattern ...</param>
      <param name="pattern">... regex pattern ...</param>
     </data>
        
        </optional>
        <optional>
         <element name="dhcp-options">
          <interleave>
           <zeroOrMore>
            <element name="router">
             <ref name="ietf-inet-types__host"/>
            </element>
           </zeroOrMore>
           <optional>
            <element name="domain-name">
             <ref name="ietf-inet-types__domain-name"/>
            </element>
           </optional>
          </interleave>
         </element>
        </optional>
        <optional>
         <element name="max-lease-time">
          <data type="unsignedInt"/>
         </element>
        </optional>
       </interleave>
      </element>
     </zeroOrMore>
    </define>
    <define name="ietf-inet-types__domain-name">
     <data type="string">
      <param name="pattern">... regex pattern ...</param>
      <param name="minLength">1</param>
      <param name="maxLength">253</param>
     </data>
    </define>
    <define name="ietf-inet-types__ipv4-prefix">
     <data type="string">
      <param name="pattern">... regex pattern ...</param>
     </data>
    </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-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>
   </grammar>
        
    </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>
   </grammar>
        
C.3.3. Schematron Schema for <nc:get> Reply
C.3.3. <nc:get>回复的Schematron模式
  <?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:pattern abstract="true" id="_dhcp__subnet-list">
    <sch:rule context="$start/$pref:subnet">
     <sch:report test="preceding-sibling::$pref:subnet
                       [$pref:net=current()/$pref:net]">
      Duplicate key "net"
     </sch:report>
    </sch:rule>
    <sch:rule
      context="$start/$pref:subnet/$pref:dhcp-options/$pref:router">
     <sch:report test=".=preceding-sibling::router">
      Duplicate leaf-list value "<sch:value-of select="."/>"
     </sch:report>
    </sch:rule>
   </sch:pattern>
   <sch:pattern id="dhcp">
    <sch:rule
      context="/nc:rpc-reply/nc:data/dhcp:dhcp/dhcp:default-lease-time">
     <sch:assert test=". &lt;= ../dhcp:max-lease-time">
      The default-lease-time must be less than max-lease-time
     </sch:assert>
    </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 "dhcp:name"
     </sch:report>
    </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 "dhcp:address"
        
  <?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:pattern abstract="true" id="_dhcp__subnet-list">
    <sch:rule context="$start/$pref:subnet">
     <sch:report test="preceding-sibling::$pref:subnet
                       [$pref:net=current()/$pref:net]">
      Duplicate key "net"
     </sch:report>
    </sch:rule>
    <sch:rule
      context="$start/$pref:subnet/$pref:dhcp-options/$pref:router">
     <sch:report test=".=preceding-sibling::router">
      Duplicate leaf-list value "<sch:value-of select="."/>"
     </sch:report>
    </sch:rule>
   </sch:pattern>
   <sch:pattern id="dhcp">
    <sch:rule
      context="/nc:rpc-reply/nc:data/dhcp:dhcp/dhcp:default-lease-time">
     <sch:assert test=". &lt;= ../dhcp:max-lease-time">
      The default-lease-time must be less than max-lease-time
     </sch:assert>
    </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 "dhcp:name"
     </sch:report>
    </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 "dhcp:address"
        
     </sch:report>
    </sch:rule>
   </sch:pattern>
   <sch:pattern id="id2768196" is-a="_dhcp__subnet-list">
    <sch:param name="start" value="/nc:rpc-reply/nc:data/dhcp:dhcp"/>
    <sch:param name="pref" value="dhcp"/>
   </sch:pattern>
   <sch:pattern id="id2768215" is-a="_dhcp__subnet-list">
    <sch:param name="start"
               value="/nc:rpc-reply/nc:data/dhcp:dhcp/
                      dhcp:shared-networks/dhcp:shared-network"/>
    <sch:param name="pref" value="dhcp"/>
   </sch:pattern>
  </sch:schema>
        
     </sch:report>
    </sch:rule>
   </sch:pattern>
   <sch:pattern id="id2768196" is-a="_dhcp__subnet-list">
    <sch:param name="start" value="/nc:rpc-reply/nc:data/dhcp:dhcp"/>
    <sch:param name="pref" value="dhcp"/>
   </sch:pattern>
   <sch:pattern id="id2768215" is-a="_dhcp__subnet-list">
    <sch:param name="start"
               value="/nc:rpc-reply/nc:data/dhcp:dhcp/
                      dhcp:shared-networks/dhcp:shared-network"/>
    <sch:param name="pref" value="dhcp"/>
   </sch:pattern>
  </sch:schema>
        
C.3.4. DSRL Schema for <nc:get> Reply
C.3.4. <nc:get>回复的DSRL架构
   <?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>
        
   <?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>
        
     <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>
        

Author's Address

作者地址

Ladislav Lhotka (editor) CESNET

拉迪斯拉夫·洛特卡(编辑)CESNET

   EMail: lhotka@cesnet.cz
        
   EMail: lhotka@cesnet.cz