Internet Engineering Task Force (IETF)                 M. Bjorklund, Ed.
Request for Comments: 7950                                Tail-f Systems
Category: Standards Track                                    August 2016
ISSN: 2070-1721
        
Internet Engineering Task Force (IETF)                 M. Bjorklund, Ed.
Request for Comments: 7950                                Tail-f Systems
Category: Standards Track                                    August 2016
ISSN: 2070-1721
        

The YANG 1.1 Data Modeling Language

YANG 1.1数据建模语言

Abstract

摘要

YANG is a data modeling language used to model configuration data, state data, Remote Procedure Calls, and notifications for network management protocols. This document describes the syntax and semantics of version 1.1 of the YANG language. YANG version 1.1 is a maintenance release of the YANG language, addressing ambiguities and defects in the original specification. There are a small number of backward incompatibilities from YANG version 1. This document also specifies the YANG mappings to the Network Configuration Protocol (NETCONF).

YANG是一种数据建模语言,用于为网络管理协议的配置数据、状态数据、远程过程调用和通知建模。本文档描述了YANG语言1.1版的语法和语义。YANG版本1.1是YANG语言的维护版本,解决了原始规范中的歧义和缺陷。YANG版本1中存在少量向后不兼容。本文档还指定了到网络配置协议(NETCONF)的映射。

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

本文件是互联网工程任务组(IETF)的产品。它代表了IETF社区的共识。它已经接受了公众审查,并已被互联网工程指导小组(IESG)批准出版。有关互联网标准的更多信息,请参见RFC 7841第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/rfc7950.

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

Copyright Notice

版权公告

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

版权所有(c)2016 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许可证中所述的无担保。

This document may contain material from IETF Documents or IETF Contributions published or made publicly available before November 10, 2008. The person(s) controlling the copyright in some of this material may not have granted the IETF Trust the right to allow modifications of such material outside the IETF Standards Process. Without obtaining an adequate license from the person(s) controlling the copyright in such materials, this document may not be modified outside the IETF Standards Process, and derivative works of it may not be created outside the IETF Standards Process, except to format it for publication as an RFC or to translate it into languages other than English.

本文件可能包含2008年11月10日之前发布或公开的IETF文件或IETF贡献中的材料。控制某些材料版权的人员可能未授予IETF信托允许在IETF标准流程之外修改此类材料的权利。在未从控制此类材料版权的人员处获得充分许可的情况下,不得在IETF标准流程之外修改本文件,也不得在IETF标准流程之外创建其衍生作品,除了将其格式化以RFC形式发布或将其翻译成英语以外的其他语言。

Table of Contents

目录

   1. Introduction ....................................................9
      1.1. Summary of Changes from RFC 6020 ..........................10
   2. Key Words ......................................................12
   3. Terminology ....................................................12
      3.1. A Note on Examples ........................................16
   4. YANG Overview ..................................................16
      4.1. Functional Overview .......................................16
      4.2. Language Overview .........................................18
           4.2.1. Modules and Submodules .............................18
           4.2.2. Data Modeling Basics ...............................19
           4.2.3. Configuration and State Data .......................23
           4.2.4. Built-In Types .....................................24
           4.2.5. Derived Types (typedef) ............................25
           4.2.6. Reusable Node Groups (grouping) ....................25
           4.2.7. Choices ............................................27
           4.2.8. Extending Data Models (augment) ....................28
           4.2.9. Operation Definitions ..............................29
           4.2.10. Notification Definitions ..........................31
   5. Language Concepts ..............................................32
      5.1. Modules and Submodules ....................................32
           5.1.1. Import and Include by Revision .....................33
           5.1.2. Module Hierarchies .................................34
      5.2. File Layout ...............................................36
      5.3. XML Namespaces ............................................36
           5.3.1. YANG XML Namespace .................................36
      5.4. Resolving Grouping, Type, and Identity Names ..............37
      5.5. Nested Typedefs and Groupings .............................37
      5.6. Conformance ...............................................38
           5.6.1. Basic Behavior .....................................38
           5.6.2. Optional Features ..................................38
           5.6.3. Deviations .........................................39
           5.6.4. Announcing Conformance Information in NETCONF ......40
           5.6.5. Implementing a Module ..............................40
      5.7. Datastore Modification ....................................44
   6. YANG Syntax ....................................................44
      6.1. Lexical Tokenization ......................................45
           6.1.1. Comments ...........................................45
           6.1.2. Tokens .............................................45
           6.1.3. Quoting ............................................45
      6.2. Identifiers ...............................................47
           6.2.1. Identifiers and Their Namespaces ...................47
      6.3. Statements ................................................48
           6.3.1. Language Extensions ................................48
      6.4. XPath Evaluations .........................................49
           6.4.1. XPath Context ......................................50
      6.5. Schema Node Identifier ....................................54
        
   1. Introduction ....................................................9
      1.1. Summary of Changes from RFC 6020 ..........................10
   2. Key Words ......................................................12
   3. Terminology ....................................................12
      3.1. A Note on Examples ........................................16
   4. YANG Overview ..................................................16
      4.1. Functional Overview .......................................16
      4.2. Language Overview .........................................18
           4.2.1. Modules and Submodules .............................18
           4.2.2. Data Modeling Basics ...............................19
           4.2.3. Configuration and State Data .......................23
           4.2.4. Built-In Types .....................................24
           4.2.5. Derived Types (typedef) ............................25
           4.2.6. Reusable Node Groups (grouping) ....................25
           4.2.7. Choices ............................................27
           4.2.8. Extending Data Models (augment) ....................28
           4.2.9. Operation Definitions ..............................29
           4.2.10. Notification Definitions ..........................31
   5. Language Concepts ..............................................32
      5.1. Modules and Submodules ....................................32
           5.1.1. Import and Include by Revision .....................33
           5.1.2. Module Hierarchies .................................34
      5.2. File Layout ...............................................36
      5.3. XML Namespaces ............................................36
           5.3.1. YANG XML Namespace .................................36
      5.4. Resolving Grouping, Type, and Identity Names ..............37
      5.5. Nested Typedefs and Groupings .............................37
      5.6. Conformance ...............................................38
           5.6.1. Basic Behavior .....................................38
           5.6.2. Optional Features ..................................38
           5.6.3. Deviations .........................................39
           5.6.4. Announcing Conformance Information in NETCONF ......40
           5.6.5. Implementing a Module ..............................40
      5.7. Datastore Modification ....................................44
   6. YANG Syntax ....................................................44
      6.1. Lexical Tokenization ......................................45
           6.1.1. Comments ...........................................45
           6.1.2. Tokens .............................................45
           6.1.3. Quoting ............................................45
      6.2. Identifiers ...............................................47
           6.2.1. Identifiers and Their Namespaces ...................47
      6.3. Statements ................................................48
           6.3.1. Language Extensions ................................48
      6.4. XPath Evaluations .........................................49
           6.4.1. XPath Context ......................................50
      6.5. Schema Node Identifier ....................................54
        
   7. YANG Statements ................................................55
      7.1. The "module" Statement ....................................55
           7.1.1. The module's Substatements .........................56
           7.1.2. The "yang-version" Statement .......................57
           7.1.3. The "namespace" Statement ..........................57
           7.1.4. The "prefix" Statement .............................57
           7.1.5. The "import" Statement .............................58
           7.1.6. The "include" Statement ............................59
           7.1.7. The "organization" Statement .......................60
           7.1.8. The "contact" Statement ............................60
           7.1.9. The "revision" Statement ...........................60
           7.1.10. Usage Example .....................................61
      7.2. The "submodule" Statement .................................62
           7.2.1. The submodule's Substatements ......................63
           7.2.2. The "belongs-to" Statement .........................63
           7.2.3. Usage Example ......................................64
      7.3. The "typedef" Statement ...................................65
           7.3.1. The typedef's Substatements ........................65
           7.3.2. The typedef's "type" Statement .....................65
           7.3.3. The "units" Statement ..............................65
           7.3.4. The typedef's "default" Statement ..................66
           7.3.5. Usage Example ......................................66
      7.4. The "type" Statement ......................................66
           7.4.1. The type's Substatements ...........................67
      7.5. The "container" Statement .................................67
           7.5.1. Containers with Presence ...........................67
           7.5.2. The container's Substatements ......................68
           7.5.3. The "must" Statement ...............................69
           7.5.4. The must's Substatements ...........................70
           7.5.5. The "presence" Statement ...........................71
           7.5.6. The container's Child Node Statements ..............71
           7.5.7. XML Encoding Rules .................................71
           7.5.8. NETCONF <edit-config> Operations ...................72
           7.5.9. Usage Example ......................................72
      7.6. The "leaf" Statement ......................................73
           7.6.1. The leaf's Default Value ...........................74
           7.6.2. The leaf's Substatements ...........................75
           7.6.3. The leaf's "type" Statement ........................75
           7.6.4. The leaf's "default" Statement .....................75
           7.6.5. The leaf's "mandatory" Statement ...................76
           7.6.6. XML Encoding Rules .................................76
           7.6.7. NETCONF <edit-config> Operations ...................76
           7.6.8. Usage Example ......................................77
      7.7. The "leaf-list" Statement .................................77
           7.7.1. Ordering ...........................................78
           7.7.2. The leaf-list's Default Values .....................79
           7.7.3. The leaf-list's Substatements ......................80
           7.7.4. The leaf-list's "default" Statement ................80
        
   7. YANG Statements ................................................55
      7.1. The "module" Statement ....................................55
           7.1.1. The module's Substatements .........................56
           7.1.2. The "yang-version" Statement .......................57
           7.1.3. The "namespace" Statement ..........................57
           7.1.4. The "prefix" Statement .............................57
           7.1.5. The "import" Statement .............................58
           7.1.6. The "include" Statement ............................59
           7.1.7. The "organization" Statement .......................60
           7.1.8. The "contact" Statement ............................60
           7.1.9. The "revision" Statement ...........................60
           7.1.10. Usage Example .....................................61
      7.2. The "submodule" Statement .................................62
           7.2.1. The submodule's Substatements ......................63
           7.2.2. The "belongs-to" Statement .........................63
           7.2.3. Usage Example ......................................64
      7.3. The "typedef" Statement ...................................65
           7.3.1. The typedef's Substatements ........................65
           7.3.2. The typedef's "type" Statement .....................65
           7.3.3. The "units" Statement ..............................65
           7.3.4. The typedef's "default" Statement ..................66
           7.3.5. Usage Example ......................................66
      7.4. The "type" Statement ......................................66
           7.4.1. The type's Substatements ...........................67
      7.5. The "container" Statement .................................67
           7.5.1. Containers with Presence ...........................67
           7.5.2. The container's Substatements ......................68
           7.5.3. The "must" Statement ...............................69
           7.5.4. The must's Substatements ...........................70
           7.5.5. The "presence" Statement ...........................71
           7.5.6. The container's Child Node Statements ..............71
           7.5.7. XML Encoding Rules .................................71
           7.5.8. NETCONF <edit-config> Operations ...................72
           7.5.9. Usage Example ......................................72
      7.6. The "leaf" Statement ......................................73
           7.6.1. The leaf's Default Value ...........................74
           7.6.2. The leaf's Substatements ...........................75
           7.6.3. The leaf's "type" Statement ........................75
           7.6.4. The leaf's "default" Statement .....................75
           7.6.5. The leaf's "mandatory" Statement ...................76
           7.6.6. XML Encoding Rules .................................76
           7.6.7. NETCONF <edit-config> Operations ...................76
           7.6.8. Usage Example ......................................77
      7.7. The "leaf-list" Statement .................................77
           7.7.1. Ordering ...........................................78
           7.7.2. The leaf-list's Default Values .....................79
           7.7.3. The leaf-list's Substatements ......................80
           7.7.4. The leaf-list's "default" Statement ................80
        
           7.7.5. The "min-elements" Statement .......................80
           7.7.6. The "max-elements" Statement .......................81
           7.7.7. The "ordered-by" Statement .........................81
           7.7.8. XML Encoding Rules .................................82
           7.7.9. NETCONF <edit-config> Operations ...................82
           7.7.10. Usage Example .....................................83
      7.8. The "list" Statement ......................................84
           7.8.1. The list's Substatements ...........................85
           7.8.2. The list's "key" Statement .........................85
           7.8.3. The list's "unique" Statement ......................86
           7.8.4. The list's Child Node Statements ...................87
           7.8.5. XML Encoding Rules .................................88
           7.8.6. NETCONF <edit-config> Operations ...................88
           7.8.7. Usage Example ......................................90
      7.9. The "choice" Statement ....................................93
           7.9.1. The choice's Substatements .........................94
           7.9.2. The choice's "case" Statement ......................94
           7.9.3. The choice's "default" Statement ...................96
           7.9.4. The choice's "mandatory" Statement .................98
           7.9.5. XML Encoding Rules .................................98
           7.9.6. Usage Example ......................................99
      7.10. The "anydata" Statement .................................100
           7.10.1. The anydata's Substatements ......................100
           7.10.2. XML Encoding Rules ...............................101
           7.10.3. NETCONF <edit-config> Operations .................101
           7.10.4. Usage Example ....................................101
      7.11. The "anyxml" Statement ..................................102
           7.11.1. The anyxml's Substatements .......................103
           7.11.2. XML Encoding Rules ...............................103
           7.11.3. NETCONF <edit-config> Operations .................103
           7.11.4. Usage Example ....................................104
      7.12. The "grouping" Statement ................................104
           7.12.1. The grouping's Substatements .....................105
           7.12.2. Usage Example ....................................105
      7.13. The "uses" Statement ....................................106
           7.13.1. The uses's Substatements .........................106
           7.13.2. The "refine" Statement ...........................106
           7.13.3. XML Encoding Rules ...............................107
           7.13.4. Usage Example ....................................107
      7.14. The "rpc" Statement .....................................108
           7.14.1. The rpc's Substatements ..........................109
           7.14.2. The "input" Statement ............................109
           7.14.3. The "output" Statement ...........................110
           7.14.4. NETCONF XML Encoding Rules .......................111
           7.14.5. Usage Example ....................................112
        
           7.7.5. The "min-elements" Statement .......................80
           7.7.6. The "max-elements" Statement .......................81
           7.7.7. The "ordered-by" Statement .........................81
           7.7.8. XML Encoding Rules .................................82
           7.7.9. NETCONF <edit-config> Operations ...................82
           7.7.10. Usage Example .....................................83
      7.8. The "list" Statement ......................................84
           7.8.1. The list's Substatements ...........................85
           7.8.2. The list's "key" Statement .........................85
           7.8.3. The list's "unique" Statement ......................86
           7.8.4. The list's Child Node Statements ...................87
           7.8.5. XML Encoding Rules .................................88
           7.8.6. NETCONF <edit-config> Operations ...................88
           7.8.7. Usage Example ......................................90
      7.9. The "choice" Statement ....................................93
           7.9.1. The choice's Substatements .........................94
           7.9.2. The choice's "case" Statement ......................94
           7.9.3. The choice's "default" Statement ...................96
           7.9.4. The choice's "mandatory" Statement .................98
           7.9.5. XML Encoding Rules .................................98
           7.9.6. Usage Example ......................................99
      7.10. The "anydata" Statement .................................100
           7.10.1. The anydata's Substatements ......................100
           7.10.2. XML Encoding Rules ...............................101
           7.10.3. NETCONF <edit-config> Operations .................101
           7.10.4. Usage Example ....................................101
      7.11. The "anyxml" Statement ..................................102
           7.11.1. The anyxml's Substatements .......................103
           7.11.2. XML Encoding Rules ...............................103
           7.11.3. NETCONF <edit-config> Operations .................103
           7.11.4. Usage Example ....................................104
      7.12. The "grouping" Statement ................................104
           7.12.1. The grouping's Substatements .....................105
           7.12.2. Usage Example ....................................105
      7.13. The "uses" Statement ....................................106
           7.13.1. The uses's Substatements .........................106
           7.13.2. The "refine" Statement ...........................106
           7.13.3. XML Encoding Rules ...............................107
           7.13.4. Usage Example ....................................107
      7.14. The "rpc" Statement .....................................108
           7.14.1. The rpc's Substatements ..........................109
           7.14.2. The "input" Statement ............................109
           7.14.3. The "output" Statement ...........................110
           7.14.4. NETCONF XML Encoding Rules .......................111
           7.14.5. Usage Example ....................................112
        
      7.15. The "action" Statement ..................................113
           7.15.1. The action's Substatements .......................114
           7.15.2. NETCONF XML Encoding Rules .......................114
           7.15.3. Usage Example ....................................115
      7.16. The "notification" Statement ............................116
           7.16.1. The notification's Substatements .................117
           7.16.2. NETCONF XML Encoding Rules .......................117
           7.16.3. Usage Example ....................................118
      7.17. The "augment" Statement .................................119
           7.17.1. The augment's Substatements ......................121
           7.17.2. XML Encoding Rules ...............................121
           7.17.3. Usage Example ....................................122
      7.18. The "identity" Statement ................................124
           7.18.1. The identity's Substatements .....................124
           7.18.2. The "base" Statement .............................124
           7.18.3. Usage Example ....................................125
      7.19. The "extension" Statement ...............................126
           7.19.1. The extension's Substatements ....................126
           7.19.2. The "argument" Statement .........................127
           7.19.3. Usage Example ....................................127
      7.20. Conformance-Related Statements ..........................128
           7.20.1. The "feature" Statement ..........................128
           7.20.2. The "if-feature" Statement .......................130
           7.20.3. The "deviation" Statement ........................131
      7.21. Common Statements .......................................134
           7.21.1. The "config" Statement ...........................134
           7.21.2. The "status" Statement ...........................135
           7.21.3. The "description" Statement ......................136
           7.21.4. The "reference" Statement ........................136
           7.21.5. The "when" Statement .............................136
   8. Constraints ...................................................138
      8.1. Constraints on Data ......................................138
      8.2. Configuration Data Modifications .........................139
      8.3. NETCONF Constraint Enforcement Model .....................139
           8.3.1. Payload Parsing ...................................139
           8.3.2. NETCONF <edit-config> Processing ..................140
           8.3.3. Validation ........................................141
   9. Built-In Types ................................................141
      9.1. Canonical Representation .................................141
      9.2. The Integer Built-In Types ...............................142
           9.2.1. Lexical Representation ............................142
           9.2.2. Canonical Form ....................................143
           9.2.3. Restrictions ......................................143
           9.2.4. The "range" Statement .............................143
           9.2.5. Usage Example .....................................144
        
      7.15. The "action" Statement ..................................113
           7.15.1. The action's Substatements .......................114
           7.15.2. NETCONF XML Encoding Rules .......................114
           7.15.3. Usage Example ....................................115
      7.16. The "notification" Statement ............................116
           7.16.1. The notification's Substatements .................117
           7.16.2. NETCONF XML Encoding Rules .......................117
           7.16.3. Usage Example ....................................118
      7.17. The "augment" Statement .................................119
           7.17.1. The augment's Substatements ......................121
           7.17.2. XML Encoding Rules ...............................121
           7.17.3. Usage Example ....................................122
      7.18. The "identity" Statement ................................124
           7.18.1. The identity's Substatements .....................124
           7.18.2. The "base" Statement .............................124
           7.18.3. Usage Example ....................................125
      7.19. The "extension" Statement ...............................126
           7.19.1. The extension's Substatements ....................126
           7.19.2. The "argument" Statement .........................127
           7.19.3. Usage Example ....................................127
      7.20. Conformance-Related Statements ..........................128
           7.20.1. The "feature" Statement ..........................128
           7.20.2. The "if-feature" Statement .......................130
           7.20.3. The "deviation" Statement ........................131
      7.21. Common Statements .......................................134
           7.21.1. The "config" Statement ...........................134
           7.21.2. The "status" Statement ...........................135
           7.21.3. The "description" Statement ......................136
           7.21.4. The "reference" Statement ........................136
           7.21.5. The "when" Statement .............................136
   8. Constraints ...................................................138
      8.1. Constraints on Data ......................................138
      8.2. Configuration Data Modifications .........................139
      8.3. NETCONF Constraint Enforcement Model .....................139
           8.3.1. Payload Parsing ...................................139
           8.3.2. NETCONF <edit-config> Processing ..................140
           8.3.3. Validation ........................................141
   9. Built-In Types ................................................141
      9.1. Canonical Representation .................................141
      9.2. The Integer Built-In Types ...............................142
           9.2.1. Lexical Representation ............................142
           9.2.2. Canonical Form ....................................143
           9.2.3. Restrictions ......................................143
           9.2.4. The "range" Statement .............................143
           9.2.5. Usage Example .....................................144
        
      9.3. The decimal64 Built-In Type ..............................144
           9.3.1. Lexical Representation ............................145
           9.3.2. Canonical Form ....................................145
           9.3.3. Restrictions ......................................145
           9.3.4. The "fraction-digits" Statement ...................145
           9.3.5. Usage Example .....................................146
      9.4. The string Built-In Type .................................146
           9.4.1. Lexical Representation ............................146
           9.4.2. Canonical Form ....................................147
           9.4.3. Restrictions ......................................147
           9.4.4. The "length" Statement ............................147
           9.4.5. The "pattern" Statement ...........................148
           9.4.6. The "modifier" Statement ..........................148
           9.4.7. Usage Example .....................................149
      9.5. The boolean Built-In Type ................................150
           9.5.1. Lexical Representation ............................150
           9.5.2. Canonical Form ....................................150
           9.5.3. Restrictions ......................................150
      9.6. The enumeration Built-In Type ............................150
           9.6.1. Lexical Representation ............................150
           9.6.2. Canonical Form ....................................151
           9.6.3. Restrictions ......................................151
           9.6.4. The "enum" Statement ..............................151
           9.6.5. Usage Example .....................................152
      9.7. The bits Built-In Type ...................................154
           9.7.1. Restrictions ......................................154
           9.7.2. Lexical Representation ............................154
           9.7.3. Canonical Form ....................................154
           9.7.4. The "bit" Statement ...............................155
           9.7.5. Usage Example .....................................156
      9.8. The binary Built-In Type .................................157
           9.8.1. Restrictions ......................................157
           9.8.2. Lexical Representation ............................157
           9.8.3. Canonical Form ....................................157
      9.9. The leafref Built-In Type ................................157
           9.9.1. Restrictions ......................................158
           9.9.2. The "path" Statement ..............................158
           9.9.3. The "require-instance" Statement ..................159
           9.9.4. Lexical Representation ............................159
           9.9.5. Canonical Form ....................................159
           9.9.6. Usage Example .....................................159
      9.10. The identityref Built-In Type ...........................163
           9.10.1. Restrictions .....................................163
           9.10.2. The identityref's "base" Statement ...............163
           9.10.3. Lexical Representation ...........................163
           9.10.4. Canonical Form ...................................164
           9.10.5. Usage Example ....................................164
        
      9.3. The decimal64 Built-In Type ..............................144
           9.3.1. Lexical Representation ............................145
           9.3.2. Canonical Form ....................................145
           9.3.3. Restrictions ......................................145
           9.3.4. The "fraction-digits" Statement ...................145
           9.3.5. Usage Example .....................................146
      9.4. The string Built-In Type .................................146
           9.4.1. Lexical Representation ............................146
           9.4.2. Canonical Form ....................................147
           9.4.3. Restrictions ......................................147
           9.4.4. The "length" Statement ............................147
           9.4.5. The "pattern" Statement ...........................148
           9.4.6. The "modifier" Statement ..........................148
           9.4.7. Usage Example .....................................149
      9.5. The boolean Built-In Type ................................150
           9.5.1. Lexical Representation ............................150
           9.5.2. Canonical Form ....................................150
           9.5.3. Restrictions ......................................150
      9.6. The enumeration Built-In Type ............................150
           9.6.1. Lexical Representation ............................150
           9.6.2. Canonical Form ....................................151
           9.6.3. Restrictions ......................................151
           9.6.4. The "enum" Statement ..............................151
           9.6.5. Usage Example .....................................152
      9.7. The bits Built-In Type ...................................154
           9.7.1. Restrictions ......................................154
           9.7.2. Lexical Representation ............................154
           9.7.3. Canonical Form ....................................154
           9.7.4. The "bit" Statement ...............................155
           9.7.5. Usage Example .....................................156
      9.8. The binary Built-In Type .................................157
           9.8.1. Restrictions ......................................157
           9.8.2. Lexical Representation ............................157
           9.8.3. Canonical Form ....................................157
      9.9. The leafref Built-In Type ................................157
           9.9.1. Restrictions ......................................158
           9.9.2. The "path" Statement ..............................158
           9.9.3. The "require-instance" Statement ..................159
           9.9.4. Lexical Representation ............................159
           9.9.5. Canonical Form ....................................159
           9.9.6. Usage Example .....................................159
      9.10. The identityref Built-In Type ...........................163
           9.10.1. Restrictions .....................................163
           9.10.2. The identityref's "base" Statement ...............163
           9.10.3. Lexical Representation ...........................163
           9.10.4. Canonical Form ...................................164
           9.10.5. Usage Example ....................................164
        
      9.11. The empty Built-In Type .................................165
           9.11.1. Restrictions .....................................165
           9.11.2. Lexical Representation ...........................165
           9.11.3. Canonical Form ...................................165
           9.11.4. Usage Example ....................................166
      9.12. The union Built-In Type .................................166
           9.12.1. Restrictions .....................................166
           9.12.2. Lexical Representation ...........................166
           9.12.3. Canonical Form ...................................167
           9.12.4. Usage Example ....................................167
      9.13. The instance-identifier Built-In Type ...................168
           9.13.1. Restrictions .....................................168
           9.13.2. Lexical Representation ...........................169
           9.13.3. Canonical Form ...................................169
           9.13.4. Usage Example ....................................169
   10. XPath Functions ..............................................170
      10.1. Function for Node Sets ..................................170
           10.1.1. current() ........................................170
      10.2. Function for Strings ....................................170
           10.2.1. re-match() .......................................170
      10.3. Function for the YANG Types "leafref" and
            "instance-identifier" ...................................171
           10.3.1. deref() ..........................................171
      10.4. Functions for the YANG Type "identityref" ...............172
           10.4.1. derived-from() ...................................172
           10.4.2. derived-from-or-self() ...........................174
      10.5. Function for the YANG Type "enumeration" ................174
           10.5.1. enum-value() .....................................174
      10.6. Function for the YANG Type "bits" .......................175
           10.6.1. bit-is-set() .....................................175
   11. Updating a Module ............................................176
   12. Coexistence with YANG Version 1 ..............................179
   13. YIN ..........................................................179
      13.1. Formal YIN Definition ...................................180
           13.1.1. Usage Example ....................................182
   14. YANG ABNF Grammar ............................................184
   15. NETCONF Error Responses for YANG-Related Errors ..............211
      15.1. Error Message for Data That Violates a "unique"
            Statement ...............................................211
      15.2. Error Message for Data That Violates a
            "max-elements" Statement ................................211
      15.3. Error Message for Data That Violates a
            "min-elements" Statement ................................211
      15.4. Error Message for Data That Violates a "must"
            Statement ...............................................212
      15.5. Error Message for Data That Violates a
            "require-instance" Statement ............................212
        
      9.11. The empty Built-In Type .................................165
           9.11.1. Restrictions .....................................165
           9.11.2. Lexical Representation ...........................165
           9.11.3. Canonical Form ...................................165
           9.11.4. Usage Example ....................................166
      9.12. The union Built-In Type .................................166
           9.12.1. Restrictions .....................................166
           9.12.2. Lexical Representation ...........................166
           9.12.3. Canonical Form ...................................167
           9.12.4. Usage Example ....................................167
      9.13. The instance-identifier Built-In Type ...................168
           9.13.1. Restrictions .....................................168
           9.13.2. Lexical Representation ...........................169
           9.13.3. Canonical Form ...................................169
           9.13.4. Usage Example ....................................169
   10. XPath Functions ..............................................170
      10.1. Function for Node Sets ..................................170
           10.1.1. current() ........................................170
      10.2. Function for Strings ....................................170
           10.2.1. re-match() .......................................170
      10.3. Function for the YANG Types "leafref" and
            "instance-identifier" ...................................171
           10.3.1. deref() ..........................................171
      10.4. Functions for the YANG Type "identityref" ...............172
           10.4.1. derived-from() ...................................172
           10.4.2. derived-from-or-self() ...........................174
      10.5. Function for the YANG Type "enumeration" ................174
           10.5.1. enum-value() .....................................174
      10.6. Function for the YANG Type "bits" .......................175
           10.6.1. bit-is-set() .....................................175
   11. Updating a Module ............................................176
   12. Coexistence with YANG Version 1 ..............................179
   13. YIN ..........................................................179
      13.1. Formal YIN Definition ...................................180
           13.1.1. Usage Example ....................................182
   14. YANG ABNF Grammar ............................................184
   15. NETCONF Error Responses for YANG-Related Errors ..............211
      15.1. Error Message for Data That Violates a "unique"
            Statement ...............................................211
      15.2. Error Message for Data That Violates a
            "max-elements" Statement ................................211
      15.3. Error Message for Data That Violates a
            "min-elements" Statement ................................211
      15.4. Error Message for Data That Violates a "must"
            Statement ...............................................212
      15.5. Error Message for Data That Violates a
            "require-instance" Statement ............................212
        
      15.6. Error Message for Data That Violates a Mandatory
            "choice" Statement ......................................212
      15.7. Error Message for the "insert" Operation ................212
   16. IANA Considerations ..........................................213
   17. Security Considerations ......................................213
   18. References ...................................................214
      18.1. Normative References ....................................214
      18.2. Informative References ..................................215
   Acknowledgements .................................................217
   Contributors .....................................................217
   Author's Address .................................................217
        
      15.6. Error Message for Data That Violates a Mandatory
            "choice" Statement ......................................212
      15.7. Error Message for the "insert" Operation ................212
   16. IANA Considerations ..........................................213
   17. Security Considerations ......................................213
   18. References ...................................................214
      18.1. Normative References ....................................214
      18.2. Informative References ..................................215
   Acknowledgements .................................................217
   Contributors .....................................................217
   Author's Address .................................................217
        
1. Introduction
1. 介绍

YANG is a data modeling language originally designed to model configuration and state data manipulated by the Network Configuration Protocol (NETCONF), NETCONF Remote Procedure Calls, and NETCONF notifications [RFC6241]. Since the publication of YANG version 1 [RFC6020], YANG has been used or proposed to be used for other protocols (e.g., RESTCONF [RESTCONF] and the Constrained Application Protocol (CoAP) Management Interface (CoMI) [CoMI]). Further, encodings other than XML have been proposed (e.g., JSON [RFC7951]).

YANG是一种数据建模语言,最初设计用于对由网络配置协议(NETCONF)、NETCONF远程过程调用和NETCONF通知[RFC6241]操作的配置和状态数据进行建模。自YANG版本1[RFC6020]发布以来,YANG已被用于或拟用于其他协议(例如RESTCONF[RESTCONF]和受限应用协议(CoAP)管理接口(CoMI)[CoMI])。此外,还提出了XML以外的编码(例如,JSON[RFC7951])。

This document describes the syntax and semantics of version 1.1 of the YANG language. It also describes how a data model defined in a YANG module is encoded in the Extensible Markup Language (XML) [XML] and how NETCONF operations are used to manipulate the data. Other protocols and encodings are possible but are out of scope for this specification.

本文档描述了YANG语言1.1版的语法和语义。它还描述了如何用可扩展标记语言(XML)[XML]对模块中定义的数据模型进行编码,以及如何使用NETCONF操作来操作数据。其他协议和编码是可能的,但不在本规范的范围内。

In terms of developing YANG data models, [YANG-Guidelines] provides some guidelines and recommendations.

在开发YANG数据模型方面,[YANG指南]提供了一些指南和建议。

Note that this document does not obsolete RFC 6020 [RFC6020].

请注意,本文件并未废除RFC 6020[RFC6020]。

1.1. Summary of Changes from RFC 6020
1.1. RFC 6020变更汇总表

This document defines version 1.1 of the YANG language. YANG version 1.1 is a maintenance release of the YANG language, addressing ambiguities and defects in the original specification [RFC6020].

本文件定义了YANG语言的1.1版。YANG版本1.1是YANG语言的维护版本,解决了原始规范[RFC6020]中的歧义和缺陷。

The following changes are not backward compatible with YANG version 1:

以下更改与YANG版本1不向后兼容:

o Changed the rules for the interpretation of escaped characters in double-quoted strings. This is a backward-incompatible change from YANG version 1. When updating a YANG version 1 module to 1.1 and the module uses a character sequence that is now illegal, the string must be changed to match the new rules. See Section 6.1.3 for details.

o 更改了双引号字符串中转义字符的解释规则。这是对YANG版本1的向后不兼容更改。当将版本1模块更新为1.1并且模块使用的字符序列现在是非法的时,必须更改字符串以匹配新规则。详见第6.1.3节。

o An unquoted string cannot contain any single or double quote characters. This is a backward-incompatible change from YANG version 1. When updating a YANG version 1 module to 1.1 and the module uses such quote characters, the string must be changed to match the new rules. See Section 6.1.3 for details.

o 未加引号的字符串不能包含任何单引号或双引号字符。这是对YANG版本1的向后不兼容更改。将第1版模块更新为1.1版时,如果模块使用此类引号字符,则必须更改字符串以匹配新规则。详见第6.1.3节。

o Made "when" and "if-feature" illegal on list keys. This is a backward-incompatible change from YANG version 1. When updating a YANG version 1 module to 1.1 and the module uses these constructs, they must be removed to match the new rules.

o 使列表键上的“何时”和“如果”功能非法。这是对YANG版本1的向后不兼容更改。将第1版模块更新为1.1版并且模块使用这些结构时,必须删除这些结构以匹配新规则。

o Defined the legal characters in YANG modules. When updating a YANG version 1 module to 1.1, any characters that are now illegal must be removed. See Section 6 for details.

o 定义了杨模块中的法律特征。将1版模块更新为1.1时,必须删除所有现在非法的字符。详见第6节。

o Made noncharacters illegal in the built-in type "string". This change affects the runtime behavior of YANG-based protocols.

o 使内置类型“string”中的非字符非法。此更改会影响基于YANG的协议的运行时行为。

The following additional changes have been done to YANG:

对YANG进行了以下附加更改:

o Changed the YANG version from "1" to "1.1".

o 将YANG版本从“1”更改为“1.1”。

o Made the "yang-version" statement mandatory in YANG version "1.1".

o 在杨版“1.1”中强制执行“杨版”声明。

o Extended the "if-feature" syntax to be a boolean expression over feature names.

o 扩展了“if feature”语法,使其成为功能名称上的布尔表达式。

o Allow "if-feature" in "bit", "enum", and "identity".

o 允许在“位”、“枚举”和“标识”中使用“如果特征”。

o Allow "if-feature" in "refine".

o 在“优化”中允许“如果特征”。

o Allow "choice" as a shorthand "case" statement (see Section 7.9.2).

o 允许“选择”作为简写的“案例”陈述(见第7.9.2节)。

o Added a new substatement "modifier" to the "pattern" statement (see Section 9.4.6).

o 在“模式”语句中添加了新的子语句“修饰符”(见第9.4.6节)。

o Allow "must" in "input", "output", and "notification".

o 在“输入”、“输出”和“通知”中允许“必须”。

o Allow "require-instance" in leafref.

o 允许在leafref中使用“require instance”。

o Allow "description" and "reference" in "import" and "include".

o 在“导入”和“包含”中允许“说明”和“引用”。

o Allow imports of multiple revisions of a module.

o 允许导入模块的多个修订版。

o Allow "augment" to add conditionally mandatory nodes (see Section 7.17).

o 允许“增强”添加有条件的强制性节点(见第7.17节)。

o Added a set of new XML Path Language (XPath) functions in Section 10.

o 在第10节中添加了一组新的XML路径语言(XPath)函数。

o Clarified the XPath context's tree in Section 6.4.1.

o 在第6.4.1节中阐明了XPath上下文的树。

o Defined the string value of an identityref in XPath expressions (see Section 9.10).

o 在XPath表达式中定义identityref的字符串值(请参见第9.10节)。

o Clarified what unprefixed names mean in leafrefs in typedefs (see Sections 6.4.1 and 9.9.2).

o 阐明typedefs中leafrefs中未固定名称的含义(见第6.4.1节和第9.9.2节)。

o Allow identities to be derived from multiple base identities (see Sections 7.18 and 9.10).

o 允许从多个基本标识派生标识(见第7.18节和第9.10节)。

o Allow enumerations and bits to be subtyped (see Sections 9.6 and 9.7).

o 允许对枚举和位进行子类型化(参见第9.6节和第9.7节)。

o Allow leaf-lists to have default values (see Section 7.7.2).

o 允许叶列表具有默认值(见第7.7.2节)。

o Allow non-unique values in non-configuration leaf-lists (see Section 7.7).

o 在非配置叶列表中允许非唯一值(见第7.7节)。

o Use syntax for case-sensitive strings (as per [RFC7405]) in the grammar.

o 语法中区分大小写的字符串使用语法(按照[RFC7405])。

o Changed the module advertisement mechanism (see Section 5.6.4).

o 更改了模块广告机制(见第5.6.4节)。

o Changed the scoping rules for definitions in submodules. A submodule can now reference all definitions in all submodules that belong to the same module, without using the "include" statement.

o 更改了子模块中定义的作用域规则。子模块现在可以引用属于同一模块的所有子模块中的所有定义,而无需使用“include”语句。

o Added a new statement "action", which is used to define operations tied to data nodes.

o 添加了一个新语句“action”,用于定义绑定到数据节点的操作。

o Allow notifications to be tied to data nodes.

o 允许将通知绑定到数据节点。

o Added a new data definition statement "anydata" (see Section 7.10), which is RECOMMENDED to be used instead of "anyxml" when the data can be modeled in YANG.

o 添加了一个新的数据定义语句“anydata”(参见第7.10节),建议在数据可以用XML建模时使用该语句代替“anyxml”。

o Allow types "empty" and "leafref" in unions.

o 允许在联合中使用类型“empty”和“leafref”。

o Allow type "empty" in a key.

o 允许在键中键入“empty”。

o Removed the restriction that identifiers could not start with the characters "xml".

o 删除了标识符不能以字符“xml”开头的限制。

The following changes have been done to the NETCONF mapping:

对NETCONF映射进行了以下更改:

o A server advertises support for YANG 1.1 modules by using ietf-yang-library [RFC7895] instead of listing them as capabilities in the <hello> message.

o 服务器通过使用ietf YANG library[RFC7895]而不是在<hello>消息中将其作为功能列出,来宣传对YANG 1.1模块的支持。

2. Key Words
2. 关键词

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119].

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

3. Terminology
3. 术语

The following terms are used within this document:

本文件中使用了以下术语:

o action: An operation defined for a node in the data tree.

o 操作:为数据树中的节点定义的操作。

o anydata: A data node that can contain an unknown set of nodes that can be modeled by YANG, except anyxml.

o anydata:一个数据节点,可以包含一组未知的节点,这些节点可以由YANG建模,anyxml除外。

o anyxml: A data node that can contain an unknown chunk of XML data.

o anyxml:可以包含未知XML数据块的数据节点。

o augment: Adds new schema nodes to a previously defined schema node.

o 扩充:将新架构节点添加到先前定义的架构节点。

o base type: The type from which a derived type was derived, which may be either a built-in type or another derived type.

o 基类型:派生类型的派生类型,可以是内置类型或其他派生类型。

o built-in type: A YANG data type defined in the YANG language, such as uint32 or string.

o 内置类型:用YANG语言定义的YANG数据类型,如uint32或字符串。

o choice: A schema node where only one of a number of identified alternatives is valid.

o 选择:一个模式节点,其中许多已识别的备选方案中只有一个是有效的。

o client: An entity that can access YANG-defined data on a server, over some network management protocol.

o 客户机:可以通过某种网络管理协议访问服务器上定义的数据的实体。

o conformance: A measure of how accurately a server follows a data model.

o 一致性:衡量服务器遵循数据模型的准确程度。

o container: An interior data node that exists in at most one instance in the data tree. A container has no value, but rather a set of child nodes.

o 容器:数据树中最多存在一个实例的内部数据节点。容器没有值,而是一组子节点。

o data definition statement: A statement that defines new data nodes. One of "container", "leaf", "leaf-list", "list", "choice", "case", "augment", "uses", "anydata", and "anyxml".

o 数据定义语句:定义新数据节点的语句。“容器”、“叶”、“叶列表”、“列表”、“选择”、“案例”、“扩充”、“使用”、“任意数据”和“任意XML”之一。

o data model: A data model describes how data is represented and accessed.

o 数据模型:数据模型描述如何表示和访问数据。

o data node: A node in the schema tree that can be instantiated in a data tree. One of container, leaf, leaf-list, list, anydata, and anyxml.

o 数据节点:架构树中可以在数据树中实例化的节点。容器、叶、叶列表、列表、anydata和anyxml之一。

o data tree: An instantiated tree of any data modeled with YANG, e.g., configuration data, state data, combined configuration and state data, RPC or action input, RPC or action output, or notification.

o 数据树:使用YANG建模的任何数据的实例化树,例如,配置数据、状态数据、组合配置和状态数据、RPC或操作输入、RPC或操作输出或通知。

o derived type: A type that is derived from a built-in type (such as uint32) or another derived type.

o 派生类型:从内置类型(如uint32)或其他派生类型派生的类型。

o extension: An extension attaches non-YANG semantics to statements. The "extension" statement defines new statements to express these semantics.

o 扩展:扩展将非YANG语义附加到语句。“extension”语句定义了新的语句来表达这些语义。

o feature: A mechanism for marking a portion of the model as optional. Definitions can be tagged with a feature name and are only valid on servers that support that feature.

o 特性:将模型的一部分标记为可选的机制。定义可以使用功能名称进行标记,并且仅在支持该功能的服务器上有效。

o grouping: A reusable set of schema nodes, which may be used locally in the module and by other modules that import from it. The "grouping" statement is not a data definition statement and, as such, does not define any nodes in the schema tree.

o 分组:一组可重用的模式节点,可在模块中本地使用,也可由从模块导入的其他模块使用。“grouping”语句不是数据定义语句,因此不定义模式树中的任何节点。

o identifier: A string used to identify different kinds of YANG items by name.

o 标识符:用于按名称标识不同类型项目的字符串。

o identity: A globally unique, abstract, and untyped name.

o 标识:全局唯一、抽象和非类型化的名称。

o instance identifier: A mechanism for identifying a particular node in a data tree.

o 实例标识符:用于标识数据树中特定节点的机制。

o interior node: Nodes within a hierarchy that are not leaf nodes.

o 内部节点:层次中不是叶节点的节点。

o leaf: A data node that exists in at most one instance in the data tree. A leaf has a value but no child nodes.

o 叶:数据树中最多存在一个实例的数据节点。叶有一个值,但没有子节点。

o leaf-list: Like the leaf node but defines a set of uniquely identifiable nodes rather than a single node. Each node has a value but no child nodes.

o 叶列表:与叶节点类似,但定义了一组唯一可识别的节点,而不是单个节点。每个节点都有一个值,但没有子节点。

o list: An interior data node that may exist in multiple instances in the data tree. A list has no value, but rather a set of child nodes.

o 列表:可能存在于数据树中多个实例中的内部数据节点。列表没有值,而是一组子节点。

o mandatory node: A mandatory node is one of:

o 强制节点:强制节点是以下节点之一:

* A leaf, choice, anydata, or anyxml node with a "mandatory" statement with the value "true".

* 具有值为“true”的“强制”语句的叶、选项、anydata或anyxml节点。

* A list or leaf-list node with a "min-elements" statement with a value greater than zero.

* 具有值大于零的“min elements”语句的列表或叶列表节点。

* A container node without a "presence" statement and that has at least one mandatory node as a child.

* 没有“presence”语句且至少有一个强制节点作为子节点的容器节点。

o module: A YANG module defines hierarchies of schema nodes. With its definitions and the definitions it imports or includes from elsewhere, a module is self-contained and "compilable".

o 模块:模块定义模式节点的层次结构。通过定义以及从其他地方导入或包含的定义,模块是自包含的且“可编译的”。

o non-presence container: A container that has no meaning of its own, existing only to contain child nodes.

o 非存在容器:一个没有自己意义的容器,存在只是为了包含子节点。

o presence container: A container where the presence of the container itself carries some meaning.

o 存在容器:容器本身的存在具有某种意义的容器。

o RPC: A Remote Procedure Call.

o RPC:远程过程调用。

o RPC operation: A specific Remote Procedure Call.

o RPC操作:特定的远程过程调用。

o schema node: A node in the schema tree. One of action, container, leaf, leaf-list, list, choice, case, rpc, input, output, notification, anydata, and anyxml.

o 架构节点:架构树中的节点。操作、容器、叶、叶列表、列表、选项、大小写、rpc、输入、输出、通知、anydata和anyxml之一。

o schema node identifier: A mechanism for identifying a particular node in the schema tree.

o 模式节点标识符:用于标识模式树中特定节点的机制。

o schema tree: The definition hierarchy specified within a module.

o 架构树:模块中指定的定义层次结构。

o server: An entity that provides access to YANG-defined data to a client, over some network management protocol.

o 服务器:通过某种网络管理协议向客户机提供对已定义数据的访问的实体。

o server deviation: A failure of the server to implement a module faithfully.

o 服务器偏差:服务器未能忠实地实现模块。

o submodule: A partial module definition that contributes derived types, groupings, data nodes, RPCs, actions, and notifications to a module. A YANG module can be constructed from a number of submodules.

o 子模块:向模块提供派生类型、分组、数据节点、RPC、操作和通知的部分模块定义。杨模可以由许多子模构成。

o top-level data node: A data node where there is no other data node between it and a "module" or "submodule" statement.

o 顶级数据节点:与“模块”或“子模块”语句之间没有其他数据节点的数据节点。

o uses: The "uses" statement is used to instantiate the set of schema nodes defined in a "grouping" statement. The instantiated nodes may be refined and augmented to tailor them to any specific needs.

o uses:“uses”语句用于实例化在“grouping”语句中定义的模式节点集。可以对实例化的节点进行细化和扩充,以使其适应任何特定需求。

o value space: For a data type; the set of values permitted by the data type. For a leaf or leaf-list instance; the value space of its data type.

o 值空间:用于数据类型;数据类型允许的值集。对于叶或叶列表实例;其数据类型的值空间。

The following terms are defined in [RFC6241]:

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

o configuration data

o 配置数据

o configuration datastore

o 配置数据存储

o datastore

o 数据存储

o state data

o 状态数据

When modeled with YANG, a datastore is realized as an instantiated data tree.

当使用YANG建模时,数据存储被实现为实例化的数据树。

When modeled with YANG, a configuration datastore is realized as an instantiated data tree with configuration data.

当使用YANG建模时,配置数据存储被实现为带有配置数据的实例化数据树。

3.1. A Note on Examples
3.1. 例注

Throughout this document, there are many examples of YANG statements. These examples are supposed to illustrate certain features and are not supposed to be complete, valid YANG modules.

在本文件中,有许多杨陈述的例子。这些示例旨在说明某些功能,而不是完整、有效的模块。

4. YANG Overview
4. 杨总览

This non-normative section is intended to give a high-level overview of YANG to first-time readers.

本非规范性章节旨在向初次阅读的读者提供杨的高级概述。

4.1. Functional Overview
4.1. 功能概述

YANG is a language originally designed to model data for the NETCONF protocol. A YANG module defines hierarchies of data that can be used for NETCONF-based operations, including configuration, state data, RPCs, and notifications. This allows a complete description of all data sent between a NETCONF client and server. Although out of scope for this specification, YANG can also be used with protocols other than NETCONF.

YANG是一种最初设计用于为NETCONF协议建模数据的语言。模块定义了可用于基于NETCONF的操作的数据层次结构,包括配置、状态数据、RPC和通知。这允许完整描述NETCONF客户端和服务器之间发送的所有数据。尽管超出了本规范的范围,但YANG也可用于NETCONF以外的协议。

YANG models the hierarchical organization of data as a tree in which each node has a name, and either a value or a set of child nodes. YANG provides clear and concise descriptions of the nodes, as well as the interaction between those nodes.

YANG将数据的分层组织建模为一棵树,其中每个节点都有一个名称、一个值或一组子节点。YANG对节点以及这些节点之间的交互进行了清晰简洁的描述。

YANG structures data models into modules and submodules. A module can import definitions from other external modules and can include definitions from submodules. The hierarchy can be augmented, allowing one module to add data nodes to the hierarchy defined in another module. This augmentation can be conditional, with new nodes appearing only if certain conditions are met.

YANG将数据模型分为模块和子模块。模块可以从其他外部模块导入定义,也可以包含子模块的定义。层次结构可以扩充,允许一个模块向另一个模块中定义的层次结构添加数据节点。这种扩展可以是有条件的,只有在满足某些条件时才会出现新节点。

YANG data models can describe constraints to be enforced on the data, restricting the presence or value of nodes based on the presence or value of other nodes in the hierarchy. These constraints are enforceable by either the client or the server.

YANG数据模型可以描述对数据实施的约束,根据层次结构中其他节点的存在或值限制节点的存在或值。这些约束可由客户端或服务器强制执行。

YANG defines a set of built-in types and has a type mechanism through which additional types may be defined. Derived types can restrict their base type's set of valid values using mechanisms like range or pattern restrictions that can be enforced by clients or servers. They can also define usage conventions for use of the derived type, such as a string-based type that contains a hostname.

YANG定义了一组内置类型,并具有一种类型机制,通过该机制可以定义其他类型。派生类型可以使用诸如范围或模式限制之类的机制来限制其基类型的有效值集,这些机制可以由客户端或服务器强制实施。它们还可以定义使用派生类型的使用约定,例如包含主机名的基于字符串的类型。

YANG permits the definition of reusable groupings of nodes. The usage of these groupings can refine or augment the nodes, allowing it to tailor the nodes to its particular needs. Derived types and groupings can be defined in one module and used in either the same module or another module that imports it.

YANG允许定义可重用的节点分组。这些分组的使用可以细化或扩充节点,使其能够根据特定需求定制节点。派生类型和分组可以在一个模块中定义,并在同一个模块或导入它的另一个模块中使用。

YANG data hierarchy constructs include defining lists where list entries are identified by keys that distinguish them from each other. Such lists may be defined as either sorted by user or automatically sorted by the system. For user-sorted lists, operations are defined for manipulating the order of the list entries.

数据层次结构包括定义列表,其中列表项由键标识,键将它们彼此区分开来。此类列表可定义为按用户排序或由系统自动排序。对于用户排序的列表,定义了用于操纵列表项顺序的操作。

YANG modules can be translated into an equivalent XML syntax called YANG Independent Notation (YIN) (Section 13), allowing applications using XML parsers and Extensible Stylesheet Language Transformations (XSLT) scripts to operate on the models. The conversion from YANG to YIN is semantically lossless, so content in YIN can be round-tripped back into YANG.

YANG模块可以转换为一种等价的XML语法,称为YANG独立表示法(YIN)(第13节),允许使用XML解析器和可扩展样式表语言转换(XSLT)脚本的应用程序在模型上操作。从阳到阴的转换在语义上是无损的,因此阴中的内容可以循环回到阳中。

YANG is an extensible language, allowing extensions to be defined by standards bodies, vendors, and individuals. The statement syntax allows these extensions to coexist with standard YANG statements in a natural way, while extensions in a YANG module stand out sufficiently for the reader to notice them.

YANG是一种可扩展语言,允许标准机构、供应商和个人定义扩展。语句语法允许这些扩展以一种自然的方式与标准的YANG语句共存,而YANG模块中的扩展足以让读者注意到它们。

YANG resists the tendency to solve all possible problems, limiting the problem space to allow expression of data models for network management protocols such as NETCONF, not arbitrary XML documents or arbitrary data models.

YANG抵制解决所有可能问题的趋势,限制了问题空间,以允许网络管理协议(如NETCONF)的数据模型表达,而不是任意XML文档或任意数据模型。

To the extent possible, YANG maintains compatibility with the Simple Network Management Protocol's (SNMP's) SMIv2 (Structure of Management Information version 2 [RFC2578] [RFC2579]). SMIv2-based MIB modules can be automatically translated into YANG modules for read-only access [RFC6643]. However, YANG is not concerned with reverse translation from YANG to SMIv2.

YANG尽可能保持与简单网络管理协议(SNMP)SMIv2(管理信息结构版本2[RFC2578][RFC2579])的兼容性。基于SMIv2的MIB模块可以自动转换为只读访问的模块[RFC6643]。然而,杨并不关心从杨到SMIv2的反向翻译。

4.2. Language Overview
4.2. 语言概述

This section introduces some important constructs used in YANG that will aid in the understanding of the language specifics in later sections.

本节介绍YANG中使用的一些重要结构,这些结构将有助于理解后面章节中的语言细节。

4.2.1. Modules and Submodules
4.2.1. 模与子模

YANG data models are defined in modules. A module contains a collection of related definitions.

YANG数据模型在模块中定义。模块包含相关定义的集合。

A module contains three types of statements: module header statements, "revision" statements, and definition statements. The module header statements describe the module and give information about the module itself, the "revision" statements give information about the history of the module, and the definition statements are the body of the module where the data model is defined.

模块包含三种类型的语句:模块标题语句、“修订”语句和定义语句。模块标题语句描述模块并提供关于模块本身的信息,“修订”语句提供关于模块历史的信息,定义语句是定义数据模型的模块主体。

A server may implement a number of modules, allowing multiple views of the same data or multiple views of disjoint subsections of the server's data. Alternatively, the server may implement only one module that defines all available data.

服务器可以实现多个模块,允许相同数据的多个视图或服务器数据不相交子部分的多个视图。或者,服务器可以仅实现一个定义所有可用数据的模块。

A module may have portions of its definitions separated into submodules, based on the needs of the module designer. The external view remains that of a single module, regardless of the presence or size of its submodules.

根据模块设计者的需要,模块可以将其定义的部分划分为子模块。外部视图保持单个模块的视图,无论其子模块的存在或大小。

The "import" statement allows a module or submodule to reference definitions defined in other modules.

“import”语句允许模块或子模块引用在其他模块中定义的定义。

The "include" statement is used in a module to identify each submodule that belongs to it.

“include”语句在模块中用于标识属于它的每个子模块。

4.2.2. Data Modeling Basics
4.2.2. 数据建模基础

YANG defines four main types of data nodes for data modeling. In each of the following subsections, the examples show the YANG syntax as well as a corresponding XML encoding. The syntax of YANG statements is defined in Section 6.3.

YANG为数据建模定义了四种主要类型的数据节点。在下面的每个小节中,示例都显示了YANG语法以及相应的XML编码。YANG语句的语法定义见第6.3节。

4.2.2.1. Leaf Nodes
4.2.2.1. 叶节点

A leaf instance contains simple data like an integer or a string. It has exactly one value of a particular type and no child nodes.

叶实例包含简单的数据,如整数或字符串。它只有一个特定类型的值,并且没有子节点。

YANG Example:

杨举例:

     leaf host-name {
       type string;
       description
         "Hostname for this system.";
     }
        
     leaf host-name {
       type string;
       description
         "Hostname for this system.";
     }
        

XML Encoding Example:

XML编码示例:

     <host-name>my.example.com</host-name>
        
     <host-name>my.example.com</host-name>
        

The "leaf" statement is covered in Section 7.6.

第7.6节介绍了“叶”声明。

4.2.2.2. Leaf-List Nodes
4.2.2.2. 叶列表节点

A leaf-list defines a sequence of values of a particular type.

叶列表定义特定类型的值序列。

YANG Example:

杨举例:

     leaf-list domain-search {
       type string;
       description
         "List of domain names to search.";
     }
        
     leaf-list domain-search {
       type string;
       description
         "List of domain names to search.";
     }
        

XML Encoding Example:

XML编码示例:

     <domain-search>high.example.com</domain-search>
     <domain-search>low.example.com</domain-search>
     <domain-search>everywhere.example.com</domain-search>
        
     <domain-search>high.example.com</domain-search>
     <domain-search>low.example.com</domain-search>
     <domain-search>everywhere.example.com</domain-search>
        

The "leaf-list" statement is covered in Section 7.7.

第7.7节介绍了“叶列表”声明。

4.2.2.3. Container Nodes
4.2.2.3. 容器节点

A container is used to group related nodes in a subtree. A container has only child nodes and no value. A container may contain any number of child nodes of any type (leafs, lists, containers, leaf-lists, actions, and notifications).

容器用于将子树中的相关节点分组。容器只有子节点,没有值。容器可以包含任意数量的任意类型的子节点(叶、列表、容器、叶列表、操作和通知)。

YANG Example:

杨举例:

     container system {
       container login {
         leaf message {
           type string;
           description
             "Message given at start of login session.";
         }
       }
     }
        
     container system {
       container login {
         leaf message {
           type string;
           description
             "Message given at start of login session.";
         }
       }
     }
        

XML Encoding Example:

XML编码示例:

     <system>
       <login>
         <message>Good morning</message>
       </login>
     </system>
        
     <system>
       <login>
         <message>Good morning</message>
       </login>
     </system>
        

The "container" statement is covered in Section 7.5.

第7.5节介绍了“容器”声明。

4.2.2.4. List Nodes
4.2.2.4. 列表节点

A list defines a sequence of list entries. Each entry is like a container and is uniquely identified by the values of its key leafs if it has any key leafs defined. A list can define multiple key leafs and may contain any number of child nodes of any type (including leafs, lists, containers, etc.).

列表定义了一系列列表条目。每个条目就像一个容器,如果定义了任何键叶,则通过其键叶的值来唯一标识。列表可以定义多个键叶,并且可以包含任意数量的任何类型的子节点(包括叶、列表、容器等)。

YANG Example:

杨举例:

     list user {
       key "name";
       leaf name {
         type string;
       }
       leaf full-name {
         type string;
       }
       leaf class {
         type string;
       }
     }
        
     list user {
       key "name";
       leaf name {
         type string;
       }
       leaf full-name {
         type string;
       }
       leaf class {
         type string;
       }
     }
        

XML Encoding Example:

XML编码示例:

     <user>
       <name>glocks</name>
       <full-name>Goldie Locks</full-name>
       <class>intruder</class>
     </user>
     <user>
       <name>snowey</name>
       <full-name>Snow White</full-name>
       <class>free-loader</class>
     </user>
     <user>
       <name>rzell</name>
       <full-name>Rapun Zell</full-name>
       <class>tower</class>
     </user>
        
     <user>
       <name>glocks</name>
       <full-name>Goldie Locks</full-name>
       <class>intruder</class>
     </user>
     <user>
       <name>snowey</name>
       <full-name>Snow White</full-name>
       <class>free-loader</class>
     </user>
     <user>
       <name>rzell</name>
       <full-name>Rapun Zell</full-name>
       <class>tower</class>
     </user>
        

The "list" statement is covered in Section 7.8.

第7.8节介绍了“列表”说明。

4.2.2.5. Example Module
4.2.2.5. 示例模块

These statements are combined to define the module:

这些语句组合起来定义模块:

     // Contents of "example-system.yang"
     module example-system {
       yang-version 1.1;
       namespace "urn:example:system";
       prefix "sys";
        
     // Contents of "example-system.yang"
     module example-system {
       yang-version 1.1;
       namespace "urn:example:system";
       prefix "sys";
        
       organization "Example Inc.";
       contact "joe@example.com";
       description
         "The module for entities implementing the Example system.";
        
       organization "Example Inc.";
       contact "joe@example.com";
       description
         "The module for entities implementing the Example system.";
        
       revision 2007-06-09 {
         description "Initial revision.";
       }
        
       revision 2007-06-09 {
         description "Initial revision.";
       }
        
       container system {
         leaf host-name {
           type string;
           description
             "Hostname for this system.";
         }
        
       container system {
         leaf host-name {
           type string;
           description
             "Hostname for this system.";
         }
        
         leaf-list domain-search {
           type string;
           description
             "List of domain names to search.";
         }
        
         leaf-list domain-search {
           type string;
           description
             "List of domain names to search.";
         }
        
         container login {
           leaf message {
             type string;
             description
               "Message given at start of login session.";
           }
        
         container login {
           leaf message {
             type string;
             description
               "Message given at start of login session.";
           }
        
           list user {
             key "name";
             leaf name {
               type string;
             }
             leaf full-name {
               type string;
             }
             leaf class {
               type string;
             }
           }
         }
       }
     }
        
           list user {
             key "name";
             leaf name {
               type string;
             }
             leaf full-name {
               type string;
             }
             leaf class {
               type string;
             }
           }
         }
       }
     }
        
4.2.3. Configuration and State Data
4.2.3. 配置和状态数据

YANG can model state data, as well as configuration data, based on the "config" statement. When a node is tagged with "config false", its subhierarchy is flagged as state data. If it is tagged with "config true", its subhierarchy is flagged as configuration data. Parent containers, lists, and key leafs are reported also, giving the context for the state data.

YANG可以根据“config”语句对状态数据和配置数据进行建模。当一个节点被标记为“config false”时,它的子层次结构被标记为状态数据。如果它被标记为“config true”,则其子层次结构被标记为配置数据。还报告父容器、列表和键叶,为状态数据提供上下文。

In this example, two leafs are defined for each interface, a configured speed and an observed speed.

在本例中,为每个接口定义了两个LEAF,一个配置速度和一个观察速度。

     list interface {
       key "name";
       config true;
        
     list interface {
       key "name";
       config true;
        
       leaf name {
         type string;
       }
       leaf speed {
         type enumeration {
           enum 10m;
           enum 100m;
           enum auto;
         }
       }
       leaf observed-speed {
         type uint32;
         config false;
       }
     }
        
       leaf name {
         type string;
       }
       leaf speed {
         type enumeration {
           enum 10m;
           enum 100m;
           enum auto;
         }
       }
       leaf observed-speed {
         type uint32;
         config false;
       }
     }
        

The "config" statement is covered in Section 7.21.1.

第7.21.1节介绍了“config”语句。

4.2.4. Built-In Types
4.2.4. 内置类型

YANG has a set of built-in types, similar to those of many programming languages, but with some differences due to special requirements of network management. The following table summarizes the built-in types discussed in Section 9:

YANG有一组内置类型,类似于许多编程语言的类型,但由于网络管理的特殊要求而有所不同。下表总结了第9节中讨论的内置类型:

       +---------------------+-------------------------------------+
       | Name                | Description                         |
       +---------------------+-------------------------------------+
       | binary              | Any binary data                     |
       | bits                | A set of bits or flags              |
       | boolean             | "true" or "false"                   |
       | decimal64           | 64-bit signed decimal number        |
       | empty               | A leaf that does not have any value |
       | enumeration         | One of an enumerated set of strings |
       | identityref         | A reference to an abstract identity |
       | instance-identifier | A reference to a data tree node     |
       | int8                | 8-bit signed integer                |
       | int16               | 16-bit signed integer               |
       | int32               | 32-bit signed integer               |
       | int64               | 64-bit signed integer               |
       | leafref             | A reference to a leaf instance      |
       | string              | A character string                  |
       | uint8               | 8-bit unsigned integer              |
       | uint16              | 16-bit unsigned integer             |
       | uint32              | 32-bit unsigned integer             |
       | uint64              | 64-bit unsigned integer             |
       | union               | Choice of member types              |
       +---------------------+-------------------------------------+
        
       +---------------------+-------------------------------------+
       | Name                | Description                         |
       +---------------------+-------------------------------------+
       | binary              | Any binary data                     |
       | bits                | A set of bits or flags              |
       | boolean             | "true" or "false"                   |
       | decimal64           | 64-bit signed decimal number        |
       | empty               | A leaf that does not have any value |
       | enumeration         | One of an enumerated set of strings |
       | identityref         | A reference to an abstract identity |
       | instance-identifier | A reference to a data tree node     |
       | int8                | 8-bit signed integer                |
       | int16               | 16-bit signed integer               |
       | int32               | 32-bit signed integer               |
       | int64               | 64-bit signed integer               |
       | leafref             | A reference to a leaf instance      |
       | string              | A character string                  |
       | uint8               | 8-bit unsigned integer              |
       | uint16              | 16-bit unsigned integer             |
       | uint32              | 32-bit unsigned integer             |
       | uint64              | 64-bit unsigned integer             |
       | union               | Choice of member types              |
       +---------------------+-------------------------------------+
        

The "type" statement is covered in Section 7.4.

“类型”说明见第7.4节。

4.2.5. Derived Types (typedef)
4.2.5. 派生类型(typedef)

YANG can define derived types from base types using the "typedef" statement. A base type can be either a built-in type or a derived type, allowing a hierarchy of derived types.

YANG可以使用“typedef”语句从基类型定义派生类型。基类型可以是内置类型或派生类型,允许派生类型的层次结构。

A derived type can be used as the argument for the "type" statement.

派生类型可用作“type”语句的参数。

YANG Example:

杨举例:

     typedef percent {
       type uint8 {
         range "0 .. 100";
       }
     }
        
     typedef percent {
       type uint8 {
         range "0 .. 100";
       }
     }
        
     leaf completed {
       type percent;
     }
        
     leaf completed {
       type percent;
     }
        

XML Encoding Example:

XML编码示例:

     <completed>20</completed>
        
     <completed>20</completed>
        

The "typedef" statement is covered in Section 7.3.

第7.3节介绍了“typedef”语句。

4.2.6. Reusable Node Groups (grouping)
4.2.6. 可重用节点组(分组)

Groups of nodes can be assembled into reusable collections using the "grouping" statement. A grouping defines a set of nodes that are instantiated with the "uses" statement.

可以使用“grouping”语句将节点组组装成可重用的集合。分组定义了一组用“uses”语句实例化的节点。

YANG Example:

杨举例:

     grouping target {
       leaf address {
         type inet:ip-address;
         description "Target IP address.";
       }
       leaf port {
         type inet:port-number;
          description "Target port number.";
       }
     }
        
     grouping target {
       leaf address {
         type inet:ip-address;
         description "Target IP address.";
       }
       leaf port {
         type inet:port-number;
          description "Target port number.";
       }
     }
        
     container peer {
       container destination {
         uses target;
       }
     }
        
     container peer {
       container destination {
         uses target;
       }
     }
        

XML Encoding Example:

XML编码示例:

     <peer>
       <destination>
         <address>2001:db8::2</address>
         <port>830</port>
       </destination>
     </peer>
        
     <peer>
       <destination>
         <address>2001:db8::2</address>
         <port>830</port>
       </destination>
     </peer>
        

The grouping can be refined as it is used, allowing certain statements to be overridden. In this example, the description is refined:

分组可以在使用时进行细化,允许覆盖某些语句。在本例中,对描述进行了细化:

     container connection {
       container source {
         uses target {
           refine "address" {
             description "Source IP address.";
           }
           refine "port" {
             description "Source port number.";
           }
         }
       }
       container destination {
         uses target {
           refine "address" {
             description "Destination IP address.";
           }
           refine "port" {
             description "Destination port number.";
           }
         }
       }
     }
        
     container connection {
       container source {
         uses target {
           refine "address" {
             description "Source IP address.";
           }
           refine "port" {
             description "Source port number.";
           }
         }
       }
       container destination {
         uses target {
           refine "address" {
             description "Destination IP address.";
           }
           refine "port" {
             description "Destination port number.";
           }
         }
       }
     }
        

The "grouping" statement is covered in Section 7.12.

第7.12节介绍了“分组”声明。

4.2.7. Choices
4.2.7. 选择

YANG allows the data model to segregate incompatible nodes into distinct choices using the "choice" and "case" statements. The "choice" statement contains a set of "case" statements that define sets of schema nodes that cannot appear together. Each "case" may contain multiple nodes, but each node may appear in only one "case" under a "choice".

YANG允许数据模型使用“choice”和“case”语句将不兼容的节点分隔为不同的选项。“choice”语句包含一组“case”语句,用于定义不能同时出现的模式节点集。每个“案例”可能包含多个节点,但每个节点可能仅出现在“选项”下的一个“案例”中。

The choice and case nodes appear only in the schema tree and not in the data tree. The additional levels of hierarchy are not needed beyond the conceptual schema. The presence of a case is indicated by the presence of one or more of the nodes within it.

choice和case节点仅显示在架构树中,而不显示在数据树中。除了概念模式之外,不需要额外的层次结构。案例的存在通过案例中一个或多个节点的存在来表示。

Since only one of the choice's cases can be valid at any time, when a node from one case is created in the data tree, all nodes from all other cases are implicitly deleted. The server handles the enforcement of the constraint, preventing incompatibilities from existing in the configuration.

由于在任何时候只有一个选项的案例是有效的,因此当在数据树中创建一个案例中的节点时,所有其他案例中的所有节点都将被隐式删除。服务器处理约束的实施,防止配置中存在不兼容。

YANG Example:

杨举例:

     container food {
       choice snack {
         case sports-arena {
           leaf pretzel {
             type empty;
           }
           leaf beer {
             type empty;
           }
         }
         case late-night {
           leaf chocolate {
             type enumeration {
               enum dark;
               enum milk;
               enum first-available;
             }
           }
         }
       }
     }
        
     container food {
       choice snack {
         case sports-arena {
           leaf pretzel {
             type empty;
           }
           leaf beer {
             type empty;
           }
         }
         case late-night {
           leaf chocolate {
             type enumeration {
               enum dark;
               enum milk;
               enum first-available;
             }
           }
         }
       }
     }
        

XML Encoding Example:

XML编码示例:

     <food>
       <pretzel/>
       <beer/>
     </food>
        
     <food>
       <pretzel/>
       <beer/>
     </food>
        

The "choice" statement is covered in Section 7.9.

“选择”声明见第7.9节。

4.2.8. Extending Data Models (augment)
4.2.8. 扩展数据模型(扩充)

YANG allows a module to insert additional nodes into data models, including both the current module (and its submodules) and an external module. This is useful, for example, for vendors to add vendor-specific parameters to standard data models in an interoperable way.

YANG允许模块将其他节点插入数据模型,包括当前模块(及其子模块)和外部模块。例如,这对于供应商以可互操作的方式向标准数据模型添加供应商特定的参数非常有用。

The "augment" statement defines the location in the data model hierarchy where new nodes are inserted, and the "when" statement defines the conditions when the new nodes are valid.

“augment”语句定义了数据模型层次结构中插入新节点的位置,“when”语句定义了新节点有效的条件。

When a server implements a module containing an "augment" statement, that implies that the server's implementation of the augmented module contains the additional nodes.

当服务器实现一个包含“augment”语句的模块时,这意味着服务器的扩展模块实现包含额外的节点。

YANG Example:

杨举例:

     augment /system/login/user {
       when "class != 'wheel'";
       leaf uid {
         type uint16 {
           range "1000 .. 30000";
         }
       }
     }
        
     augment /system/login/user {
       when "class != 'wheel'";
       leaf uid {
         type uint16 {
           range "1000 .. 30000";
         }
       }
     }
        

This example defines a "uid" node that is valid only when the user's "class" is not "wheel".

此示例定义了一个“uid”节点,该节点仅在用户的“类”不是“轮子”时才有效。

If a module augments another module, the XML elements that are added to the encoding are in the namespace of the augmenting module. For example, if the above augmentation were in a module with prefix "other", the XML would look like:

如果一个模块扩展另一个模块,则添加到编码中的XML元素位于扩展模块的命名空间中。例如,如果上述扩展位于前缀为“other”的模块中,则XML将如下所示:

XML Encoding Example:

XML编码示例:

     <user>
       <name>alicew</name>
       <full-name>Alice N. Wonderland</full-name>
       <class>drop-out</class>
       <other:uid>1024</other:uid>
     </user>
        
     <user>
       <name>alicew</name>
       <full-name>Alice N. Wonderland</full-name>
       <class>drop-out</class>
       <other:uid>1024</other:uid>
     </user>
        

The "augment" statement is covered in Section 7.17.

第7.17节介绍了“增强”声明。

4.2.9. Operation Definitions
4.2.9. 操作定义

YANG allows the definition of operations. The operations' names, input parameters, and output parameters are modeled using YANG data definition statements. Operations on the top level in a module are defined with the "rpc" statement. Operations can also be tied to a container or list data node. Such operations are defined with the "action" statement.

杨允许定义操作。使用数据定义语句对操作的名称、输入参数和输出参数进行建模。模块中顶层的操作是用“rpc”语句定义的。操作也可以绑定到容器或列表数据节点。这些操作是用“action”语句定义的。

YANG Example for an operation at the top level:

顶层操作的示例:

     rpc activate-software-image {
       input {
         leaf image-name {
           type string;
         }
       }
       output {
         leaf status {
           type string;
         }
       }
     }
        
     rpc activate-software-image {
       input {
         leaf image-name {
           type string;
         }
       }
       output {
         leaf status {
           type string;
         }
       }
     }
        

NETCONF XML Example:

NETCONF XML示例:

     <rpc message-id="101"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
       <activate-software-image xmlns="http://example.com/system">
         <image-name>example-fw-2.3</image-name>
       </activate-software-image>
     </rpc>
        
     <rpc message-id="101"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
       <activate-software-image xmlns="http://example.com/system">
         <image-name>example-fw-2.3</image-name>
       </activate-software-image>
     </rpc>
        
     <rpc-reply message-id="101"
                xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
       <status xmlns="http://example.com/system">
         The image example-fw-2.3 is being installed.
       </status>
     </rpc-reply>
        
     <rpc-reply message-id="101"
                xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
       <status xmlns="http://example.com/system">
         The image example-fw-2.3 is being installed.
       </status>
     </rpc-reply>
        

YANG Example for an operation tied to a list data node:

绑定到列表数据节点的操作示例:

     list interface {
       key "name";
        
     list interface {
       key "name";
        
       leaf name {
         type string;
       }
        
       leaf name {
         type string;
       }
        
       action ping {
         input {
           leaf destination {
             type inet:ip-address;
           }
         }
         output {
           leaf packet-loss {
             type uint8;
           }
         }
       }
     }
        
       action ping {
         input {
           leaf destination {
             type inet:ip-address;
           }
         }
         output {
           leaf packet-loss {
             type uint8;
           }
         }
       }
     }
        

NETCONF XML Example:

NETCONF XML示例:

     <rpc message-id="102"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
       <action xmlns="urn:ietf:params:xml:ns:yang:1">
         <interface xmlns="http://example.com/system">
           <name>eth1</name>
           <ping>
             <destination>192.0.2.1</destination>
           </ping>
         </interface>
       </action>
     </rpc>
        
     <rpc message-id="102"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
       <action xmlns="urn:ietf:params:xml:ns:yang:1">
         <interface xmlns="http://example.com/system">
           <name>eth1</name>
           <ping>
             <destination>192.0.2.1</destination>
           </ping>
         </interface>
       </action>
     </rpc>
        
     <rpc-reply message-id="102"
                xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
                xmlns:sys="http://example.com/system">
       <sys:packet-loss>60</sys:packet-loss>
     </rpc-reply>
        
     <rpc-reply message-id="102"
                xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
                xmlns:sys="http://example.com/system">
       <sys:packet-loss>60</sys:packet-loss>
     </rpc-reply>
        

The "rpc" statement is covered in Section 7.14, and the "action" statement is covered in Section 7.15.

第7.14节介绍了“rpc”声明,第7.15节介绍了“行动”声明。

4.2.10. Notification Definitions
4.2.10. 通知定义

YANG allows the definition of notifications. YANG data definition statements are used to model the content of the notification.

YANG允许定义通知。数据定义语句用于对通知的内容建模。

YANG Example:

杨举例:

     notification link-failure {
       description
         "A link failure has been detected.";
       leaf if-name {
         type leafref {
           path "/interface/name";
         }
       }
       leaf if-admin-status {
         type admin-status;
       }
       leaf if-oper-status {
         type oper-status;
       }
     }
        
     notification link-failure {
       description
         "A link failure has been detected.";
       leaf if-name {
         type leafref {
           path "/interface/name";
         }
       }
       leaf if-admin-status {
         type admin-status;
       }
       leaf if-oper-status {
         type oper-status;
       }
     }
        

NETCONF XML Example:

NETCONF XML示例:

     <notification
         xmlns="urn:ietf:params:netconf:capability:notification:1.0">
       <eventTime>2007-09-01T10:00:00Z</eventTime>
       <link-failure xmlns="urn:example:system">
         <if-name>so-1/2/3.0</if-name>
         <if-admin-status>up</if-admin-status>
         <if-oper-status>down</if-oper-status>
       </link-failure>
     </notification>
        
     <notification
         xmlns="urn:ietf:params:netconf:capability:notification:1.0">
       <eventTime>2007-09-01T10:00:00Z</eventTime>
       <link-failure xmlns="urn:example:system">
         <if-name>so-1/2/3.0</if-name>
         <if-admin-status>up</if-admin-status>
         <if-oper-status>down</if-oper-status>
       </link-failure>
     </notification>
        

The "notification" statement is covered in Section 7.16.

“通知”声明见第7.16节。

5. Language Concepts
5. 语言概念
5.1. Modules and Submodules
5.1. 模与子模

The module is the base unit of definition in YANG. A module defines a single data model. A module can also augment an existing data model with additional nodes.

模块是杨定义的基本单位。模块定义单个数据模型。模块还可以使用附加节点来扩充现有数据模型。

Submodules are partial modules that contribute definitions to a module. A module may include any number of submodules, but each submodule may belong to only one module.

子模块是为模块提供定义的部分模块。一个模块可以包括任意数量的子模块,但每个子模块只能属于一个模块。

Developers of YANG modules and submodules are RECOMMENDED to choose names for their modules that will have a low probability of colliding with standard or other enterprise modules, e.g., by using the enterprise or organization name as a prefix for the module name. Within a server, all module names MUST be unique.

建议模块和子模块的开发人员为其模块选择与标准模块或其他企业模块发生冲突的可能性较低的名称,例如,使用企业或组织名称作为模块名称的前缀。在服务器中,所有模块名称都必须是唯一的。

A module uses the "include" statement to list all its submodules. A module, or submodule belonging to that module, can reference definitions in the module and all submodules included by the module.

模块使用“include”语句列出其所有子模块。模块或属于该模块的子模块可以引用该模块中的定义以及该模块包含的所有子模块。

A module or submodule uses the "import" statement to reference external modules. Statements in the module or submodule can reference definitions in the external module using the prefix specified in the "import" statement.

模块或子模块使用“import”语句引用外部模块。模块或子模块中的语句可以使用“import”语句中指定的前缀引用外部模块中的定义。

For backward compatibility with YANG version 1, a submodule MAY use the "include" statement to reference other submodules within its module, but this is not necessary in YANG version 1.1. A submodule can reference any definition in the module it belongs to and in all submodules included by the module. A submodule MUST NOT include different revisions of other submodules than the revisions that its module includes.

为了与YANG版本1向后兼容,子模块可以使用“include”语句引用其模块内的其他子模块,但在YANG版本1.1中不需要这样做。子模块可以引用其所属模块中的任何定义以及该模块包含的所有子模块中的任何定义。子模块不得包含与其模块包含的版本不同的其他子模块版本。

A module or submodule MUST NOT include submodules from other modules, and a submodule MUST NOT import its own module.

模块或子模块不得包含来自其他模块的子模块,并且子模块不得导入自己的模块。

The "import" and "include" statements are used to make definitions available from other modules:

“import”和“include”语句用于从其他模块提供定义:

o For a module or submodule to reference definitions in an external module, the external module MUST be imported.

o 要使模块或子模块引用外部模块中的定义,必须导入外部模块。

o A module MUST include all its submodules.

o 模块必须包括其所有子模块。

o A module, or submodule belonging to that module, MAY reference definitions in the module and all submodules included by the module.

o 模块或属于该模块的子模块可以引用该模块中的定义以及该模块包含的所有子模块。

There MUST NOT be any circular chains of imports. For example, if module "a" imports module "b", "b" cannot import "a".

不得有任何环形进口链。例如,如果模块“a”导入模块“b”,则“b”无法导入“a”。

When a definition in an external module is referenced, a locally defined prefix MUST be used, followed by a colon (":") and then the external identifier. References to definitions in the local module MAY use the prefix notation. Since built-in data types do not belong to any module and have no prefix, references to built-in data types (e.g., int32) cannot use the prefix notation. The syntax for a reference to a definition is formally defined by the rule "identifier-ref" in Section 14.

引用外部模块中的定义时,必须使用本地定义的前缀,后跟冒号(“:”),然后是外部标识符。对本地模块中定义的引用可以使用前缀表示法。由于内置数据类型不属于任何模块且没有前缀,因此对内置数据类型(例如int32)的引用不能使用前缀表示法。引用定义的语法由第14节中的规则“标识符ref”正式定义。

5.1.1. Import and Include by Revision
5.1.1. 通过修订导入和包含

Published modules evolve independently over time. In order to allow for this evolution, modules can be imported using specific revisions. Initially, a module imports the revisions of other modules that are current when the module is written. As future revisions of the imported modules are published, the importing module is unaffected and its contents are unchanged. When the author of the module is prepared to move to the most recently published revision of an imported module, the module is republished with an updated "import" statement. By republishing with the new revision, the authors explicitly indicate their acceptance of any changes in the imported module.

已发布的模块会随着时间的推移独立演化。为了允许这种演变,可以使用特定的修订版导入模块。最初,模块导入其他模块的修订版,这些修订版在编写模块时是最新的。随着导入模块的未来版本的发布,导入模块不受影响,其内容不变。当模块的作者准备移动到导入模块的最新发布版本时,将使用更新的“导入”语句重新发布该模块。通过使用新版本重新发布,作者明确表示接受导入模块中的任何更改。

For submodules, the issue is related but simpler. A module or submodule that includes submodules may specify the revision of the included submodules. If a submodule changes, any module or submodule that includes it by revision needs to be updated to reference the new revision.

对于子模块,问题是相关的,但更简单。包含子模块的模块或子模块可以指定包含子模块的版本。如果子模块发生更改,则需要更新按修订包含它的任何模块或子模块,以引用新修订。

For example, module "b" imports module "a".

例如,模块“b”导入模块“a”。

     module a {
       yang-version 1.1;
       namespace "urn:example:a";
       prefix "a";
        
     module a {
       yang-version 1.1;
       namespace "urn:example:a";
       prefix "a";
        
       revision 2008-01-01 { ... }
       grouping a {
         leaf eh { .... }
       }
     }
        
       revision 2008-01-01 { ... }
       grouping a {
         leaf eh { .... }
       }
     }
        
     module b {
       yang-version 1.1;
       namespace "urn:example:b";
       prefix "b";
        
     module b {
       yang-version 1.1;
       namespace "urn:example:b";
       prefix "b";
        
       import a {
         prefix "p";
         revision-date 2008-01-01;
       }
        
       import a {
         prefix "p";
         revision-date 2008-01-01;
       }
        
       container bee {
         uses p:a;
       }
     }
        
       container bee {
         uses p:a;
       }
     }
        

When the author of "a" publishes a new revision, the changes may not be acceptable to the author of "b". If the new revision is acceptable, the author of "b" can republish with an updated revision in the "import" statement.

当“a”的作者发布新版本时,“b”的作者可能不接受这些更改。如果新版本可以接受,“b”的作者可以在“导入”语句中使用更新版本重新发布。

If a module is not imported with a specific revision, it is undefined which revision is used.

如果模块未随特定版本一起导入,则未定义使用哪个版本。

5.1.2. Module Hierarchies
5.1.2. 模块层次结构

YANG allows modeling of data in multiple hierarchies, where data may have more than one top-level node. Each top-level data node in a module defines a separate hierarchy. Models that have multiple top-level nodes are sometimes convenient and are supported by YANG.

YANG允许在多个层次结构中对数据进行建模,其中数据可能有多个顶级节点。模块中的每个顶级数据节点定义一个单独的层次结构。具有多个顶级节点的模型有时很方便,并且受到YANG的支持。

5.1.2.1. NETCONF XML Encoding
5.1.2.1. NETCONF XML编码

NETCONF is capable of carrying any XML content as the payload in the <config> and <data> elements. The top-level nodes of YANG modules are encoded as child elements, in any order, within these elements. This encapsulation guarantees that the corresponding NETCONF messages are always well-formed XML documents.

NETCONF能够在<config>和<data>元素中承载任何XML内容作为有效负载。YANG模块的顶级节点在这些元素中以任意顺序编码为子元素。这种封装保证了相应的NETCONF消息始终是格式良好的XML文档。

For example, an instance of:

例如,以下实例:

     module example-config {
       yang-version 1.1;
       namespace "urn:example:config";
       prefix "co";
        
     module example-config {
       yang-version 1.1;
       namespace "urn:example:config";
       prefix "co";
        
       container system { ... }
       container routing { ... }
     }
        
       container system { ... }
       container routing { ... }
     }
        

could be encoded in NETCONF as:

可以在NETCONF中编码为:

     <rpc message-id="101"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
          xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
       <edit-config>
         <target>
           <running/>
         </target>
         <config>
           <system xmlns="urn:example:config">
             <!-- system data here -->
           </system>
           <routing xmlns="urn:example:config">
             <!-- routing data here -->
           </routing>
         </config>
       </edit-config>
     </rpc>
        
     <rpc message-id="101"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
          xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
       <edit-config>
         <target>
           <running/>
         </target>
         <config>
           <system xmlns="urn:example:config">
             <!-- system data here -->
           </system>
           <routing xmlns="urn:example:config">
             <!-- routing data here -->
           </routing>
         </config>
       </edit-config>
     </rpc>
        
5.2. File Layout
5.2. 文件布局

YANG modules and submodules are typically stored in files, one "module" or "submodule" statement per file. The name of the file SHOULD be of the form:

模块和子模块通常存储在文件中,每个文件有一个“module”或“submodule”语句。文件名的格式应为:

module-or-submodule-name ['@' revision-date] ( '.yang' / '.yin' )

模块或子模块名称['@'修订日期]('.yang'/'.yin')

"module-or-submodule-name" is the name of the module or submodule, and the optional "revision-date" is the latest revision of the module or submodule, as defined by the "revision" statement (Section 7.1.9).

“模块或子模块名称”是模块或子模块的名称,可选的“修订日期”是“修订”声明(第7.1.9节)中定义的模块或子模块的最新版本。

The file extension ".yang" denotes that the contents of the file are written with YANG syntax (Section 6), and ".yin" denotes that the contents of the file are written with YIN syntax (Section 13).

文件扩展名“.yang”表示文件内容使用yang语法编写(第6节),“.yin”表示文件内容使用yin语法编写(第13节)。

YANG parsers can find imported modules and included submodules via this convention.

YANG解析器可以通过此约定查找导入的模块和包含的子模块。

5.3. XML Namespaces
5.3. XML名称空间

All YANG definitions are specified within a module. Each module is bound to a distinct XML namespace [XML-NAMES], which is a globally unique URI [RFC3986]. A NETCONF client or server uses the namespace during XML encoding of data.

所有定义都在模块中指定。每个模块都绑定到一个不同的XML名称空间[XML-NAMES],这是一个全局唯一的URI[RFC3986]。NETCONF客户端或服务器在数据的XML编码期间使用名称空间。

XML namespaces for modules published in RFC streams [RFC4844] MUST be assigned by IANA; see Section 14 in [RFC6020].

RFC streams[RFC4844]中发布的模块的XML名称空间必须由IANA分配;参见[RFC6020]中的第14节。

XML namespaces for private modules are assigned by the organization owning the module without a central registry. Namespace URIs MUST be chosen so they cannot collide with standard or other enterprise namespaces -- for example, by using the enterprise or organization name in the namespace.

私有模块的XML名称空间由拥有该模块的组织分配,而无需中央注册表。必须选择名称空间URI,以便它们不会与标准或其他企业名称空间冲突——例如,通过在名称空间中使用企业或组织名称。

The "namespace" statement is covered in Section 7.1.3.

第7.1.3节介绍了“名称空间”语句。

5.3.1. YANG XML Namespace
5.3.1. XML名称空间

YANG defines an XML namespace for NETCONF <edit-config> operations, <error-info> content, and the <action> element. The name of this namespace is "urn:ietf:params:xml:ns:yang:1".

YANG为NETCONF<edit config>操作、<error info>内容和<action>元素定义了一个XML名称空间。此命名空间的名称为“urn:ietf:params:xml:ns:yang:1”。

5.4. Resolving Grouping, Type, and Identity Names
5.4. 解析分组、类型和标识名

Grouping, type, and identity names are resolved in the context in which they are defined, rather than the context in which they are used. Users of groupings, typedefs, and identities are not required to import modules or include submodules to satisfy all references made by the original definition. This behaves like static scoping in a conventional programming language.

分组、类型和标识名在定义它们的上下文中解析,而不是在使用它们的上下文中解析。分组、typedef和标识的用户无需导入模块或包含子模块以满足原始定义所做的所有引用。这与传统编程语言中的静态作用域类似。

For example, if a module defines a grouping in which a type is referenced, when the grouping is used in a second module, the type is resolved in the context of the original module, not the second module. There is no ambiguity if both modules define the type.

例如,如果一个模块定义了一个引用类型的分组,则当该分组在第二个模块中使用时,该类型将在原始模块的上下文中解析,而不是在第二个模块中解析。如果两个模块都定义了类型,则不会有歧义。

5.5. Nested Typedefs and Groupings
5.5. 嵌套的typedef和分组

Typedefs and groupings may appear nested under many YANG statements, allowing these to be lexically scoped by the statement hierarchy under which they appear. This allows types and groupings to be defined near where they are used, rather than placing them at the top level of the hierarchy. The close proximity increases readability.

typedef和groupings可能嵌套在许多YANG语句下,允许它们在词汇上受它们出现的语句层次结构的限制。这允许在使用类型和分组的位置附近定义它们,而不是将它们放在层次结构的顶层。近距离增加了可读性。

Scoping also allows types to be defined without concern for naming conflicts between types in different submodules. Type names can be specified without adding leading strings designed to prevent name collisions within large modules.

作用域还允许定义类型,而不必担心不同子模块中类型之间的命名冲突。可以在不添加前导字符串的情况下指定类型名,前导字符串旨在防止大型模块中的名称冲突。

Finally, scoping allows the module author to keep types and groupings private to their module or submodule, preventing their reuse. Since only top-level types and groupings (i.e., those appearing as substatements to a "module" or "submodule" statement) can be used outside the module or submodule, the developer has more control over what pieces of their module are presented to the outside world, supporting the need to hide internal information and maintaining a boundary between what is shared with the outside world and what is kept private.

最后,作用域允许模块作者将类型和分组保持为其模块或子模块的私有,从而防止其重用。由于只有顶级类型和分组(即,那些作为“模块”或“子模块”语句的子状态出现的类型和分组)可以在模块或子模块之外使用,因此开发人员可以更好地控制向外部世界展示其模块的哪些部分,支持隐藏内部信息的需要,并在与外部世界共享的信息和保密的信息之间保持界限。

Scoped definitions MUST NOT shadow definitions at a higher scope. A type or grouping cannot be defined if a higher level in the statement hierarchy has a definition with a matching identifier.

作用域定义不能在更高的作用域中隐藏定义。如果语句层次结构中的较高级别具有具有匹配标识符的定义,则无法定义类型或分组。

A reference to an unprefixed type or grouping, or one that uses the prefix of the current module, is resolved by locating the matching "typedef" or "grouping" statement among the immediate substatements of each ancestor statement.

通过在每个祖先语句的直接子语句中定位匹配的“typedef”或“grouping”语句,可以解析对未固定类型或分组的引用,或对使用当前模块前缀的类型或分组的引用。

5.6. Conformance
5.6. 一致性

Conformance to a model is a measure of how accurately a server follows the model. Generally speaking, servers are responsible for implementing the model faithfully, allowing applications to treat servers that implement the model identically. Deviations from the model can reduce the utility of the model and increase the fragility of applications that use it.

模型的一致性是衡量服务器遵循模型的准确程度的一个指标。一般来说,服务器负责忠实地实现模型,允许应用程序以相同的方式对待实现模型的服务器。偏离模型会降低模型的实用性,并增加使用它的应用程序的脆弱性。

YANG modelers have three mechanisms for conformance:

YANG建模者有三种一致性机制:

o the basic behavior of the model

o 模型的基本行为

o optional features that are part of the model

o 作为模型一部分的可选功能

o deviations from the model

o 与模型的偏差

We will consider each of these in sequence.

我们将依次考虑每一个问题。

5.6.1. Basic Behavior
5.6.1. 基本行为

The model defines a contract between a YANG-based client and server; this contract allows both parties to have faith that the other knows the syntax and semantics behind the modeled data. The strength of YANG lies in the strength of this contract.

该模型定义了基于YANG的客户端和服务器之间的契约;本合同允许双方相信另一方知道建模数据背后的语法和语义。杨的力量在于这份合同的力量。

5.6.2. Optional Features
5.6.2. 可选功能

In many models, the modeler will allow sections of the model to be conditional. The server controls whether these conditional portions of the model are supported or valid for that particular server.

在许多模型中,建模者将允许模型的部分是有条件的。服务器控制模型的这些条件部分对于特定服务器是否受支持或有效。

For example, a syslog data model may choose to include the ability to save logs locally, but the modeler will realize that this is only possible if the server has local storage. If there is no local storage, an application should not tell the server to save logs.

例如,syslog数据模型可能会选择包含本地保存日志的功能,但建模人员会意识到,只有在服务器具有本地存储的情况下,这才是可能的。如果没有本地存储,应用程序不应该告诉服务器保存日志。

YANG supports this conditional mechanism using a construct called "feature". Features give the modeler a mechanism for making portions of the module conditional in a manner that is controlled by the server. The model can express constructs that are not universally present in all servers. These features are included in the model definition, allowing a consistent view and allowing applications to learn which features are supported and tailor their behavior to the server.

YANG使用一种称为“特征”的结构来支持这种条件机制。特性为建模者提供了一种机制,使模块的某些部分以服务器控制的方式具有条件。该模型可以表示并非所有服务器中都普遍存在的结构。这些特性包含在模型定义中,允许一致的视图,并允许应用程序了解支持哪些特性,并根据服务器调整其行为。

A module may declare any number of features, identified by simple strings, and may make portions of the module optional based on those features. If the server supports a feature, then the corresponding portions of the module are valid for that server. If the server doesn't support the feature, those parts of the module are not valid, and applications should behave accordingly.

一个模块可以声明任意数量的特性,由简单字符串标识,并且可以基于这些特性使模块的部分成为可选的。如果服务器支持某项功能,则模块的相应部分对该服务器有效。如果服务器不支持该功能,则模块的这些部分无效,应用程序应相应地运行。

Features are defined using the "feature" statement. Definitions in the module that are conditional to the feature are noted by the "if-feature" statement.

使用“功能”语句定义功能。模块中与功能相关的定义由“if feature”语句注释。

Further details are available in Section 7.20.1.

更多详情见第7.20.1节。

5.6.3. Deviations
5.6.3. 偏差

In an ideal world, all servers would be required to implement the model exactly as defined, and deviations from the model would not be allowed. But in the real world, servers are often not able or designed to implement the model as written. For YANG-based automation to deal with these server deviations, a mechanism must exist for servers to inform applications of the specifics of such deviations.

在理想情况下,所有服务器都需要完全按照定义实现模型,并且不允许偏离模型。但在现实世界中,服务器通常无法或设计为实现所编写的模型。为了使基于YANG的自动化能够处理这些服务器偏差,服务器必须有一种机制来通知应用程序这些偏差的具体情况。

For example, a BGP module may allow any number of BGP peers, but a particular server may only support 16 BGP peers. Any application configuring the 17th peer will receive an error. While an error may suffice to let the application know it cannot add another peer, it would be far better if the application had prior knowledge of this limitation and could prevent the user from starting down the path that could not succeed.

例如,BGP模块可允许任意数量的BGP对等点,但特定服务器可能仅支持16个BGP对等点。任何配置第17个对等点的应用程序都将收到错误。虽然一个错误可能足以让应用程序知道它无法添加另一个对等点,但如果应用程序事先知道这一限制,并且可以阻止用户沿着无法成功的路径启动,那就更好了。

Server deviations are declared using the "deviation" statement, which takes as its argument a string that identifies a node in the schema tree. The contents of the statement detail the manner in which the server implementation deviates from the contract as defined in the module.

服务器偏差是使用“偏差”语句声明的,该语句以标识模式树中节点的字符串作为参数。该语句的内容详细说明了服务器实现偏离模块中定义的契约的方式。

Further details are available in Section 7.20.3.

更多详情见第7.20.3节。

5.6.4. Announcing Conformance Information in NETCONF
5.6.4. 在NETCONF中宣布一致性信息

This document defines the following mechanism for announcing conformance information. Other mechanisms may be defined by future specifications.

本文档定义了以下发布一致性信息的机制。其他机制可能由未来的规范定义。

A NETCONF server MUST announce the modules it implements (see Section 5.6.5) by implementing the YANG module "ietf-yang-library" defined in [RFC7895] and listing all implemented modules in the "/modules-state/module" list.

NETCONF服务器必须通过实现[RFC7895]中定义的YANG模块“ietf YANG library”并在“/模块状态/模块”列表中列出所有实现的模块来宣布其实现的模块(见第5.6.5节)。

The server also MUST advertise the following capability in the <hello> message (line breaks and whitespaces are used for formatting reasons only):

服务器还必须在<hello>消息中公布以下功能(换行符和空格仅用于格式化原因):

     urn:ietf:params:netconf:capability:yang-library:1.0?
       revision=<date>&module-set-id=<id>
        
     urn:ietf:params:netconf:capability:yang-library:1.0?
       revision=<date>&module-set-id=<id>
        

The parameter "revision" has the same value as the revision date of the "ietf-yang-library" module implemented by the server. This parameter MUST be present.

参数“revision”的值与服务器实现的“ietf yang library”模块的修订日期相同。此参数必须存在。

The parameter "module-set-id" has the same value as the leaf "/modules-state/module-set-id" from "ietf-yang-library". This parameter MUST be present.

参数“模块集id”的值与“ietf库”中的叶“/模块状态/模块集id”的值相同。此参数必须存在。

With this mechanism, a client can cache the supported modules for a server and only update the cache if the "module-set-id" value in the <hello> message changes.

通过这种机制,客户机可以缓存服务器支持的模块,并且只有在<hello>消息中的“module set id”值更改时才更新缓存。

5.6.5. Implementing a Module
5.6.5. 实现模块

A server implements a module if it implements the module's data nodes, RPCs, actions, notifications, and deviations.

如果服务器实现了模块的数据节点、RPC、操作、通知和偏差,则服务器将实现该模块。

A server MUST NOT implement more than one revision of a module.

服务器不能实现一个模块的多个版本。

If a server implements a module A that imports a module B, and A uses any node from B in an "augment" or "path" statement that the server supports, then the server MUST implement a revision of module B that has these nodes defined. This is regardless of whether module B is imported by revision or not.

如果服务器实现了导入模块B的模块a,并且a在服务器支持的“augment”或“path”语句中使用了来自B的任何节点,则服务器必须实现定义了这些节点的模块B的修订版。这与模块B是否通过修订版导入无关。

If a server implements a module A that imports a module C without specifying the revision date of module C and the server does not implement C (e.g., if C only defines some typedefs), the server MUST list module C in the "/modules-state/module" list from "ietf-yang-library" [RFC7895], and it MUST set the leaf "conformance-type" to "import" for this module.

如果服务器实现的模块a导入模块C而未指定模块C的修订日期,并且服务器未实现C(例如,如果C仅定义了一些TypeDef),则服务器必须在“ietf yang library”[RFC7895]的“/模块状态/模块”列表中列出模块C,并且必须将叶“一致性类型”设置为“导入”对于本模块。

If a server lists a module C in the "/modules-state/module" list from "ietf-yang-library" and there are other modules Ms listed that import C without specifying the revision date of module C, the server MUST use the definitions from the most recent revision of C listed for modules Ms.

如果服务器在“ietf yang library”中的“/模块状态/模块”列表中列出模块C,并且列出的其他模块Ms在未指定模块C的修订日期的情况下导入C,则服务器必须使用为模块Ms列出的最新版本C中的定义。

The reason for these rules is that clients need to be able to know the specific data model structure and types of all leafs and leaf-lists implemented in a server.

这些规则的原因是,客户机需要能够知道服务器中实现的所有叶和叶列表的特定数据模型结构和类型。

For example, with these modules:

例如,使用这些模块:

     module a {
       yang-version 1.1;
       namespace "urn:example:a";
       prefix "a";
        
     module a {
       yang-version 1.1;
       namespace "urn:example:a";
       prefix "a";
        
       import b {
         revision-date 2015-01-01;
       }
       import c;
        
       import b {
         revision-date 2015-01-01;
       }
       import c;
        

revision 2015-01-01;

修订版2015-01-01;

feature foo;

特写富;

       augment "/b:x" {
         if-feature foo;
        
       augment "/b:x" {
         if-feature foo;
        
         leaf y {
           type b:myenum;
         }
       }
        
         leaf y {
           type b:myenum;
         }
       }
        
       container a {
         leaf x {
           type c:bar;
         }
       }
     }
        
       container a {
         leaf x {
           type c:bar;
         }
       }
     }
        
     module b {
       yang-version 1.1;
       namespace "urn:example:b";
       prefix "b";
        
     module b {
       yang-version 1.1;
       namespace "urn:example:b";
       prefix "b";
        

revision 2015-01-01;

修订版2015-01-01;

       typedef myenum {
         type enumeration {
           enum zero;
         }
       }
        
       typedef myenum {
         type enumeration {
           enum zero;
         }
       }
        
       container x {
       }
     }
        
       container x {
       }
     }
        
     module b {
       yang-version 1.1;
       namespace "urn:example:b";
       prefix "b";
        
     module b {
       yang-version 1.1;
       namespace "urn:example:b";
       prefix "b";
        
       revision 2015-04-04;
       revision 2015-01-01;
        
       revision 2015-04-04;
       revision 2015-01-01;
        
       typedef myenum {
         type enumeration {
           enum zero; // added in 2015-01-01
           enum one;  // added in 2015-04-04
         }
       }
        
       typedef myenum {
         type enumeration {
           enum zero; // added in 2015-01-01
           enum one;  // added in 2015-04-04
         }
       }
        
       container x {  // added in 2015-01-01
         container y; // added in 2015-04-04
       }
     }
        
       container x {  // added in 2015-01-01
         container y; // added in 2015-04-04
       }
     }
        
     module c {
       yang-version 1.1;
       namespace "urn:example:c";
       prefix "c";
        
     module c {
       yang-version 1.1;
       namespace "urn:example:c";
       prefix "c";
        

revision 2015-02-02;

修订版2015-02-02;

       typedef bar {
         ...
       }
     }
        
       typedef bar {
         ...
       }
     }
        
     module c {
       yang-version 1.1;
       namespace "urn:example:c";
       prefix "c";
        
     module c {
       yang-version 1.1;
       namespace "urn:example:c";
       prefix "c";
        
       revision 2015-03-03;
       revision 2015-02-02;
        
       revision 2015-03-03;
       revision 2015-02-02;
        
       typedef bar {
         ...
       }
     }
        
       typedef bar {
         ...
       }
     }
        

A server that implements revision "2015-01-01" of module "a" and supports feature "foo" can implement revision "2015-01-01" or "2015-04-04" of module "b". Since "b" was imported by revision, the type of leaf "/b:x/a:y" is the same, regardless of which revision of "b" the server implements.

实现模块“A”的版本“2015-01-01”并支持功能“foo”的服务器可以实现模块“b”的版本“2015-01-01”或“2015-04-04”。由于“b”是通过修订版导入的,因此叶“/b:x/a:y”的类型是相同的,无论服务器实现的是“b”的哪个修订版。

A server that implements module "a" but does not support feature "foo" does not have to implement module "b".

实现模块“A”但不支持功能“foo”的服务器不必实现模块“b”。

A server that implements revision "2015-01-01" of module "a" picks any revision of module "c" and lists it in the "/modules-state/module" list from "ietf-yang-library".

实现模块“A”的版本“2015-01-01”的服务器会选择模块“c”的任何版本,并将其列在“ietf库”的“/模块状态/模块”列表中。

The following XML encoding example shows valid data for the "/modules-state/module" list for a server that implements module "a":

以下XML编码示例显示了实现模块“a”的服务器的“/modules state/module”列表的有效数据:

     <modules-state
         xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library">
       <module-set-id>ee1ecb017370cafd</module-set-id>
       <module>
         <name>a</name>
         <revision>2015-01-01</revision>
         <namespace>urn:example:a</namespace>
         <feature>foo</feature>
         <conformance-type>implement</conformance-type>
       </module>
       <module>
         <name>b</name>
         <revision>2015-04-04</revision>
         <namespace>urn:example:b</namespace>
         <conformance-type>implement</conformance-type>
       </module>
        
     <modules-state
         xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-library">
       <module-set-id>ee1ecb017370cafd</module-set-id>
       <module>
         <name>a</name>
         <revision>2015-01-01</revision>
         <namespace>urn:example:a</namespace>
         <feature>foo</feature>
         <conformance-type>implement</conformance-type>
       </module>
       <module>
         <name>b</name>
         <revision>2015-04-04</revision>
         <namespace>urn:example:b</namespace>
         <conformance-type>implement</conformance-type>
       </module>
        
       <module>
         <name>c</name>
         <revision>2015-02-02</revision>
         <namespace>urn:example:c</namespace>
         <conformance-type>import</conformance-type>
       </module>
     </modules-state>
        
       <module>
         <name>c</name>
         <revision>2015-02-02</revision>
         <namespace>urn:example:c</namespace>
         <conformance-type>import</conformance-type>
       </module>
     </modules-state>
        
5.7. Datastore Modification
5.7. 数据存储修改

Data models may allow the server to alter the configuration datastore in ways not explicitly directed via network management protocol messages. For example, a data model may define leafs that are assigned system-generated values when the client does not provide one. A formal mechanism for specifying the circumstances where these changes are allowed is out of scope for this specification.

数据模型可能允许服务器以未通过网络管理协议消息明确指示的方式更改配置数据存储。例如,数据模型可以定义在客户端不提供时分配给系统生成值的LEAF。用于指定允许这些更改的情况的正式机制超出了本规范的范围。

6. YANG Syntax
6. 阳语法

The YANG syntax is similar to that of SMIng [RFC3780] and programming languages like C and C++. This C-like syntax was chosen specifically for its readability, since YANG values the time and effort of the readers of models above those of modules writers and YANG tool-chain developers. This section introduces the YANG syntax.

杨语法类似于SMI[RCF380]和C语言和C++语言。这种类似C的语法是专门为其可读性而选择的,因为YANG重视模型读者的时间和精力,而不是模块作者和YANG工具链开发人员的时间和精力。本节介绍YANG语法。

Legal characters in YANG modules are the Unicode and ISO/IEC 10646 [ISO.10646] characters, including tab, carriage return, and line feed but excluding the other C0 control characters, the surrogate blocks, and the noncharacters. The character syntax is formally defined by the rule "yang-char" in Section 14.

模块中的合法字符是Unicode和ISO/IEC 10646[ISO.10646]字符,包括制表符、回车符和换行符,但不包括其他C0控制字符、代理块和非字符。字符语法由第14节中的规则“yang char”正式定义。

YANG modules and submodules are stored in files using the UTF-8 [RFC3629] character encoding.

模块和子模块使用UTF-8[RFC3629]字符编码存储在文件中。

Lines in a YANG module end with a carriage return-line feed combination or with a line feed alone. A carriage return that is not followed by a line feed may only appear inside a quoted string (Section 6.1.3). Note that carriage returns and line feeds that appear inside quoted strings become part of the value of the string without modification; the value of a multi-line quoted string contains the same form of line ends as those lines of the YANG module.

杨氏模块中的管线以托架返回管线馈送组合或单独管线馈送结束。未后跟换行符的回车符只能出现在带引号的字符串中(第6.1.3节)。请注意,出现在带引号的字符串中的回车符和换行符在未经修改的情况下成为字符串值的一部分;多行引号字符串的值包含与模块中的行相同形式的行尾。

6.1. Lexical Tokenization
6.1. 词汇标记化

YANG modules are parsed as a series of tokens. This section details the rules for recognizing tokens from an input stream. YANG tokenization rules are both simple and powerful. The simplicity is driven by a need to keep the parsers easy to implement, while the power is driven by the fact that modelers need to express their models in readable formats.

YANG模块被解析为一系列标记。本节详细介绍了从输入流识别令牌的规则。YANG标记化规则既简单又强大。简单性是由保持解析器易于实现的需要驱动的,而强大的驱动力是由建模者需要以可读的格式表达他们的模型这一事实驱动的。

6.1.1. Comments
6.1.1. 评论

Comments are C++ style. A single line comment starts with "//" and ends at the end of the line. A block comment starts with "/*" and ends with the nearest following "*/".

注释是C++风格。单行注释以“/”开头,并在行尾结束。块注释以“/*”开头,以最近的“*/”结尾。

Note that inside a quoted string (Section 6.1.3), these character pairs are never interpreted as the start or end of a comment.

请注意,在带引号的字符串中(第6.1.3节),这些字符对永远不会解释为注释的开始或结束。

6.1.2. Tokens
6.1.2. 代币

A token in YANG is either a keyword, a string, a semicolon (";"), or braces ("{" or "}"). A string can be quoted or unquoted. A keyword is either one of the YANG keywords defined in this document, or a prefix identifier, followed by a colon (":"), followed by a language extension keyword. Keywords are case sensitive. See Section 6.2 for a formal definition of identifiers.

YANG中的标记可以是关键字、字符串、分号(“;”)或大括号(“{”或“}”)。字符串可以是带引号的或不带引号的。关键字可以是本文档中定义的关键字之一,也可以是前缀标识符,后跟冒号(“:”),后跟语言扩展关键字。关键字区分大小写。标识符的正式定义见第6.2节。

6.1.3. Quoting
6.1.3. 引用

An unquoted string is any sequence of characters that does not contain any space, tab, carriage return, or line feed characters, a single or double quote character, a semicolon (";"), braces ("{" or "}"), or comment sequences ("//", "/*", or "*/").

无引号字符串是不包含任何空格、制表符、回车符或换行符、单引号或双引号字符、分号(“;”)、大括号(“{”或“}”)或注释序列(“//”、“/*”)的任何字符序列。

Note that any keyword can legally appear as an unquoted string.

请注意,任何关键字都可以合法地显示为不带引号的字符串。

Within an unquoted string, every character is preserved. Note that this means that the backslash character does not have any special meaning in an unquoted string.

在不带引号的字符串中,每个字符都被保留。请注意,这意味着反斜杠字符在无引号的字符串中没有任何特殊含义。

If a double-quoted string contains a line break followed by space or tab characters that are used to indent the text according to the layout in the YANG file, this leading whitespace is stripped from the string, up to and including the column of the starting double quote character, or to the first non-whitespace character, whichever occurs first. Any tab character in a succeeding line that must be examined for stripping is first converted into 8 space characters.

如果双引号字符串包含一个换行符,后跟空格或制表符,用于根据YANG文件中的布局缩进文本,则该前导空格将从字符串中剥离,直至并包括起始双引号字符的列,或第一个非空格字符,以先发生的为准。后续行中必须进行剥离检查的任何制表符首先转换为8个空格字符。

If a double-quoted string contains space or tab characters before a line break, this trailing whitespace is stripped from the string.

如果双引号字符串在换行符之前包含空格或制表符,则会从字符串中删除该尾随空格。

A single-quoted string (enclosed within ' ') preserves each character within the quotes. A single quote character cannot occur in a single-quoted string, even when preceded by a backslash.

单引号字符串(括在“”中)保留引号中的每个字符。单引号字符不能出现在单引号字符串中,即使前面有反斜杠。

Within a double-quoted string (enclosed within " "), a backslash character introduces a representation of a special character, which depends on the character that immediately follows the backslash:

在双引号字符串(括在“”中)中,反斜杠字符引入特殊字符的表示形式,这取决于紧跟在反斜杠后面的字符:

\n newline \t a tab character \" a double quote \\ a single backslash

\n换行符\t制表符\“双引号\\单反斜杠”

The backslash MUST NOT be followed by any other character.

反斜杠后面不能跟任何其他字符。

If a quoted string is followed by a plus character ("+"), followed by another quoted string, the two strings are concatenated into one string, allowing multiple concatenations to build one string. Whitespace, line breaks, and comments are allowed between the quoted strings and the plus character.

如果一个带引号的字符串后跟一个加号(“+”),后跟另一个带引号的字符串,则这两个字符串将连接成一个字符串,从而允许多个连接生成一个字符串。带引号的字符串和加号字符之间允许有空格、换行符和注释。

In double-quoted strings, whitespace trimming is done before substitution of backslash-escaped characters. Concatenation is performed as the last step.

在双引号字符串中,空格修剪是在替换反斜杠转义字符之前完成的。连接作为最后一步执行。

6.1.3.1. Quoting Examples
6.1.3.1. 举出例子

The following strings are equivalent:

以下字符串是等效的:

hello "hello" 'hello' "hel" + "lo" 'hel' + "lo"

喂喂喂喂喂喂喂喂喂喂喂喂喂喂喂喂喂喂喂喂喂喂喂喂喂喂喂喂喂

The following examples show some special strings:

以下示例显示了一些特殊字符串:

"\"" - string containing a double quote '"' - string containing a double quote "\n" - string containing a newline character '\n' - string containing a backslash followed by the character n

“\”“-包含双引号的字符串”-包含双引号的字符串“\n”-包含换行符“\n”-包含反斜杠后跟字符n的字符串

The following examples show some illegal strings:

以下示例显示了一些非法字符串:

'''' - a single-quoted string cannot contain single quotes """ - a double quote must be escaped in a double-quoted string

“”“”-单引号字符串不能包含单引号“”-双引号字符串中必须转义双引号

The following strings are equivalent:

以下字符串是等效的:

"first line second line"

“第一行第二行”

"first line\n" + " second line"

“第一行\n”+“第二行”

6.2. Identifiers
6.2. 标识符

Identifiers are used to identify different kinds of YANG items by name. Each identifier starts with an uppercase or lowercase ASCII letter or an underscore character, followed by zero or more ASCII letters, digits, underscore characters, hyphens, and dots. Implementations MUST support identifiers up to 64 characters in length and MAY support longer identifiers. Identifiers are case sensitive. The identifier syntax is formally defined by the rule "identifier" in Section 14. Identifiers can be specified as quoted or unquoted strings.

标识符用于按名称标识不同种类的项目。每个标识符以大写或小写ASCII字母或下划线字符开头,后跟零个或多个ASCII字母、数字、下划线字符、连字符和点。实现必须支持长度不超过64个字符的标识符,并且可能支持更长的标识符。标识符区分大小写。标识符语法由第14节中的“标识符”规则正式定义。标识符可以指定为带引号或不带引号的字符串。

6.2.1. Identifiers and Their Namespaces
6.2.1. 标识符及其名称空间

Each identifier is valid in a namespace that depends on the type of the YANG item being defined. All identifiers defined in a namespace MUST be unique.

每个标识符在命名空间中都是有效的,该命名空间取决于所定义项的类型。命名空间中定义的所有标识符都必须是唯一的。

o All module and submodule names share the same global module identifier namespace.

o 所有模块和子模块名称共享相同的全局模块标识符命名空间。

o All extension names defined in a module and its submodules share the same extension identifier namespace.

o 模块及其子模块中定义的所有扩展名共享相同的扩展标识符命名空间。

o All feature names defined in a module and its submodules share the same feature identifier namespace.

o 模块及其子模块中定义的所有功能名称共享相同的功能标识符命名空间。

o All identity names defined in a module and its submodules share the same identity identifier namespace.

o 模块及其子模块中定义的所有标识名共享相同的标识标识符命名空间。

o All derived type names defined within a parent node or at the top level of the module or its submodules share the same type identifier namespace. This namespace is scoped to all descendant nodes of the parent node or module. This means that any descendant node may use that typedef, and it MUST NOT define a typedef with the same name.

o 在父节点内或在模块或其子模块的顶层定义的所有派生类型名称共享相同的类型标识符命名空间。此命名空间的作用域为父节点或模块的所有子节点。这意味着任何子节点都可以使用该typedef,并且它不能定义具有相同名称的typedef。

o All grouping names defined within a parent node or at the top level of the module or its submodules share the same grouping identifier namespace. This namespace is scoped to all descendant nodes of the parent node or module. This means that any descendant node may use that grouping, and it MUST NOT define a grouping with the same name.

o 在父节点内或在模块或其子模块的顶层定义的所有分组名称共享相同的分组标识符命名空间。此命名空间的作用域为父节点或模块的所有子节点。这意味着任何子节点都可以使用该分组,并且不能使用相同的名称定义分组。

o All leafs, leaf-lists, lists, containers, choices, rpcs, actions, notifications, anydatas, and anyxmls defined (directly or through a "uses" statement) within a parent node or at the top level of the module or its submodules share the same identifier namespace. This namespace is scoped to the parent node or module, unless the parent node is a case node. In that case, the namespace is scoped to the closest ancestor node that is not a case or choice node.

o 父节点内或模块或其子模块顶层定义的所有叶、叶列表、列表、容器、选项、RPC、操作、通知、anydata和anyxml(直接或通过“uses”语句)共享相同的标识符命名空间。除非父节点是案例节点,否则此命名空间的作用域为父节点或模块。在这种情况下,名称空间的作用域是最接近的祖先节点,该节点不是case或choice节点。

o All cases within a choice share the same case identifier namespace. This namespace is scoped to the parent choice node.

o 选项中的所有案例共享相同的案例标识符命名空间。此命名空间的作用域为父选择节点。

Forward references are allowed in YANG.

在YANG中允许向前引用。

6.3. Statements
6.3. 声明

A YANG module contains a sequence of statements. Each statement starts with a keyword, followed by zero or one argument, followed by either a semicolon (";") or a block of substatements enclosed within braces ("{ }"):

模块包含一系列语句。每个语句都以关键字开头,后跟零或一个参数,后跟分号(;)或大括号({})中包含的子语句块:

     statement = keyword [argument] (";" / "{" *statement "}")
        
     statement = keyword [argument] (";" / "{" *statement "}")
        

The argument is a string, as defined in Section 6.1.2.

参数是一个字符串,如第6.1.2节所定义。

6.3.1. Language Extensions
6.3.1. 语言外延

A module can introduce YANG extensions by using the "extension" keyword (see Section 7.19). The extensions can be imported by other modules with the "import" statement (see Section 7.1.5). When an imported extension is used, the extension's keyword MUST be qualified using the prefix with which the extension's module was imported. If an extension is used in the module where it is defined, the extension's keyword MUST be qualified with the prefix of this module.

一个模块可以通过使用“extension”关键字引入YANG扩展(参见第7.19节)。其他模块可以使用“导入”语句导入扩展(参见第7.1.5节)。使用导入的扩展时,必须使用导入扩展模块时使用的前缀限定扩展的关键字。如果在定义扩展的模块中使用扩展,则扩展的关键字必须使用此模块的前缀限定。

The processing of extensions depends on whether support for those extensions is claimed for a given YANG parser or the tool set in which it is embedded. An unsupported extension appearing in a YANG module as an unknown-statement (see Section 14) MAY be ignored in its entirety. Any supported extension MUST be processed in accordance with the specification governing that extension.

扩展的处理取决于对这些扩展的支持是针对给定的语法分析器还是嵌入该语法分析器的工具集。在YANG模块中出现的作为未知语句的不受支持的扩展(参见第14节)可以全部忽略。任何受支持的扩展必须按照管理该扩展的规范进行处理。

Care must be taken when defining extensions so that modules that use the extensions are meaningful also for applications that do not support the extensions.

定义扩展时必须小心,以便使用扩展的模块对不支持扩展的应用程序也有意义。

6.4. XPath Evaluations
6.4. XPath求值

YANG relies on XML Path Language (XPath) 1.0 [XPATH] as a notation for specifying many inter-node references and dependencies. An implementation is not required to implement an XPath interpreter but MUST ensure that the requirements encoded in the data model are enforced. The manner of enforcement is an implementation decision. The XPath expressions MUST be syntactically correct, and all prefixes used MUST be present in the XPath context (see Section 6.4.1). An implementation may choose to implement them by hand, rather than using the XPath expression directly.

YANG依赖XML路径语言(XPath)1.0[XPath]作为指定许多节点间引用和依赖关系的表示法。实现XPath解释器不需要实现,但必须确保执行数据模型中编码的需求。执行方式是一项执行决定。XPath表达式必须语法正确,并且使用的所有前缀必须出现在XPath上下文中(请参见第6.4.1节)。实现可以选择手工实现,而不是直接使用XPath表达式。

The data model used in the XPath expressions is the same as that used in XPath 1.0 [XPATH], with the same extension for root node children as used by XSLT 1.0 (see Section 3.1 in [XSLT]). Specifically, it means that the root node may have any number of element nodes as its children.

XPath表达式中使用的数据模型与XPath 1.0[XPath]中使用的数据模型相同,根节点子节点的扩展与XSLT 1.0使用的扩展相同(请参见[XSLT]中的第3.1节)。具体来说,这意味着根节点可以有任意数量的元素节点作为其子节点。

The data tree has no concept of document order. An implementation needs to choose some document order, but how it is done is an implementation decision. This means that XPath expressions in YANG modules SHOULD NOT rely on any specific document order.

数据树没有文档顺序的概念。一个实现需要选择一些文档顺序,但如何执行是一个实现决策。这意味着模块中的XPath表达式不应该依赖于任何特定的文档顺序。

Numbers in XPath 1.0 are IEEE 754 [IEEE754-2008] double-precision floating-point values; see Section 3.5 in [XPATH]. This means that some values of int64, uint64, and decimal64 types (see Sections 9.2 and 9.3) cannot be exactly represented in XPath expressions. Therefore, due caution should be exercised when using nodes with 64-bit numeric values in XPath expressions. In particular, numerical comparisons involving equality may yield unexpected results.

XPath 1.0中的数字是IEEE 754[IEEE754-2008]双精度浮点值;请参见[XPATH]中的第3.5节。这意味着int64、uint64和decimal64类型的某些值(参见第9.2节和第9.3节)无法在XPath表达式中精确表示。因此,在XPath表达式中使用具有64位数值的节点时,应特别小心。特别是,涉及等式的数值比较可能会产生意想不到的结果。

For example, consider the following definition:

例如,考虑下面的定义:

     leaf lxiv {
       type decimal64 {
         fraction-digits 18;
       }
       must ". <= 10";
     }
        
     leaf lxiv {
       type decimal64 {
         fraction-digits 18;
       }
       must ". <= 10";
     }
        

An instance of the "lxiv" leaf having the value of 10.0000000000000001 will then successfully pass validation.

值为10.0000000000000001的“lxiv”叶实例将成功通过验证。

6.4.1. XPath Context
6.4.1. XPath上下文

All YANG XPath expressions share the following XPath context definition:

所有XPath表达式共享以下XPath上下文定义:

o The set of namespace declarations is the set of all "import" statements' prefix and namespace pairs in the module where the XPath expression is specified, and the "prefix" statement's prefix for the "namespace" statement's URI.

o 名称空间声明集是指定XPath表达式的模块中所有“导入”语句的前缀和名称空间对的集合,以及“名称空间”语句URI的“前缀”语句的前缀。

o Names without a namespace prefix belong to the same namespace as the identifier of the current node. Inside a grouping, that namespace is affected by where the grouping is used (see Section 7.13). Inside a typedef, that namespace is affected by where the typedef is referenced. If a typedef is defined and referenced within a grouping, the namespace is affected by where the grouping is used (see Section 7.13).

o 没有名称空间前缀的名称与当前节点的标识符属于同一名称空间。在分组中,名称空间受分组使用位置的影响(参见第7.13节)。在typedef中,该名称空间受typedef引用位置的影响。如果在分组中定义并引用了typedef,则名称空间受分组使用位置的影响(请参见第7.13节)。

o The function library is the core function library defined in [XPATH] and the functions defined in Section 10.

o 函数库是[XPATH]中定义的核心函数库和第10节中定义的函数。

o The set of variable bindings is empty.

o 变量绑定集为空。

The mechanism for handling unprefixed names is adopted from XPath 2.0 [XPATH2.0] and helps simplify XPath expressions in YANG. No ambiguity may ever arise, because YANG node identifiers are always qualified names with a non-null namespace URI.

处理不固定名称的机制来自XPATH2.0[XPATH2.0],有助于简化XML中的XPath表达式。不会出现歧义,因为节点标识符始终是具有非空命名空间URI的限定名称。

The accessible tree depends on where the statement with the XPath expression is defined:

可访问树取决于使用XPath表达式定义语句的位置:

o If the XPath expression is defined in a substatement to a data node that represents configuration, the accessible tree is the data in the datastore where the context node exists. The root node has all top-level configuration data nodes in all modules as children.

o 如果XPath表达式是在表示配置的数据节点的子状态中定义的,则可访问树是存在上下文节点的数据存储中的数据。根节点将所有模块中的所有顶级配置数据节点作为子节点。

o If the XPath expression is defined in a substatement to a data node that represents state data, the accessible tree is all state data in the server, and the running configuration datastore. The root node has all top-level data nodes in all modules as children.

o 如果XPath表达式是在表示状态数据的数据节点的子状态中定义的,则可访问树是服务器中的所有状态数据以及正在运行的配置数据存储。根节点将所有模块中的所有顶级数据节点作为子节点。

o If the XPath expression is defined in a substatement to a "notification" statement, the accessible tree is the notification instance, all state data in the server, and the running configuration datastore. If the notification is defined on the top level in a module, then the root node has the node

o 如果XPath表达式是在“notification”语句的子语句中定义的,那么可访问的树就是通知实例、服务器中的所有状态数据以及正在运行的配置数据存储。如果通知是在模块的顶层定义的,则根节点具有该节点

representing the notification being defined and all top-level data nodes in all modules as children. Otherwise, the root node has all top-level data nodes in all modules as children.

将正在定义的通知和所有模块中的所有顶级数据节点表示为子节点。否则,根节点将所有模块中的所有顶级数据节点作为子节点。

o If the XPath expression is defined in a substatement to an "input" statement in an "rpc" or "action" statement, the accessible tree is the RPC or action operation instance, all state data in the server, and the running configuration datastore. The root node has top-level data nodes in all modules as children. Additionally, for an RPC, the root node also has the node representing the RPC operation being defined as a child. The node representing the operation being defined has the operation's input parameters as children.

o 如果XPath表达式是在“rpc”或“action”语句中的“input”语句的子语句中定义的,则可访问的树是rpc或action操作实例、服务器中的所有状态数据以及正在运行的配置数据存储。根节点在所有模块中都有顶级数据节点作为子节点。此外,对于RPC,根节点还将表示RPC操作的节点定义为子节点。表示所定义操作的节点将操作的输入参数作为子节点。

o If the XPath expression is defined in a substatement to an "output" statement in an "rpc" or "action" statement, the accessible tree is the RPC or action operation instance, all state data in the server, and the running configuration datastore. The root node has top-level data nodes in all modules as children. Additionally, for an RPC, the root node also has the node representing the RPC operation being defined as a child. The node representing the operation being defined has the operation's output parameters as children.

o 如果XPath表达式是在“rpc”或“action”语句中的“output”语句的子语句中定义的,则可访问的树是rpc或action操作实例、服务器中的所有状态数据以及正在运行的配置数据存储。根节点在所有模块中都有顶级数据节点作为子节点。此外,对于RPC,根节点还将表示RPC操作的节点定义为子节点。表示所定义操作的节点将操作的输出参数作为子级。

In the accessible tree, all leafs and leaf-lists with default values in use exist (see Sections 7.6.1 and 7.7.2).

在可访问树中,存在使用默认值的所有叶和叶列表(见第7.6.1和7.7.2节)。

If a node that exists in the accessible tree has a non-presence container as a child, then the non-presence container also exists in the accessible tree.

如果存在于可访问树中的节点具有作为子节点的不存在容器,则该不存在容器也存在于可访问树中。

The context node varies with the YANG XPath expression and is specified where the YANG statement with the XPath expression is defined.

上下文节点随YANG XPath表达式的不同而变化,并在定义带有XPath表达式的YANG语句的位置指定。

6.4.1.1. Examples
6.4.1.1. 例子

Given the following module:

鉴于以下模块:

     module example-a {
       yang-version 1.1;
       namespace urn:example:a;
       prefix a;
        
     module example-a {
       yang-version 1.1;
       namespace urn:example:a;
       prefix a;
        
       container a {
         list b {
           key id;
           leaf id {
             type string;
           }
           notification down {
             leaf reason {
               type string;
             }
           }
           action reset {
             input {
               leaf delay {
                 type uint32;
               }
             }
             output {
               leaf result {
                 type string;
               }
             }
           }
         }
       }
       notification failure {
         leaf b-ref {
           type leafref {
             path "/a/b/id";
           }
         }
       }
     }
        
       container a {
         list b {
           key id;
           leaf id {
             type string;
           }
           notification down {
             leaf reason {
               type string;
             }
           }
           action reset {
             input {
               leaf delay {
                 type uint32;
               }
             }
             output {
               leaf result {
                 type string;
               }
             }
           }
         }
       }
       notification failure {
         leaf b-ref {
           type leafref {
             path "/a/b/id";
           }
         }
       }
     }
        

and given the following data tree, specified in XML:

并给出以下以XML指定的数据树:

     <a xmlns="urn:example:a">
       <b>
         <id>1</id>
       </b>
       <b>
         <id>2</id>
       </b>
     </a>
        
     <a xmlns="urn:example:a">
       <b>
         <id>1</id>
       </b>
       <b>
         <id>2</id>
       </b>
     </a>
        

The accessible tree for a notification "down" on /a/b[id="2"] is:

/a/b[id=“2”]上通知“关闭”的可访问树为:

     <a xmlns="urn:example:a">
       <b>
         <id>1</id>
       </b>
       <b>
         <id>2</id>
         <down>
           <reason>error</reason>
         </down>
       </b>
     </a>
     // possibly other top-level nodes here
        
     <a xmlns="urn:example:a">
       <b>
         <id>1</id>
       </b>
       <b>
         <id>2</id>
         <down>
           <reason>error</reason>
         </down>
       </b>
     </a>
     // possibly other top-level nodes here
        

The accessible tree for an action invocation of "reset" on /a/b[id="1"] with the "when" parameter set to "10" would be:

当“when”参数设置为“10”时,/a/b[id=“1”]上的“reset”操作调用的可访问树为:

     <a xmlns="urn:example:a">
       <b>
         <id>1</id>
         <reset>
           <delay>10</delay>
         </reset>
       </b>
       <b>
         <id>2</id>
       </b>
     </a>
     // possibly other top-level nodes here
        
     <a xmlns="urn:example:a">
       <b>
         <id>1</id>
         <reset>
           <delay>10</delay>
         </reset>
       </b>
       <b>
         <id>2</id>
       </b>
     </a>
     // possibly other top-level nodes here
        

The accessible tree for the action output of this action is:

此操作的操作输出的可访问树为:

     <a xmlns="urn:example:a">
       <b>
         <id>1</id>
         <reset>
           <result>ok</result>
         </reset>
       </b>
       <b>
         <id>2</id>
       </b>
     </a>
     // possibly other top-level nodes here
        
     <a xmlns="urn:example:a">
       <b>
         <id>1</id>
         <reset>
           <result>ok</result>
         </reset>
       </b>
       <b>
         <id>2</id>
       </b>
     </a>
     // possibly other top-level nodes here
        

The accessible tree for a notification "failure" could be:

通知“失败”的可访问树可以是:

     <a xmlns="urn:example:a">
       <b>
         <id>1</id>
       </b>
       <b>
         <id>2</id>
       </b>
     </a>
     <failure>
       <b-ref>2</b-ref>
     </failure>
     // possibly other top-level nodes here
        
     <a xmlns="urn:example:a">
       <b>
         <id>1</id>
       </b>
       <b>
         <id>2</id>
       </b>
     </a>
     <failure>
       <b-ref>2</b-ref>
     </failure>
     // possibly other top-level nodes here
        
6.5. Schema Node Identifier
6.5. 模式节点标识符

A schema node identifier is a string that identifies a node in the schema tree. It has two forms, "absolute" and "descendant", defined by the rules "absolute-schema-nodeid" and "descendant-schema-nodeid" in Section 14, respectively. A schema node identifier consists of a path of identifiers, separated by slashes ("/"). In an absolute schema node identifier, the first identifier after the leading slash is any top-level schema node in the local module or in an imported module.

架构节点标识符是标识架构树中节点的字符串。它有两种形式,“绝对”和“后代”,分别由第14节中的规则“绝对模式节点ID”和“后代模式节点ID”定义。架构节点标识符由标识符路径组成,由斜杠(“/”)分隔。在绝对模式节点标识符中,前导斜杠后的第一个标识符是本地模块或导入模块中的任何顶级模式节点。

References to identifiers defined in external modules MUST be qualified with appropriate prefixes, and references to identifiers defined in the current module and its submodules MAY use a prefix.

对外部模块中定义的标识符的引用必须使用适当的前缀进行限定,对当前模块及其子模块中定义的标识符的引用可以使用前缀。

For example, to identify the child node "b" of top-level node "a", the string "/a/b" can be used.

例如,要标识顶级节点“a”的子节点“b”,可以使用字符串“/a/b”。

7. YANG Statements
7. 杨声明

The following sections describe all of the YANG statements.

以下各节描述了所有杨陈述。

Note that even a statement that does not have any substatements defined in YANG can have vendor-specific extensions as substatements. For example, the "description" statement does not have any substatements defined in YANG, but the following is legal:

请注意,即使没有在YANG中定义任何子状态的语句也可以将特定于供应商的扩展作为子状态。例如,“description”语句在YANG中没有定义任何子语句,但以下语句是合法的:

     description "Some text." {
       ex:documentation-flag 5;
     }
        
     description "Some text." {
       ex:documentation-flag 5;
     }
        
7.1. The "module" Statement
7.1. “模块”语句

The "module" statement defines the module's name and groups all statements that belong to the module together. The "module" statement's argument is the name of the module, followed by a block of substatements that holds detailed module information. The module name is an identifier (see Section 6.2).

“module”语句定义模块的名称,并将属于该模块的所有语句分组在一起。“module”语句的参数是模块的名称,后跟一个包含详细模块信息的子语句块。模块名称是一个标识符(见第6.2节)。

Names of modules published in RFC streams [RFC4844] MUST be assigned by IANA; see Section 14 in [RFC6020].

在RFC流[RFC4844]中发布的模块名称必须由IANA分配;参见[RFC6020]中的第14节。

Private module names are assigned by the organization owning the module without a central registry. See Section 5.1 for recommendations on how to name modules.

私有模块名称由拥有该模块的组织分配,而无需中央注册表。有关如何命名模块的建议,请参见第5.1节。

A module typically has the following layout:

模块通常具有以下布局:

     module <module-name> {
        
     module <module-name> {
        
       // header information
       <yang-version statement>
       <namespace statement>
       <prefix statement>
        
       // header information
       <yang-version statement>
       <namespace statement>
       <prefix statement>
        
       // linkage statements
       <import statements>
       <include statements>
        
       // linkage statements
       <import statements>
       <include statements>
        
       // meta-information
       <organization statement>
       <contact statement>
       <description statement>
       <reference statement>
        
       // meta-information
       <organization statement>
       <contact statement>
       <description statement>
       <reference statement>
        
       // revision history
       <revision statements>
        
       // revision history
       <revision statements>
        
       // module definitions
       <other statements>
     }
        
       // module definitions
       <other statements>
     }
        
7.1.1. The module's Substatements
7.1.1. 模块的子状态
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | anydata      | 7.10    | 0..n        |
                 | anyxml       | 7.11    | 0..n        |
                 | augment      | 7.17    | 0..n        |
                 | choice       | 7.9     | 0..n        |
                 | contact      | 7.1.8   | 0..1        |
                 | container    | 7.5     | 0..n        |
                 | description  | 7.21.3  | 0..1        |
                 | deviation    | 7.20.3  | 0..n        |
                 | extension    | 7.19    | 0..n        |
                 | feature      | 7.20.1  | 0..n        |
                 | grouping     | 7.12    | 0..n        |
                 | identity     | 7.18    | 0..n        |
                 | import       | 7.1.5   | 0..n        |
                 | include      | 7.1.6   | 0..n        |
                 | leaf         | 7.6     | 0..n        |
                 | leaf-list    | 7.7     | 0..n        |
                 | list         | 7.8     | 0..n        |
                 | namespace    | 7.1.3   | 1           |
                 | notification | 7.16    | 0..n        |
                 | organization | 7.1.7   | 0..1        |
                 | prefix       | 7.1.4   | 1           |
                 | reference    | 7.21.4  | 0..1        |
                 | revision     | 7.1.9   | 0..n        |
                 | rpc          | 7.14    | 0..n        |
                 | typedef      | 7.3     | 0..n        |
                 | uses         | 7.13    | 0..n        |
                 | yang-version | 7.1.2   | 1           |
                 +--------------+---------+-------------+
        
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | anydata      | 7.10    | 0..n        |
                 | anyxml       | 7.11    | 0..n        |
                 | augment      | 7.17    | 0..n        |
                 | choice       | 7.9     | 0..n        |
                 | contact      | 7.1.8   | 0..1        |
                 | container    | 7.5     | 0..n        |
                 | description  | 7.21.3  | 0..1        |
                 | deviation    | 7.20.3  | 0..n        |
                 | extension    | 7.19    | 0..n        |
                 | feature      | 7.20.1  | 0..n        |
                 | grouping     | 7.12    | 0..n        |
                 | identity     | 7.18    | 0..n        |
                 | import       | 7.1.5   | 0..n        |
                 | include      | 7.1.6   | 0..n        |
                 | leaf         | 7.6     | 0..n        |
                 | leaf-list    | 7.7     | 0..n        |
                 | list         | 7.8     | 0..n        |
                 | namespace    | 7.1.3   | 1           |
                 | notification | 7.16    | 0..n        |
                 | organization | 7.1.7   | 0..1        |
                 | prefix       | 7.1.4   | 1           |
                 | reference    | 7.21.4  | 0..1        |
                 | revision     | 7.1.9   | 0..n        |
                 | rpc          | 7.14    | 0..n        |
                 | typedef      | 7.3     | 0..n        |
                 | uses         | 7.13    | 0..n        |
                 | yang-version | 7.1.2   | 1           |
                 +--------------+---------+-------------+
        
7.1.2. The "yang-version" Statement
7.1.2. “杨版”声明

The "yang-version" statement specifies which version of the YANG language was used in developing the module. The statement's argument is a string. It MUST contain the value "1.1" for YANG modules defined based on this specification.

“yang version”语句指定在开发模块时使用的yang语言版本。语句的参数是字符串。它必须包含根据本规范定义的模块的值“1.1”。

A module or submodule that doesn't contain the "yang-version" statement, or one that contains the value "1", is developed for YANG version 1, defined in [RFC6020].

不包含“yang version”语句或包含值“1”的模块或子模块是为[RFC6020]中定义的yang version 1开发的。

Handling of the "yang-version" statement for versions other than "1.1" (the version defined here) is out of scope for this specification. Any document that defines a higher version will need to define the backward compatibility of such a higher version.

对于“1.1”以外的版本(此处定义的版本)处理“yang version”语句超出了本规范的范围。任何定义更高版本的文档都需要定义这样一个更高版本的向后兼容性。

For compatibility between YANG versions 1 and 1.1, see Section 12.

有关版本1和1.1之间的兼容性,请参见第12节。

7.1.3. The "namespace" Statement
7.1.3. “namespace”语句

The "namespace" statement defines the XML namespace that all identifiers defined by the module are qualified by in the XML encoding, with the exception of identifiers for data nodes, action nodes, and notification nodes defined inside a grouping (see Section 7.13 for details). The argument to the "namespace" statement is the URI of the namespace.

“namespace”语句定义了XML名称空间,模块定义的所有标识符在XML编码中都由该名称空间限定,但分组中定义的数据节点、操作节点和通知节点的标识符除外(有关详细信息,请参阅第7.13节)。“namespace”语句的参数是名称空间的URI。

See also Section 5.3.

另见第5.3节。

7.1.4. The "prefix" Statement
7.1.4. “前缀”语句

The "prefix" statement is used to define the prefix associated with the module and its namespace. The "prefix" statement's argument is the prefix string that is used as a prefix to access a module. The prefix string MAY be used with the module to refer to definitions contained in the module, e.g., "if:ifName". A prefix is an identifier (see Section 6.2).

“prefix”语句用于定义与模块及其命名空间关联的前缀。“prefix”语句的参数是用作访问模块前缀的前缀字符串。前缀字符串可与模块一起使用,以引用模块中包含的定义,例如,“if:ifName”。前缀是一种标识符(见第6.2节)。

When used inside the "module" statement, the "prefix" statement defines the prefix suggested to be used when this module is imported.

在“module”语句中使用时,“prefix”语句定义导入此模块时建议使用的前缀。

To improve readability of the NETCONF XML, a NETCONF client or server that generates XML or XPath that uses prefixes SHOULD use the prefix defined by the module as the XML namespace prefix, unless there is a conflict.

为提高NETCONF XML的可读性,生成使用前缀的XML或XPath的NETCONF客户端或服务器应使用模块定义的前缀作为XML命名空间前缀,除非存在冲突。

When used inside the "import" statement, the "prefix" statement defines the prefix to be used when accessing definitions inside the imported module. When a reference to an identifier from the imported module is used, the prefix string for the imported module followed by a colon (":") and the identifier is used, e.g., "if:ifIndex". To improve readability of YANG modules, the prefix defined by a module SHOULD be used when the module is imported, unless there is a conflict. If there is a conflict, i.e., two different modules that both have defined the same prefix are imported, at least one of them MUST be imported with a different prefix.

在“import”语句中使用时,“prefix”语句定义访问导入模块中的定义时要使用的前缀。使用对导入模块标识符的引用时,将使用导入模块的前缀字符串,后跟冒号(“:”)和标识符,例如“if:ifIndex”。为提高模块的可读性,导入模块时应使用模块定义的前缀,除非存在冲突。如果存在冲突,即导入两个定义了相同前缀的不同模块,则必须使用不同前缀导入其中至少一个模块。

All prefixes, including the prefix for the module itself, MUST be unique within the module or submodule.

所有前缀(包括模块本身的前缀)在模块或子模块中必须是唯一的。

7.1.5. The "import" Statement
7.1.5. “进口”声明

The "import" statement makes definitions from one module available inside another module or submodule. The argument is the name of the module to import, and the statement is followed by a block of substatements that holds detailed import information. When a module is imported, the importing module may:

“import”语句使一个模块中的定义在另一个模块或子模块中可用。参数是要导入的模块的名称,语句后面是一个包含详细导入信息的子语句块。导入模块时,导入模块可以:

o use any grouping and typedef defined at the top level in the imported module or its submodules.

o 使用在导入的模块或其子模块的顶层定义的任何分组和typedef。

o use any extension, feature, and identity defined in the imported module or its submodules.

o 使用导入的模块或其子模块中定义的任何扩展、功能和标识。

o use any node in the imported module's schema tree in "must", "path", and "when" statements, or as the target node in "augment" and "deviation" statements.

o 在“must”、“path”和“when”语句中使用导入模块模式树中的任何节点,或者在“augment”和“develope”语句中作为目标节点。

The mandatory "prefix" substatement assigns a prefix for the imported module that is scoped to the importing module or submodule. Multiple "import" statements may be specified to import from different modules.

必填的“prefix”子语句为导入的模块分配一个前缀,其作用域为导入模块或子模块。可以指定多个“导入”语句从不同的模块导入。

When the optional "revision-date" substatement is present, any typedef, grouping, extension, feature, and identity referenced by definitions in the local module are taken from the specified revision of the imported module. It is an error if the specified revision of the imported module does not exist. If no "revision-date" substatement is present, it is undefined from which revision of the module they are taken.

当存在可选的“修订日期”子状态时,本地模块中定义引用的任何类型定义、分组、扩展、特征和标识都将取自导入模块的指定版本。如果导入模块的指定版本不存在,则为错误。如果不存在“修订日期”子语句,则未定义从哪个版本获取这些子语句的模块。

Multiple revisions of the same module can be imported, provided that different prefixes are used.

如果使用不同的前缀,可以导入同一模块的多个版本。

                 +---------------+---------+-------------+
                 | substatement  | section | cardinality |
                 +---------------+---------+-------------+
                 | description   | 7.21.3  | 0..1        |
                 | prefix        | 7.1.4   | 1           |
                 | reference     | 7.21.4  | 0..1        |
                 | revision-date | 7.1.5.1 | 0..1        |
                 +---------------+---------+-------------+
        
                 +---------------+---------+-------------+
                 | substatement  | section | cardinality |
                 +---------------+---------+-------------+
                 | description   | 7.21.3  | 0..1        |
                 | prefix        | 7.1.4   | 1           |
                 | reference     | 7.21.4  | 0..1        |
                 | revision-date | 7.1.5.1 | 0..1        |
                 +---------------+---------+-------------+
        

The import's Substatements

导入的子语句

7.1.5.1. The import's "revision-date" Statement
7.1.5.1. 进口的“修订日期”声明

The import's "revision-date" statement is used to specify the version of the module to import.

导入的“修订日期”语句用于指定要导入的模块的版本。

7.1.6. The "include" Statement
7.1.6. “包括”声明

The "include" statement is used to make content from a submodule available to that submodule's parent module. The argument is an identifier that is the name of the submodule to include. Modules are only allowed to include submodules that belong to that module, as defined by the "belongs-to" statement (see Section 7.2.2).

“include”语句用于将子模块中的内容提供给该子模块的父模块。参数是一个标识符,它是要包含的子模块的名称。模块仅允许包含属于该模块的子模块,如“属于”语句所定义(见第7.2.2节)。

When a module includes a submodule, it incorporates the contents of the submodule into the node hierarchy of the module.

当模块包含子模块时,它会将子模块的内容合并到模块的节点层次结构中。

For backward compatibility with YANG version 1, a submodule is allowed to include another submodule belonging to the same module, but this is not necessary in YANG version 1.1 (see Section 5.1).

为了与YANG版本1向后兼容,允许子模块包含属于同一模块的另一个子模块,但在YANG版本1.1中不需要这样做(参见第5.1节)。

When the optional "revision-date" substatement is present, the specified revision of the submodule is included in the module. It is an error if the specified revision of the submodule does not exist. If no "revision-date" substatement is present, it is undefined which revision of the submodule is included.

当存在可选的“修订日期”子状态时,子模块的指定修订将包含在模块中。如果子模块的指定版本不存在,则为错误。如果不存在“修订日期”子语句,则未定义包含子模块的哪个修订。

Multiple revisions of the same submodule MUST NOT be included.

不得包含同一子模块的多个修订版。

                 +---------------+---------+-------------+
                 | substatement  | section | cardinality |
                 +---------------+---------+-------------+
                 | description   | 7.21.3  | 0..1        |
                 | reference     | 7.21.4  | 0..1        |
                 | revision-date | 7.1.5.1 | 0..1        |
                 +---------------+---------+-------------+
        
                 +---------------+---------+-------------+
                 | substatement  | section | cardinality |
                 +---------------+---------+-------------+
                 | description   | 7.21.3  | 0..1        |
                 | reference     | 7.21.4  | 0..1        |
                 | revision-date | 7.1.5.1 | 0..1        |
                 +---------------+---------+-------------+
        

The includes's Substatements

包含的子语句

7.1.7. The "organization" Statement
7.1.7. “组织”声明

The "organization" statement defines the party responsible for this module. The argument is a string that is used to specify a textual description of the organization(s) under whose auspices this module was developed.

“组织”声明定义了负责此模块的一方。参数是一个字符串,用于指定在其主持下开发此模块的组织的文本描述。

7.1.8. The "contact" Statement
7.1.8. “接触”声明

The "contact" statement provides contact information for the module. The argument is a string that is used to specify contact information for the person or persons to whom technical queries concerning this module should be sent, such as their name, postal address, telephone number, and electronic mail address.

“contact”语句提供模块的联系信息。参数是一个字符串,用于指定应向其发送有关此模块的技术查询的人员的联系信息,如姓名、邮政地址、电话号码和电子邮件地址。

7.1.9. The "revision" Statement
7.1.9. “修订”声明

The "revision" statement specifies the editorial revision history of the module, including the initial revision. A series of "revision" statements detail the changes in the module's definition. The argument is a date string in the format "YYYY-MM-DD", followed by a block of substatements that holds detailed revision information. A module SHOULD have at least one "revision" statement. For every published editorial change, a new one SHOULD be added in front of the revisions sequence so that all revisions are in reverse chronological order.

“修订”语句指定模块的编辑修订历史记录,包括初始修订。一系列“修订”声明详细说明了模块定义中的更改。参数是格式为“YYYY-MM-DD”的日期字符串,后跟一块保存详细修订信息的子状态。一个模块应该至少有一个“修订”语句。对于每个已发布的编辑更改,应在修订顺序之前添加一个新的修订,以便所有修订都按相反的时间顺序进行。

7.1.9.1. The revision's Substatements
7.1.9.1. 修订版的子条款
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | description  | 7.21.3  | 0..1        |
                 | reference    | 7.21.4  | 0..1        |
                 +--------------+---------+-------------+
        
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | description  | 7.21.3  | 0..1        |
                 | reference    | 7.21.4  | 0..1        |
                 +--------------+---------+-------------+
        
7.1.10. Usage Example
7.1.10. 用法示例

The following example relies on [RFC6991].

以下示例依赖于[RFC6991]。

     module example-system {
       yang-version 1.1;
       namespace "urn:example:system";
       prefix "sys";
        
     module example-system {
       yang-version 1.1;
       namespace "urn:example:system";
       prefix "sys";
        
       import ietf-yang-types {
         prefix "yang";
         reference "RFC 6991: Common YANG Data Types";
       }
        
       import ietf-yang-types {
         prefix "yang";
         reference "RFC 6991: Common YANG Data Types";
       }
        

include example-types;

包括示例类型;

organization "Example Inc."; contact "Joe L. User

组织“范例公司”;联系“Joe L.用户”

Example Inc. 42 Anywhere Drive Nowhere, CA 95134 USA

示例公司42 Anywhere Drive Nowhere,加利福尼亚州95134美国

          Phone: +1 800 555 0100
          Email: joe@example.com";
        
          Phone: +1 800 555 0100
          Email: joe@example.com";
        

description "The module for entities implementing the Example system.";

说明“实施示例系统的实体模块”;

       revision 2007-06-09 {
         description "Initial revision.";
       }
        
       revision 2007-06-09 {
         description "Initial revision.";
       }
        

// definitions follow... }

//定义如下…}

7.2. The "submodule" Statement
7.2. “submodule”语句

While the primary unit in YANG is a module, a YANG module can itself be constructed out of several submodules. Submodules allow a module designer to split a complex model into several pieces where all the submodules contribute to a single namespace, which is defined by the module that includes the submodules.

虽然YANG中的主要单元是一个模块,但YANG模块本身可以由几个子模块构成。子模块允许模块设计器将复杂模型拆分为多个部分,其中所有子模块都贡献给单个名称空间,该名称空间由包含子模块的模块定义。

The "submodule" statement defines the submodule's name, and it groups all statements that belong to the submodule together. The "submodule" statement's argument is the name of the submodule, followed by a block of substatements that holds detailed submodule information. The submodule name is an identifier (see Section 6.2).

“submodule”语句定义子模块的名称,并将属于该子模块的所有语句分组在一起。“submodule”语句的参数是子模块的名称,后跟一个包含详细子模块信息的子语句块。子模块名称是一个标识符(见第6.2节)。

Names of submodules published in RFC streams [RFC4844] MUST be assigned by IANA; see Section 14 in [RFC6020].

在RFC streams[RFC4844]中发布的子模块名称必须由IANA分配;参见[RFC6020]中的第14节。

Private submodule names are assigned by the organization owning the submodule without a central registry. See Section 5.1 for recommendations on how to name submodules.

私有子模块名称由拥有该子模块的组织分配,而无需中央注册表。有关如何命名子模块的建议,请参见第5.1节。

A submodule typically has the following layout:

子模块通常具有以下布局:

     submodule <module-name> {
        
     submodule <module-name> {
        

<yang-version statement>

<yang版本声明>

       // module identification
       <belongs-to statement>
        
       // module identification
       <belongs-to statement>
        
       // linkage statements
       <import statements>
        
       // linkage statements
       <import statements>
        
       // meta-information
       <organization statement>
       <contact statement>
       <description statement>
       <reference statement>
        
       // meta-information
       <organization statement>
       <contact statement>
       <description statement>
       <reference statement>
        
       // revision history
       <revision statements>
        
       // revision history
       <revision statements>
        
       // module definitions
       <other statements>
     }
        
       // module definitions
       <other statements>
     }
        
7.2.1. The submodule's Substatements
7.2.1. 子模块的子状态
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | anydata      | 7.10    | 0..n        |
                 | anyxml       | 7.11    | 0..n        |
                 | augment      | 7.17    | 0..n        |
                 | belongs-to   | 7.2.2   | 1           |
                 | choice       | 7.9     | 0..n        |
                 | contact      | 7.1.8   | 0..1        |
                 | container    | 7.5     | 0..n        |
                 | description  | 7.21.3  | 0..1        |
                 | deviation    | 7.20.3  | 0..n        |
                 | extension    | 7.19    | 0..n        |
                 | feature      | 7.20.1  | 0..n        |
                 | grouping     | 7.12    | 0..n        |
                 | identity     | 7.18    | 0..n        |
                 | import       | 7.1.5   | 0..n        |
                 | include      | 7.1.6   | 0..n        |
                 | leaf         | 7.6     | 0..n        |
                 | leaf-list    | 7.7     | 0..n        |
                 | list         | 7.8     | 0..n        |
                 | notification | 7.16    | 0..n        |
                 | organization | 7.1.7   | 0..1        |
                 | reference    | 7.21.4  | 0..1        |
                 | revision     | 7.1.9   | 0..n        |
                 | rpc          | 7.14    | 0..n        |
                 | typedef      | 7.3     | 0..n        |
                 | uses         | 7.13    | 0..n        |
                 | yang-version | 7.1.2   | 1           |
                 +--------------+---------+-------------+
        
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | anydata      | 7.10    | 0..n        |
                 | anyxml       | 7.11    | 0..n        |
                 | augment      | 7.17    | 0..n        |
                 | belongs-to   | 7.2.2   | 1           |
                 | choice       | 7.9     | 0..n        |
                 | contact      | 7.1.8   | 0..1        |
                 | container    | 7.5     | 0..n        |
                 | description  | 7.21.3  | 0..1        |
                 | deviation    | 7.20.3  | 0..n        |
                 | extension    | 7.19    | 0..n        |
                 | feature      | 7.20.1  | 0..n        |
                 | grouping     | 7.12    | 0..n        |
                 | identity     | 7.18    | 0..n        |
                 | import       | 7.1.5   | 0..n        |
                 | include      | 7.1.6   | 0..n        |
                 | leaf         | 7.6     | 0..n        |
                 | leaf-list    | 7.7     | 0..n        |
                 | list         | 7.8     | 0..n        |
                 | notification | 7.16    | 0..n        |
                 | organization | 7.1.7   | 0..1        |
                 | reference    | 7.21.4  | 0..1        |
                 | revision     | 7.1.9   | 0..n        |
                 | rpc          | 7.14    | 0..n        |
                 | typedef      | 7.3     | 0..n        |
                 | uses         | 7.13    | 0..n        |
                 | yang-version | 7.1.2   | 1           |
                 +--------------+---------+-------------+
        
7.2.2. The "belongs-to" Statement
7.2.2. “属于”声明

The "belongs-to" statement specifies the module to which the submodule belongs. The argument is an identifier that is the name of the module.

“属于”语句指定子模块所属的模块。参数是一个标识符,它是模块的名称。

A submodule MUST only be included by either the module to which it belongs or another submodule that belongs to that module.

子模块只能由其所属的模块或属于该模块的另一个子模块包含。

The mandatory "prefix" substatement assigns a prefix for the module to which the submodule belongs. All definitions in the module that the submodule belongs to and all its submodules can be accessed by using the prefix.

强制性的“prefix”子语句为子模块所属的模块指定前缀。子模块所属模块及其所有子模块中的所有定义都可以使用前缀进行访问。

                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | prefix       | 7.1.4   | 1           |
                 +--------------+---------+-------------+
        
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | prefix       | 7.1.4   | 1           |
                 +--------------+---------+-------------+
        

The belongs-to's Substatement

该函数属于的子状态

7.2.3. Usage Example
7.2.3. 用法示例
     submodule example-types {
       yang-version 1.1;
       belongs-to "example-system" {
         prefix "sys";
       }
        
     submodule example-types {
       yang-version 1.1;
       belongs-to "example-system" {
         prefix "sys";
       }
        
       import ietf-yang-types {
         prefix "yang";
       }
        
       import ietf-yang-types {
         prefix "yang";
       }
        

organization "Example Inc."; contact "Joe L. User

组织“范例公司”;联系“Joe L.用户”

Example Inc. 42 Anywhere Drive Nowhere, CA 95134 USA

示例公司42 Anywhere Drive Nowhere,加利福尼亚州95134美国

          Phone: +1 800 555 0100
          Email: joe@example.com";
        
          Phone: +1 800 555 0100
          Email: joe@example.com";
        

description "This submodule defines common Example types.";

description“此子模块定义常见的示例类型。”;

       revision "2007-06-09" {
         description "Initial revision.";
       }
        
       revision "2007-06-09" {
         description "Initial revision.";
       }
        

// definitions follow... }

//定义如下…}

7.3. The "typedef" Statement
7.3. “typedef”语句

The "typedef" statement defines a new type that may be used locally in the module or submodule, and by other modules that import from it, according to the rules in Section 5.5. The new type is called the "derived type", and the type from which it was derived is called the "base type". All derived types can be traced back to a YANG built-in type.

根据第5.5节中的规则,“typedef”语句定义了一个新类型,该类型可以在模块或子模块中本地使用,也可以由从中导入的其他模块使用。新类型称为“派生类型”,派生它的类型称为“基类型”。所有派生类型都可以追溯到内置类型。

The "typedef" statement's argument is an identifier that is the name of the type to be defined and MUST be followed by a block of substatements that holds detailed typedef information.

“typedef”语句的参数是一个标识符,它是要定义的类型的名称,后面必须跟一个包含详细typedef信息的子语句块。

The name of the type MUST NOT be one of the YANG built-in types. If the typedef is defined at the top level of a YANG module or submodule, the name of the type to be defined MUST be unique within the module.

类型的名称不能是内置类型之一。如果typedef是在模块或子模块的顶层定义的,则要定义的类型名称在模块中必须是唯一的。

7.3.1. The typedef's Substatements
7.3.1. typedef的子状态
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | default      | 7.3.4   | 0..1        |
                 | description  | 7.21.3  | 0..1        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | type         | 7.3.2   | 1           |
                 | units        | 7.3.3   | 0..1        |
                 +--------------+---------+-------------+
        
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | default      | 7.3.4   | 0..1        |
                 | description  | 7.21.3  | 0..1        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | type         | 7.3.2   | 1           |
                 | units        | 7.3.3   | 0..1        |
                 +--------------+---------+-------------+
        
7.3.2. The typedef's "type" Statement
7.3.2. typedef的“type”语句

The "type" statement, which MUST be present, defines the base type from which this type is derived. See Section 7.4 for details.

必须存在的“type”语句定义了派生此类型的基类型。详见第7.4节。

7.3.3. The "units" Statement
7.3.3. “单位”声明

The "units" statement, which is optional, takes as an argument a string that contains a textual definition of the units associated with the type.

“units”语句是可选的,它将包含与类型关联的单元的文本定义的字符串作为参数。

7.3.4. The typedef's "default" Statement
7.3.4. typedef的“default”语句

The "default" statement takes as an argument a string that contains a default value for the new type.

“default”语句将包含新类型的默认值的字符串作为参数。

The value of the "default" statement MUST be valid according to the type specified in the "type" statement.

根据“type”语句中指定的类型,“default”语句的值必须有效。

If the base type has a default value and the new derived type does not specify a new default value, the base type's default value is also the default value of the new derived type.

如果基类型具有默认值,而新派生类型未指定新的默认值,则基类型的默认值也是新派生类型的默认值。

If the type's default value is not valid according to the new restrictions specified in a derived type or leaf definition, the derived type or leaf definition MUST specify a new default value compatible with the restrictions.

如果根据派生类型或叶定义中指定的新限制,类型的默认值无效,则派生类型或叶定义必须指定与这些限制兼容的新默认值。

7.3.5. Usage Example
7.3.5. 用法示例
     typedef listen-ipv4-address {
       type inet:ipv4-address;
       default "0.0.0.0";
     }
        
     typedef listen-ipv4-address {
       type inet:ipv4-address;
       default "0.0.0.0";
     }
        
7.4. The "type" Statement
7.4. “类型”语句

The "type" statement takes as an argument a string that is the name of a YANG built-in type (see Section 9) or a derived type (see Section 7.3), followed by an optional block of substatements that is used to put further restrictions on the type.

“type”语句将一个字符串作为参数,该字符串是内置类型(见第9节)或派生类型(见第7.3节)的名称,后跟一个可选的子语句块,用于对该类型施加进一步的限制。

The restrictions that can be applied depend on the type being restricted. The restriction statements for all built-in types are described in the subsections of Section 9.

可以应用的限制取决于被限制的类型。所有内置类型的限制说明见第9节的小节。

7.4.1. The type's Substatements
7.4.1. 类型的子状态
               +------------------+---------+-------------+
               | substatement     | section | cardinality |
               +------------------+---------+-------------+
               | base             | 7.18.2  | 0..n        |
               | bit              | 9.7.4   | 0..n        |
               | enum             | 9.6.4   | 0..n        |
               | fraction-digits  | 9.3.4   | 0..1        |
               | length           | 9.4.4   | 0..1        |
               | path             | 9.9.2   | 0..1        |
               | pattern          | 9.4.5   | 0..n        |
               | range            | 9.2.4   | 0..1        |
               | require-instance | 9.9.3   | 0..1        |
               | type             | 7.4     | 0..n        |
               +------------------+---------+-------------+
        
               +------------------+---------+-------------+
               | substatement     | section | cardinality |
               +------------------+---------+-------------+
               | base             | 7.18.2  | 0..n        |
               | bit              | 9.7.4   | 0..n        |
               | enum             | 9.6.4   | 0..n        |
               | fraction-digits  | 9.3.4   | 0..1        |
               | length           | 9.4.4   | 0..1        |
               | path             | 9.9.2   | 0..1        |
               | pattern          | 9.4.5   | 0..n        |
               | range            | 9.2.4   | 0..1        |
               | require-instance | 9.9.3   | 0..1        |
               | type             | 7.4     | 0..n        |
               +------------------+---------+-------------+
        
7.5. The "container" Statement
7.5. “容器”语句

The "container" statement is used to define an interior data node in the schema tree. It takes one argument, which is an identifier, followed by a block of substatements that holds detailed container information.

“container”语句用于定义模式树中的内部数据节点。它有一个参数,它是一个标识符,后跟一个包含详细容器信息的子语句块。

A container node does not have a value, but it has a list of child nodes in the data tree. The child nodes are defined in the container's substatements.

容器节点没有值,但在数据树中有子节点列表。子节点在容器的子状态中定义。

7.5.1. Containers with Presence
7.5.1. 存在的容器

YANG supports two styles of containers, those that exist only for organizing the hierarchy of data nodes and those whose presence in the data tree has an explicit meaning.

YANG支持两种类型的容器,一种是仅用于组织数据节点层次结构的容器,另一种是在数据树中具有明确含义的容器。

In the first style, the container has no meaning of its own, existing only to contain child nodes. In particular, the presence of the container node with no child nodes is semantically equivalent to the absence of the container node. YANG calls this style a "non-presence container". This is the default style.

在第一种样式中,容器本身没有意义,只存在于包含子节点的地方。特别是,没有子节点的容器节点的存在在语义上等同于没有容器节点。杨称这种风格为“不存在的容器”。这是默认样式。

For example, the set of scrambling options for Synchronous Optical Network (SONET) interfaces may be placed inside a "scrambling" container to enhance the organization of the configuration hierarchy and to keep these nodes together. The "scrambling" node itself has no meaning, so removing the node when it becomes empty relieves the user from performing this task.

例如,用于同步光网络(SONET)接口的一组加扰选项可放置在“加扰”容器内,以增强配置层次结构的组织并将这些节点保持在一起。“加扰”节点本身没有任何意义,因此在节点变空时移除节点可以免除用户执行此任务。

In the second style, the presence of the container itself carries some meaning, representing a single bit of data.

在第二种样式中,容器本身的存在具有某种意义,表示单个数据位。

For configuration data, the container acts as both a configuration knob and a means of organizing related configuration nodes. These containers are explicitly created and deleted.

对于配置数据,容器充当配置旋钮和组织相关配置节点的手段。这些容器是显式创建和删除的。

YANG calls this style a "presence container", and it is indicated using the "presence" statement, which takes as its argument a text string indicating what the presence of the node means.

YANG将这种样式称为“状态容器”,并使用“状态”语句表示,该语句将一个文本字符串作为其参数,指示节点的存在意味着什么。

For example, an "ssh" container may turn on the ability to log into the server using Secure SHell (SSH) but can also contain any SSH-related configuration knobs, such as connection rates or retry limits.

例如,“ssh”容器可以启用使用Secure SHell(ssh)登录服务器的功能,但也可以包含任何与ssh相关的配置旋钮,例如连接速率或重试限制。

The "presence" statement (see Section 7.5.5) is used to give semantics to the existence of the container in the data tree.

“presence”语句(见第7.5.5节)用于为数据树中容器的存在提供语义。

7.5.2. The container's Substatements
7.5.2. 容器的子状态
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | action       | 7.15    | 0..n        |
                 | anydata      | 7.10    | 0..n        |
                 | anyxml       | 7.11    | 0..n        |
                 | choice       | 7.9     | 0..n        |
                 | config       | 7.21.1  | 0..1        |
                 | container    | 7.5     | 0..n        |
                 | description  | 7.21.3  | 0..1        |
                 | grouping     | 7.12    | 0..n        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | leaf         | 7.6     | 0..n        |
                 | leaf-list    | 7.7     | 0..n        |
                 | list         | 7.8     | 0..n        |
                 | must         | 7.5.3   | 0..n        |
                 | notification | 7.16    | 0..n        |
                 | presence     | 7.5.5   | 0..1        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | typedef      | 7.3     | 0..n        |
                 | uses         | 7.13    | 0..n        |
                 | when         | 7.21.5  | 0..1        |
                 +--------------+---------+-------------+
        
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | action       | 7.15    | 0..n        |
                 | anydata      | 7.10    | 0..n        |
                 | anyxml       | 7.11    | 0..n        |
                 | choice       | 7.9     | 0..n        |
                 | config       | 7.21.1  | 0..1        |
                 | container    | 7.5     | 0..n        |
                 | description  | 7.21.3  | 0..1        |
                 | grouping     | 7.12    | 0..n        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | leaf         | 7.6     | 0..n        |
                 | leaf-list    | 7.7     | 0..n        |
                 | list         | 7.8     | 0..n        |
                 | must         | 7.5.3   | 0..n        |
                 | notification | 7.16    | 0..n        |
                 | presence     | 7.5.5   | 0..1        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | typedef      | 7.3     | 0..n        |
                 | uses         | 7.13    | 0..n        |
                 | when         | 7.21.5  | 0..1        |
                 +--------------+---------+-------------+
        
7.5.3. The "must" Statement
7.5.3. “必须”声明

The "must" statement, which is optional, takes as an argument a string that contains an XPath expression (see Section 6.4). It is used to formally declare a constraint on valid data. The constraint is enforced according to the rules in Section 8.

“must”语句是可选的,它将包含XPath表达式的字符串作为参数(参见第6.4节)。它用于正式声明对有效数据的约束。根据第8节中的规则强制执行约束。

When a datastore is validated, all "must" constraints are conceptually evaluated once for each node in the accessible tree (see Section 6.4.1).

验证数据存储时,所有“必须”约束在概念上对可访问树中的每个节点评估一次(见第6.4.1节)。

All such constraints MUST evaluate to "true" for the data to be valid.

所有这些约束必须评估为“true”,数据才有效。

The XPath expression is conceptually evaluated in the following context, in addition to the definition in Section 6.4.1:

除了第6.4.1节中的定义外,XPath表达式在以下上下文中进行概念性评估:

o If the "must" statement is a substatement of a "notification" statement, the context node is the node representing the notification in the accessible tree.

o 如果“必须”语句是“通知”语句的子语句,则上下文节点是可访问树中表示通知的节点。

o If the "must" statement is a substatement of an "input" statement, the context node is the node representing the operation in the accessible tree.

o 如果“必须”语句是“输入”语句的子语句,则上下文节点是表示可访问树中的操作的节点。

o If the "must" statement is a substatement of an "output" statement, the context node is the node representing the operation in the accessible tree.

o 如果“必须”语句是“输出”语句的子语句,则上下文节点是表示可访问树中的操作的节点。

o Otherwise, the context node is the node in the accessible tree for which the "must" statement is defined.

o 否则,上下文节点是可访问树中定义了“必须”语句的节点。

The result of the XPath expression is converted to a boolean value using the standard XPath rules.

XPath表达式的结果使用标准XPath规则转换为布尔值。

Note that since all leaf values in the data tree are conceptually stored in their canonical form (see Section 9.1), any XPath comparisons are done on the canonical value.

请注意,由于数据树中的所有叶值在概念上都以其规范形式存储(请参见第9.1节),因此所有XPath比较都是在规范值上进行的。

Also note that the XPath expression is conceptually evaluated. This means that an implementation does not have to use an XPath evaluator in the server. How the evaluation is done in practice is an implementation decision.

还要注意,XPath表达式是在概念上计算的。这意味着实现不必在服务器中使用XPath计算器。如何在实践中进行评估是一项实施决策。

7.5.4. The must's Substatements
7.5.4. 必须的子状态
                 +---------------+---------+-------------+
                 | substatement  | section | cardinality |
                 +---------------+---------+-------------+
                 | description   | 7.21.3  | 0..1        |
                 | error-app-tag | 7.5.4.2 | 0..1        |
                 | error-message | 7.5.4.1 | 0..1        |
                 | reference     | 7.21.4  | 0..1        |
                 +---------------+---------+-------------+
        
                 +---------------+---------+-------------+
                 | substatement  | section | cardinality |
                 +---------------+---------+-------------+
                 | description   | 7.21.3  | 0..1        |
                 | error-app-tag | 7.5.4.2 | 0..1        |
                 | error-message | 7.5.4.1 | 0..1        |
                 | reference     | 7.21.4  | 0..1        |
                 +---------------+---------+-------------+
        
7.5.4.1. The "error-message" Statement
7.5.4.1. “错误消息”语句

The "error-message" statement, which is optional, takes a string as an argument. If the constraint evaluates to "false", the string is passed as <error-message> in the <rpc-error> in NETCONF.

“error message”语句是可选的,它将字符串作为参数。如果约束的计算结果为“false”,则在NETCONF的<rpc error>中,字符串作为<error message>传递。

7.5.4.2. The "error-app-tag" Statement
7.5.4.2. “error-app-tag”语句

The "error-app-tag" statement, which is optional, takes a string as an argument. If the constraint evaluates to "false", the string is passed as <error-app-tag> in the <rpc-error> in NETCONF.

“error-app-tag”语句是可选的,它将字符串作为参数。如果约束的计算结果为“false”,则在NETCONF的<rpc error>中,字符串作为<error app tag>传递。

7.5.4.3. Usage Example of must and error-message
7.5.4.3. must和错误消息的用法示例
     container interface {
       leaf ifType {
         type enumeration {
           enum ethernet;
           enum atm;
         }
       }
       leaf ifMTU {
         type uint32;
       }
       must 'ifType != "ethernet" or ifMTU = 1500' {
         error-message "An Ethernet MTU must be 1500";
       }
       must 'ifType != "atm" or'
          + ' (ifMTU <= 17966 and ifMTU >= 64)' {
         error-message "An ATM MTU must be 64 .. 17966";
       }
     }
        
     container interface {
       leaf ifType {
         type enumeration {
           enum ethernet;
           enum atm;
         }
       }
       leaf ifMTU {
         type uint32;
       }
       must 'ifType != "ethernet" or ifMTU = 1500' {
         error-message "An Ethernet MTU must be 1500";
       }
       must 'ifType != "atm" or'
          + ' (ifMTU <= 17966 and ifMTU >= 64)' {
         error-message "An ATM MTU must be 64 .. 17966";
       }
     }
        
7.5.5. The "presence" Statement
7.5.5. “在场”声明

The "presence" statement assigns a meaning to the presence of a container in the data tree. It takes as an argument a string that contains a textual description of what the node's presence means.

“presence”语句为数据树中容器的存在赋予了意义。它接受一个字符串作为参数,该字符串包含节点存在的含义的文本描述。

If a container has the "presence" statement, the container's existence in the data tree carries some meaning. Otherwise, the container is used to give some structure to the data, and it carries no meaning by itself.

如果一个容器有“presence”语句,那么该容器在数据树中的存在就具有某种意义。否则,容器被用来为数据提供某种结构,它本身没有任何意义。

See Section 7.5.1 for additional information.

更多信息见第7.5.1节。

7.5.6. The container's Child Node Statements
7.5.6. 容器的子节点语句

Within a container, the "container", "leaf", "list", "leaf-list", "uses", "choice", "anydata", and "anyxml" statements can be used to define child nodes to the container.

在容器中,“container”、“leaf”、“list”、“leaf list”、“uses”、“choice”、“anydata”和“anyxml”语句可用于定义容器的子节点。

7.5.7. XML Encoding Rules
7.5.7. XML编码规则

A container node is encoded as an XML element. The element's local name is the container's identifier, and its namespace is the module's XML namespace (see Section 7.1.3).

容器节点编码为XML元素。元素的本地名称是容器的标识符,其名称空间是模块的XML名称空间(参见第7.1.3节)。

The container's child nodes are encoded as subelements to the container element. If the container defines RPC or action input or output parameters, these subelements are encoded in the same order as they are defined within the "container" statement. Otherwise, the subelements are encoded in any order.

容器的子节点被编码为容器元素的子元素。如果容器定义了RPC或操作输入或输出参数,则这些子元素的编码顺序与“container”语句中定义的顺序相同。否则,子元素按任意顺序编码。

Any whitespace between the subelements to the container is insignificant, i.e., an implementation MAY insert whitespace characters between subelements.

容器的子元素之间的任何空白都是无关紧要的,即,实现可以在子元素之间插入空白字符。

If a non-presence container does not have any child nodes, the container may or may not be present in the XML encoding.

如果不存在容器没有任何子节点,则该容器可能存在于XML编码中,也可能不存在于XML编码中。

7.5.8. NETCONF <edit-config> Operations
7.5.8. NETCONF<edit config>操作

Containers can be created, deleted, replaced, and modified through <edit-config> by using the "operation" attribute (see Section 7.2 in [RFC6241]) in the container's XML element.

可以通过<edit config>在容器的XML元素中使用“operation”属性(参见[RFC6241]中的第7.2节)来创建、删除、替换和修改容器。

If a container does not have a "presence" statement and the last child node is deleted, the NETCONF server MAY delete the container.

如果容器没有“presence”语句,并且删除了最后一个子节点,NETCONF服务器可能会删除该容器。

When a NETCONF server processes an <edit-config> request, the elements of procedure for the container node are as follows:

当NETCONF服务器处理<edit config>请求时,容器节点的过程元素如下所示:

o If the operation is "merge" or "replace", the node is created if it does not exist.

o 如果操作为“合并”或“替换”,则会在节点不存在时创建该节点。

o If the operation is "create", the node is created if it does not exist. If the node already exists, a "data-exists" error is returned.

o 如果操作为“创建”,则在节点不存在时创建该节点。如果节点已经存在,则返回“数据存在”错误。

o If the operation is "delete", the node is deleted if it exists. If the node does not exist, a "data-missing" error is returned.

o 如果操作为“删除”,则删除节点(如果存在)。如果节点不存在,则返回“数据丢失”错误。

7.5.9. Usage Example
7.5.9. 用法示例

Given the following container definition:

给定以下容器定义:

     container system {
       description
         "Contains various system parameters.";
       container services {
         description
           "Configure externally available services.";
         container "ssh" {
           presence "Enables SSH";
           description
             "SSH service-specific configuration.";
           // more leafs, containers, and stuff here...
         }
       }
     }
        
     container system {
       description
         "Contains various system parameters.";
       container services {
         description
           "Configure externally available services.";
         container "ssh" {
           presence "Enables SSH";
           description
             "SSH service-specific configuration.";
           // more leafs, containers, and stuff here...
         }
       }
     }
        

A corresponding XML instance example:

对应的XML实例示例:

     <system>
       <services>
         <ssh/>
       </services>
     </system>
        
     <system>
       <services>
         <ssh/>
       </services>
     </system>
        

Since the <ssh> element is present, SSH is enabled.

由于存在<ssh>元素,因此启用了ssh。

To delete a container with an <edit-config>:

要删除带有<edit config>的容器,请执行以下操作:

     <rpc message-id="101"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
          xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
       <edit-config>
         <target>
           <running/>
         </target>
         <config>
           <system xmlns="urn:example:config">
             <services>
               <ssh nc:operation="delete"/>
             </services>
           </system>
         </config>
       </edit-config>
     </rpc>
        
     <rpc message-id="101"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
          xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
       <edit-config>
         <target>
           <running/>
         </target>
         <config>
           <system xmlns="urn:example:config">
             <services>
               <ssh nc:operation="delete"/>
             </services>
           </system>
         </config>
       </edit-config>
     </rpc>
        
7.6. The "leaf" Statement
7.6. “叶子”声明

The "leaf" statement is used to define a leaf node in the schema tree. It takes one argument, which is an identifier, followed by a block of substatements that holds detailed leaf information.

“leaf”语句用于在模式树中定义叶节点。它有一个参数,它是一个标识符,后跟一个包含详细叶信息的子语句块。

A leaf node has a value, but no child nodes, in the data tree. Conceptually, the value in the data tree is always in the canonical form (see Section 9.1).

叶节点在数据树中有一个值,但没有子节点。从概念上讲,数据树中的值始终采用规范形式(参见第9.1节)。

A leaf node exists in zero or one instance in the data tree.

叶节点存在于数据树中的零个或一个实例中。

The "leaf" statement is used to define a scalar variable of a particular built-in or derived type.

“leaf”语句用于定义特定内置或派生类型的标量变量。

7.6.1. The leaf's Default Value
7.6.1. 叶的默认值

The default value of a leaf is the value that the server uses if the leaf does not exist in the data tree. The usage of the default value depends on the leaf's closest ancestor node in the schema tree that is not a non-presence container (see Section 7.5.1):

如果叶在数据树中不存在,则叶的默认值是服务器使用的值。默认值的使用取决于叶在模式树中最近的祖先节点,该节点不是非存在容器(参见第7.5.1节):

o If no such ancestor exists in the schema tree, the default value MUST be used.

o 如果模式树中不存在这样的祖先,则必须使用默认值。

o Otherwise, if this ancestor is a case node, the default value MUST be used if any node from the case exists in the data tree or the case node is the choice's default case, and if no nodes from any other case exist in the data tree.

o 否则,如果此祖先是案例节点,则如果数据树中存在案例中的任何节点,或者案例节点是选项的默认案例,并且如果数据树中不存在任何其他案例中的节点,则必须使用默认值。

o Otherwise, the default value MUST be used if the ancestor node exists in the data tree.

o 否则,如果数据树中存在祖先节点,则必须使用默认值。

In these cases, the default value is said to be in use.

在这些情况下,默认值被称为正在使用。

Note that if the leaf or any of its ancestors has a "when" condition or "if-feature" expression that evaluates to "false", then the default value is not in use.

请注意,如果叶或其任何祖先具有计算结果为“false”的“when”条件或“if feature”表达式,则默认值不在使用中。

When the default value is in use, the server MUST operationally behave as if the leaf was present in the data tree with the default value as its value.

当使用默认值时,服务器在操作上的行为必须与叶在数据树中以默认值作为其值一样。

If a leaf has a "default" statement, the leaf's default value is the value of the "default" statement. Otherwise, if the leaf's type has a default value and the leaf is not mandatory, then the leaf's default value is the type's default value. In all other cases, the leaf does not have a default value.

如果一个叶子有一个“default”语句,那么叶子的默认值就是“default”语句的值。否则,如果叶的类型具有默认值且叶不是必需的,则叶的默认值是该类型的默认值。在所有其他情况下,叶没有默认值。

7.6.2. The leaf's Substatements
7.6.2. 叶的亚基
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | config       | 7.21.1  | 0..1        |
                 | default      | 7.6.4   | 0..1        |
                 | description  | 7.21.3  | 0..1        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | mandatory    | 7.6.5   | 0..1        |
                 | must         | 7.5.3   | 0..n        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | type         | 7.6.3   | 1           |
                 | units        | 7.3.3   | 0..1        |
                 | when         | 7.21.5  | 0..1        |
                 +--------------+---------+-------------+
        
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | config       | 7.21.1  | 0..1        |
                 | default      | 7.6.4   | 0..1        |
                 | description  | 7.21.3  | 0..1        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | mandatory    | 7.6.5   | 0..1        |
                 | must         | 7.5.3   | 0..n        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | type         | 7.6.3   | 1           |
                 | units        | 7.3.3   | 0..1        |
                 | when         | 7.21.5  | 0..1        |
                 +--------------+---------+-------------+
        
7.6.3. The leaf's "type" Statement
7.6.3. 叶的“类型”语句

The "type" statement, which MUST be present, takes as an argument the name of an existing built-in or derived type. The optional substatements specify restrictions on this type. See Section 7.4 for details.

必须存在的“type”语句将现有内置类型或派生类型的名称作为参数。可选子语句指定此类型的限制。详见第7.4节。

7.6.4. The leaf's "default" Statement
7.6.4. 叶的“默认”语句

The "default" statement, which is optional, takes as an argument a string that contains a default value for the leaf.

“default”语句是可选的,它将包含叶的默认值的字符串作为参数。

The value of the "default" statement MUST be valid according to the type specified in the leaf's "type" statement.

根据叶的“type”语句中指定的类型,“default”语句的值必须有效。

The "default" statement MUST NOT be present on nodes where "mandatory" is "true".

“default”语句不能出现在“mandatory”为“true”的节点上。

The definition of the default value MUST NOT be marked with an "if-feature" statement. For example, the following is illegal:

默认值的定义不得用“if feature”语句标记。例如,以下行为是非法的:

     leaf color {
       type enumeration {
         enum blue { if-feature blue; }
         ...
       }
       default blue; // illegal - enum value is conditional
     }
        
     leaf color {
       type enumeration {
         enum blue { if-feature blue; }
         ...
       }
       default blue; // illegal - enum value is conditional
     }
        
7.6.5. The leaf's "mandatory" Statement
7.6.5. 叶的“强制性”声明

The "mandatory" statement, which is optional, takes as an argument the string "true" or "false" and puts a constraint on valid data. If not specified, the default is "false".

“mandatory”语句是可选的,它将字符串“true”或“false”作为参数,并对有效数据进行约束。如果未指定,则默认值为“false”。

If "mandatory" is "true", the behavior of the constraint depends on the type of the leaf's closest ancestor node in the schema tree that is not a non-presence container (see Section 7.5.1):

如果“mandatory”为“true”,则约束的行为取决于模式树中叶的最近祖先节点的类型,该节点不是非存在容器(请参见第7.5.1节):

o If no such ancestor exists in the schema tree, the leaf MUST exist.

o 如果模式树中不存在这样的祖先,那么叶必须存在。

o Otherwise, if this ancestor is a case node, the leaf MUST exist if any node from the case exists in the data tree.

o 否则,如果此祖先是案例节点,则如果案例中的任何节点存在于数据树中,则该叶必须存在。

o Otherwise, the leaf MUST exist if the ancestor node exists in the data tree.

o 否则,如果数据树中存在祖先节点,则叶必须存在。

This constraint is enforced according to the rules in Section 8.

此约束根据第8节中的规则强制执行。

7.6.6. XML Encoding Rules
7.6.6. XML编码规则

A leaf node is encoded as an XML element. The element's local name is the leaf's identifier, and its namespace is the module's XML namespace (see Section 7.1.3).

叶节点编码为XML元素。元素的本地名称是叶的标识符,其名称空间是模块的XML名称空间(参见第7.1.3节)。

The value of the leaf node is encoded to XML according to the type and is sent as character data in the element.

叶节点的值根据类型编码为XML,并作为元素中的字符数据发送。

See Section 7.6.8 for an example.

示例见第7.6.8节。

7.6.7. NETCONF <edit-config> Operations
7.6.7. NETCONF<edit config>操作

When a NETCONF server processes an <edit-config> request, the elements of procedure for the leaf node are as follows:

当NETCONF服务器处理<edit config>请求时,叶节点的过程元素如下所示:

o If the operation is "merge" or "replace", the node is created if it does not exist, and its value is set to the value found in the XML RPC data.

o 如果操作为“merge”或“replace”,则将在节点不存在时创建该节点,并将其值设置为在XML RPC数据中找到的值。

o If the operation is "create", the node is created if it does not exist. If the node already exists, a "data-exists" error is returned.

o 如果操作为“创建”,则在节点不存在时创建该节点。如果节点已经存在,则返回“数据存在”错误。

o If the operation is "delete", the node is deleted if it exists. If the node does not exist, a "data-missing" error is returned.

o 如果操作为“删除”,则删除节点(如果存在)。如果节点不存在,则返回“数据丢失”错误。

7.6.8. Usage Example
7.6.8. 用法示例

Given the following "leaf" statement, placed in the previously defined "ssh" container (see Section 7.5.9):

给出以下“leaf”语句,放在前面定义的“ssh”容器中(参见第7.5.9节):

     leaf port {
       type inet:port-number;
       default 22;
       description
         "The port to which the SSH server listens.";
     }
        
     leaf port {
       type inet:port-number;
       default 22;
       description
         "The port to which the SSH server listens.";
     }
        

A corresponding XML instance example:

对应的XML实例示例:

     <port>2022</port>
        
     <port>2022</port>
        

To set the value of a leaf with an <edit-config>:

要使用<edit config>设置叶的值,请执行以下操作:

     <rpc message-id="101"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
          xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
       <edit-config>
         <target>
           <running/>
         </target>
         <config>
           <system xmlns="urn:example:config">
             <services>
               <ssh>
                 <port>2022</port>
               </ssh>
             </services>
           </system>
         </config>
       </edit-config>
     </rpc>
        
     <rpc message-id="101"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
          xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
       <edit-config>
         <target>
           <running/>
         </target>
         <config>
           <system xmlns="urn:example:config">
             <services>
               <ssh>
                 <port>2022</port>
               </ssh>
             </services>
           </system>
         </config>
       </edit-config>
     </rpc>
        
7.7. The "leaf-list" Statement
7.7. “叶列表”语句

Where the "leaf" statement is used to define a simple scalar variable of a particular type, the "leaf-list" statement is used to define an array of a particular type. The "leaf-list" statement takes one argument, which is an identifier, followed by a block of substatements that holds detailed leaf-list information.

如果“leaf”语句用于定义特定类型的简单标量变量,“leaf list”语句用于定义特定类型的数组。“叶列表”语句接受一个参数,该参数是一个标识符,后跟一个包含详细叶列表信息的子语句块。

In configuration data, the values in a leaf-list MUST be unique.

在配置数据中,叶列表中的值必须是唯一的。

The definitions of the default values MUST NOT be marked with an "if-feature" statement.

默认值的定义不得用“if feature”语句标记。

Conceptually, the values in the data tree MUST be in the canonical form (see Section 9.1).

从概念上讲,数据树中的值必须采用规范形式(见第9.1节)。

7.7.1. Ordering
7.7.1. 订购

YANG supports two styles for ordering the entries within lists and leaf-lists. In many lists, the order of list entries does not impact the implementation of the list's configuration, and the server is free to sort the list entries in any reasonable order. The "description" string for the list may suggest an order to the server implementor. YANG calls this style of list "system ordered"; such lists are indicated with the statement "ordered-by system".

YANG支持两种样式对列表和叶列表中的条目进行排序。在许多列表中,列表项的顺序不会影响列表配置的实现,服务器可以按照任何合理的顺序对列表项进行排序。列表的“description”字符串可能会向服务器实现者建议一个顺序。杨称这种类型的列表为“系统有序”;此类列表用“按系统排序”的语句表示。

For example, a list of valid users would typically be sorted alphabetically, since the order in which the users appeared in the configuration would not impact the creation of those users' accounts.

例如,有效用户列表通常按字母顺序排序,因为用户在配置中出现的顺序不会影响这些用户帐户的创建。

In the other style of lists, the order of list entries matters for the implementation of the list's configuration and the user is responsible for ordering the entries, while the server maintains that order. YANG calls this style of list "user ordered"; such lists are indicated with the statement "ordered-by user".

在另一种类型的列表中,列表条目的顺序对列表配置的实现很重要,用户负责对条目进行排序,而服务器则维持该顺序。杨称这种类型的列表为“用户订购”;此类列表用“按用户排序”的语句表示。

For example, the order in which packet filter entries are applied to incoming traffic may affect how that traffic is filtered. The user would need to decide if the filter entry that discards all TCP traffic should be applied before or after the filter entry that allows all traffic from trusted interfaces. The choice of order would be crucial.

例如,分组过滤器条目应用于传入流量的顺序可能会影响该流量的过滤方式。用户需要决定是否应在允许来自受信任接口的所有流量的筛选器条目之前或之后应用丢弃所有TCP流量的筛选器条目。秩序的选择至关重要。

YANG provides a rich set of facilities within NETCONF's <edit-config> operation that allows the order of list entries in user-ordered lists to be controlled. List entries may be inserted or rearranged, positioned as the first or last entry in the list, or positioned before or after another specific entry.

YANG在NETCONF的<edit config>操作中提供了一组丰富的工具,允许控制用户排序列表中列表项的顺序。列表条目可以插入或重新排列,定位为列表中的第一个或最后一个条目,或者定位在另一个特定条目之前或之后。

The "ordered-by" statement is covered in Section 7.7.7.

第7.7.7节介绍了“订购人”声明。

7.7.2. The leaf-list's Default Values
7.7.2. 叶列表的默认值

The default values of a leaf-list are the values that the server uses if the leaf-list does not exist in the data tree. The usage of the default values depends on the leaf-list's closest ancestor node in the schema tree that is not a non-presence container (see Section 7.5.1):

叶列表的默认值是服务器在数据树中不存在叶列表时使用的值。默认值的使用取决于叶列表在模式树中最近的祖先节点,该节点不是非存在容器(请参阅第7.5.1节):

o If no such ancestor exists in the schema tree, the default values MUST be used.

o 如果模式树中不存在这样的祖先,则必须使用默认值。

o Otherwise, if this ancestor is a case node, the default values MUST be used if any node from the case exists in the data tree or the case node is the choice's default case, and if no nodes from any other case exist in the data tree.

o 否则,如果此祖先是案例节点,则如果案例中的任何节点存在于数据树中,或者案例节点是选项的默认案例,并且如果数据树中不存在任何其他案例中的节点,则必须使用默认值。

o Otherwise, the default values MUST be used if the ancestor node exists in the data tree.

o 否则,如果数据树中存在祖先节点,则必须使用默认值。

In these cases, the default values are said to be in use.

在这些情况下,默认值被称为正在使用。

Note that if the leaf-list or any of its ancestors has a "when" condition or "if-feature" expression that evaluates to "false", then the default values are not in use.

请注意,如果叶列表或其任何祖先具有计算结果为“false”的“when”条件或“if feature”表达式,则默认值不在使用中。

When the default values are in use, the server MUST operationally behave as if the leaf-list was present in the data tree with the default values as its values.

当使用默认值时,服务器在操作上的行为必须与叶列表以默认值作为其值出现在数据树中一样。

If a leaf-list has one or more "default" statements, the leaf-list's default values are the values of the "default" statements, and if the leaf-list is user ordered, the default values are used in the order of the "default" statements. Otherwise, if the leaf-list's type has a default value and the leaf-list does not have a "min-elements" statement with a value greater than or equal to one, then the leaf-list's default value is one instance of the type's default value. In all other cases, the leaf-list does not have any default values.

如果叶列表有一个或多个“default”语句,则叶列表的默认值是“default”语句的值,如果叶列表是用户排序的,则按照“default”语句的顺序使用默认值。否则,如果叶列表的类型具有默认值,并且叶列表没有值大于或等于1的“min elements”语句,则叶列表的默认值是该类型默认值的一个实例。在所有其他情况下,叶列表没有任何默认值。

7.7.3. The leaf-list's Substatements
7.7.3. 叶列表的子状态
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | config       | 7.21.1  | 0..1        |
                 | default      | 7.7.4   | 0..n        |
                 | description  | 7.21.3  | 0..1        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | max-elements | 7.7.6   | 0..1        |
                 | min-elements | 7.7.5   | 0..1        |
                 | must         | 7.5.3   | 0..n        |
                 | ordered-by   | 7.7.7   | 0..1        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | type         | 7.4     | 1           |
                 | units        | 7.3.3   | 0..1        |
                 | when         | 7.21.5  | 0..1        |
                 +--------------+---------+-------------+
        
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | config       | 7.21.1  | 0..1        |
                 | default      | 7.7.4   | 0..n        |
                 | description  | 7.21.3  | 0..1        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | max-elements | 7.7.6   | 0..1        |
                 | min-elements | 7.7.5   | 0..1        |
                 | must         | 7.5.3   | 0..n        |
                 | ordered-by   | 7.7.7   | 0..1        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | type         | 7.4     | 1           |
                 | units        | 7.3.3   | 0..1        |
                 | when         | 7.21.5  | 0..1        |
                 +--------------+---------+-------------+
        
7.7.4. The leaf-list's "default" Statement
7.7.4. 叶列表的“default”语句

The "default" statement, which is optional, takes as an argument a string that contains a default value for the leaf-list.

“default”语句是可选的,它将包含叶列表的默认值的字符串作为参数。

The value of the "default" statement MUST be valid according to the type specified in the leaf-list's "type" statement.

根据叶列表的“type”语句中指定的类型,“default”语句的值必须有效。

The "default" statement MUST NOT be present on nodes where "min-elements" has a value greater than or equal to one.

“default”语句不得出现在“min elements”值大于或等于1的节点上。

7.7.5. The "min-elements" Statement
7.7.5. “最小元素”语句

The "min-elements" statement, which is optional, takes as an argument a non-negative integer that puts a constraint on valid list entries. A valid leaf-list or list MUST have at least min-elements entries.

“min elements”语句是可选的,它将一个非负整数作为参数,该非负整数对有效的列表项进行约束。有效的叶列表或列表必须至少包含min元素条目。

If no "min-elements" statement is present, it defaults to zero.

如果不存在“min elements”语句,则默认为零。

The behavior of the constraint depends on the type of the leaf-list's or list's closest ancestor node in the schema tree that is not a non-presence container (see Section 7.5.1):

约束的行为取决于模式树中不是非存在容器的叶列表或列表最近祖先节点的类型(参见第7.5.1节):

o If no such ancestor exists in the schema tree, the constraint is enforced.

o 如果模式树中不存在这样的祖先,则强制执行约束。

o Otherwise, if this ancestor is a case node, the constraint is enforced if any other node from the case exists.

o 否则,如果此祖先是案例节点,则如果案例中存在任何其他节点,则强制执行约束。

o Otherwise, it is enforced if the ancestor node exists.

o 否则,如果祖先节点存在,则强制执行。

The constraint is further enforced according to the rules in Section 8.

根据第8节中的规则,进一步实施约束。

7.7.6. The "max-elements" Statement
7.7.6. “最大元素”语句

The "max-elements" statement, which is optional, takes as an argument a positive integer or the string "unbounded", which puts a constraint on valid list entries. A valid leaf-list or list always has at most max-elements entries.

“max elements”语句是可选的,它将一个正整数或字符串“unbounded”作为参数,该字符串对有效列表项施加约束。有效的叶列表或列表始终最多包含max elements条目。

If no "max-elements" statement is present, it defaults to "unbounded".

如果不存在“max elements”语句,则默认为“unbounded”。

The "max-elements" constraint is enforced according to the rules in Section 8.

“最大元素”约束根据第8节中的规则强制执行。

7.7.7. The "ordered-by" Statement
7.7.7. “orderby”语句

The "ordered-by" statement defines whether the order of entries within a list are determined by the user or the system. The argument is one of the strings "system" or "user". If not present, ordering defaults to "system".

“ordered by”语句定义列表中条目的顺序是由用户还是由系统确定的。参数是字符串“system”或“user”之一。如果不存在,则订购默认为“系统”。

This statement is ignored if the list represents state data, RPC output parameters, or notification content.

如果列表表示状态数据、RPC输出参数或通知内容,则忽略此语句。

See Section 7.7.1 for additional information.

更多信息见第7.7.1节。

7.7.7.1. ordered-by system
7.7.7.1. 按系统排序

The entries in the list are ordered according to an order determined by the system. The "description" string for the list may suggest an order to the server implementor. If not, an implementation is free to order the entries in any order. An implementation SHOULD use the same order for the same data, regardless of how the data were created. Using a deterministic order will make comparisons possible using simple tools like "diff".

列表中的条目根据系统确定的顺序排序。列表的“description”字符串可能会向服务器实现者建议一个顺序。如果没有,则实现可以按任意顺序对条目进行排序。无论数据是如何创建的,实现都应该对相同的数据使用相同的顺序。使用确定性顺序可以使用“diff”等简单工具进行比较。

This is the default order.

这是默认顺序。

7.7.7.2. ordered-by user
7.7.7.2. 按用户订购

The entries in the list are ordered according to an order defined by the user. In NETCONF, this order is controlled by using special XML attributes in the <edit-config> request. See Section 7.7.9 for details.

列表中的条目按照用户定义的顺序排序。在NETCONF中,这个顺序是通过在<edit config>请求中使用特殊的XML属性来控制的。详见第7.7.9节。

7.7.8. XML Encoding Rules
7.7.8. XML编码规则

A leaf-list node is encoded as a series of XML elements. Each element's local name is the leaf-list's identifier, and its namespace is the module's XML namespace (see Section 7.1.3).

叶列表节点编码为一系列XML元素。每个元素的本地名称是叶列表的标识符,其名称空间是模块的XML名称空间(参见第7.1.3节)。

The value of each leaf-list entry is encoded to XML according to the type and is sent as character data in the element.

每个叶列表条目的值根据类型编码为XML,并作为元素中的字符数据发送。

The XML elements representing leaf-list entries MUST appear in the order specified by the user if the leaf-list is "ordered-by user"; otherwise, the order is implementation dependent. The XML elements representing leaf-list entries MAY be interleaved with elements for siblings of the leaf-list, unless the leaf-list defines RPC or action input or output parameters.

如果叶列表是“按用户排序”的,则表示叶列表条目的XML元素必须按照用户指定的顺序出现;否则,顺序取决于实现。表示叶列表条目的XML元素可以与叶列表的同级元素交错,除非叶列表定义了RPC或操作输入或输出参数。

See Section 7.7.10 for an example.

示例见第7.7.10节。

7.7.9. NETCONF <edit-config> Operations
7.7.9. NETCONF<edit config>操作

Leaf-list entries can be created and deleted, but not modified, through <edit-config>, by using the "operation" attribute in the leaf-list entry's XML element.

通过使用叶列表条目的XML元素中的“operation”属性,可以创建和删除叶列表条目,但不能修改。

In an "ordered-by user" leaf-list, the attributes "insert" and "value" in the YANG XML namespace (Section 5.3.1) can be used to control where in the leaf-list the entry is inserted. These can be used during "create" operations to insert a new leaf-list entry, or during "merge" or "replace" operations to insert a new leaf-list entry or move an existing one.

在“按用户排序”叶列表中,XML命名空间(第5.3.1节)中的属性“插入”和“值”可用于控制在叶列表中插入条目的位置。这些可以在“创建”操作期间用于插入新的叶列表条目,或在“合并”或“替换”操作期间用于插入新的叶列表条目或移动现有的叶列表条目。

The "insert" attribute can take the values "first", "last", "before", and "after". If the value is "before" or "after", the "value" attribute MUST also be used to specify an existing entry in the leaf-list.

“insert”属性可以采用值“first”、“last”、“before”和“after”。如果值为“before”或“after”,则“value”属性还必须用于指定叶列表中的现有条目。

If no "insert" attribute is present in the "create" operation, it defaults to "last".

如果“创建”操作中不存在“插入”属性,则默认为“最后”。

If several entries in an "ordered-by user" leaf-list are modified in the same <edit-config> request, the entries are modified one at a time, in the order of the XML elements in the request.

如果在同一<edit config>请求中修改了“ordered by user”(按用户排序)叶列表中的多个条目,则按照请求中XML元素的顺序一次修改一个条目。

In a <copy-config> or in an <edit-config> with a "replace" operation that covers the entire leaf-list, the leaf-list order is the same as the order of the XML elements in the request.

在包含整个叶列表的“replace”操作的<copy config>或<edit config>中,叶列表顺序与请求中XML元素的顺序相同。

When a NETCONF server processes an <edit-config> request, the elements of procedure for a leaf-list node are as follows:

当NETCONF服务器处理<edit config>请求时,叶列表节点的过程元素如下所示:

o If the operation is "merge" or "replace", the leaf-list entry is created if it does not exist.

o 如果操作为“合并”或“替换”,则会在叶列表条目不存在时创建该条目。

o If the operation is "create", the leaf-list entry is created if it does not exist. If the leaf-list entry already exists, a "data-exists" error is returned.

o 如果操作为“创建”,则会创建不存在的叶列表条目。如果叶列表条目已经存在,则返回“数据存在”错误。

o If the operation is "delete", the entry is deleted from the leaf-list if it exists. If the leaf-list entry does not exist, a "data-missing" error is returned.

o 如果操作为“删除”,则该条目将从叶列表中删除(如果存在)。如果叶列表条目不存在,则返回“数据丢失”错误。

7.7.10. Usage Example
7.7.10. 用法示例
     leaf-list allow-user {
       type string;
       description
         "A list of user name patterns to allow.";
     }
        
     leaf-list allow-user {
       type string;
       description
         "A list of user name patterns to allow.";
     }
        

A corresponding XML instance example:

对应的XML实例示例:

     <allow-user>alice</allow-user>
     <allow-user>bob</allow-user>
        
     <allow-user>alice</allow-user>
     <allow-user>bob</allow-user>
        

To create a new element in this list, using the default <edit-config> operation "merge":

要在此列表中创建新元素,请使用默认的<edit config>操作“merge”:

     <rpc message-id="101"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
          xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
       <edit-config>
         <target>
           <running/>
         </target>
         <config>
           <system xmlns="urn:example:config">
             <services>
               <ssh>
                 <allow-user>eric</allow-user>
               </ssh>
             </services>
           </system>
         </config>
       </edit-config>
     </rpc>
        
     <rpc message-id="101"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
          xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
       <edit-config>
         <target>
           <running/>
         </target>
         <config>
           <system xmlns="urn:example:config">
             <services>
               <ssh>
                 <allow-user>eric</allow-user>
               </ssh>
             </services>
           </system>
         </config>
       </edit-config>
     </rpc>
        

Given the following ordered-by user leaf-list:

给定按用户叶列表排序的以下内容:

     leaf-list cipher {
       type string;
       ordered-by user;
       description
         "A list of ciphers.";
     }
        
     leaf-list cipher {
       type string;
       ordered-by user;
       description
         "A list of ciphers.";
     }
        

The following would be used to insert a new cipher "blowfish-cbc" after "3des-cbc":

以下内容将用于在“3des cbc”之后插入新密码“河豚cbc”:

     <rpc message-id="102"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
          xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
          xmlns:yang="urn:ietf:params:xml:ns:yang:1">
       <edit-config>
         <target>
           <running/>
         </target>
         <config>
           <system xmlns="urn:example:config">
             <services>
               <ssh>
                 <cipher nc:operation="create"
                         yang:insert="after"
                         yang:value="3des-cbc">blowfish-cbc</cipher>
               </ssh>
             </services>
           </system>
         </config>
       </edit-config>
     </rpc>
        
     <rpc message-id="102"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
          xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
          xmlns:yang="urn:ietf:params:xml:ns:yang:1">
       <edit-config>
         <target>
           <running/>
         </target>
         <config>
           <system xmlns="urn:example:config">
             <services>
               <ssh>
                 <cipher nc:operation="create"
                         yang:insert="after"
                         yang:value="3des-cbc">blowfish-cbc</cipher>
               </ssh>
             </services>
           </system>
         </config>
       </edit-config>
     </rpc>
        
7.8. The "list" Statement
7.8. “名单”声明

The "list" statement is used to define an interior data node in the schema tree. A list node may exist in multiple instances in the data tree. Each such instance is known as a list entry. The "list" statement takes one argument, which is an identifier, followed by a block of substatements that holds detailed list information.

“list”语句用于定义模式树中的内部数据节点。列表节点可能存在于数据树中的多个实例中。每个这样的实例称为列表条目。“list”语句接受一个参数,它是一个标识符,后跟一个包含详细列表信息的子语句块。

A list entry is uniquely identified by the values of the list's keys, if defined.

列表项由列表键的值唯一标识(如果已定义)。

7.8.1. The list's Substatements
7.8.1. 列表的子状态
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | action       | 7.15    | 0..n        |
                 | anydata      | 7.10    | 0..n        |
                 | anyxml       | 7.11    | 0..n        |
                 | choice       | 7.9     | 0..n        |
                 | config       | 7.21.1  | 0..1        |
                 | container    | 7.5     | 0..n        |
                 | description  | 7.21.3  | 0..1        |
                 | grouping     | 7.12    | 0..n        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | key          | 7.8.2   | 0..1        |
                 | leaf         | 7.6     | 0..n        |
                 | leaf-list    | 7.7     | 0..n        |
                 | list         | 7.8     | 0..n        |
                 | max-elements | 7.7.6   | 0..1        |
                 | min-elements | 7.7.5   | 0..1        |
                 | must         | 7.5.3   | 0..n        |
                 | notification | 7.16    | 0..n        |
                 | ordered-by   | 7.7.7   | 0..1        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | typedef      | 7.3     | 0..n        |
                 | unique       | 7.8.3   | 0..n        |
                 | uses         | 7.13    | 0..n        |
                 | when         | 7.21.5  | 0..1        |
                 +--------------+---------+-------------+
        
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | action       | 7.15    | 0..n        |
                 | anydata      | 7.10    | 0..n        |
                 | anyxml       | 7.11    | 0..n        |
                 | choice       | 7.9     | 0..n        |
                 | config       | 7.21.1  | 0..1        |
                 | container    | 7.5     | 0..n        |
                 | description  | 7.21.3  | 0..1        |
                 | grouping     | 7.12    | 0..n        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | key          | 7.8.2   | 0..1        |
                 | leaf         | 7.6     | 0..n        |
                 | leaf-list    | 7.7     | 0..n        |
                 | list         | 7.8     | 0..n        |
                 | max-elements | 7.7.6   | 0..1        |
                 | min-elements | 7.7.5   | 0..1        |
                 | must         | 7.5.3   | 0..n        |
                 | notification | 7.16    | 0..n        |
                 | ordered-by   | 7.7.7   | 0..1        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | typedef      | 7.3     | 0..n        |
                 | unique       | 7.8.3   | 0..n        |
                 | uses         | 7.13    | 0..n        |
                 | when         | 7.21.5  | 0..1        |
                 +--------------+---------+-------------+
        
7.8.2. The list's "key" Statement
7.8.2. 列表的“关键”语句

The "key" statement, which MUST be present if the list represents configuration and MAY be present otherwise, takes as an argument a string that specifies a space-separated list of one or more leaf identifiers of this list. A leaf identifier MUST NOT appear more than once in the key. Each such leaf identifier MUST refer to a child leaf of the list. The leafs can be defined directly in substatements to the list or in groupings used in the list.

如果列表表示配置,则“key”语句必须存在,否则可能存在。该语句将字符串作为参数,指定此列表的一个或多个叶标识符的以空格分隔的列表。叶标识符在键中不能出现多次。每个这样的叶标识符必须引用列表的子叶。可以直接在列表的子状态或列表中使用的分组中定义LEAF。

The combined values of all the leafs specified in the key are used to uniquely identify a list entry. All key leafs MUST be given values when a list entry is created. Thus, any default values in the key leafs or their types are ignored. Any "mandatory" statements in the key leafs are ignored.

键中指定的所有叶的组合值用于唯一标识列表项。创建列表条目时,必须为所有键叶指定值。因此,将忽略键叶或其类型中的任何默认值。忽略键叶中的任何“强制”语句。

A leaf that is part of the key can be of any built-in or derived type.

作为键的一部分的叶可以是任何内置或派生类型。

All key leafs in a list MUST have the same value for their "config" as the list itself.

列表中的所有键叶的“配置”值必须与列表本身的值相同。

The key string syntax is formally defined by the rule "key-arg" in Section 14.

键字符串语法由第14节中的规则“key arg”正式定义。

7.8.3. The list's "unique" Statement
7.8.3. 该列表的“唯一”声明

The "unique" statement is used to put constraints on valid list entries. It takes as an argument a string that contains a space-separated list of schema node identifiers, which MUST be given in the descendant form (see the rule "descendant-schema-nodeid" in Section 14). Each such schema node identifier MUST refer to a leaf.

“unique”语句用于对有效列表项进行约束。它将包含模式节点标识符的空格分隔列表的字符串作为参数,这些标识符必须以子代形式给出(请参见第14节中的规则“子代模式节点ID”)。每个这样的模式节点标识符必须引用一个叶。

If one of the referenced leafs represents configuration data, then all of the referenced leafs MUST represent configuration data.

如果其中一个引用的leaf表示配置数据,那么所有引用的leaf都必须表示配置数据。

The "unique" constraint specifies that the combined values of all the leaf instances specified in the argument string, including leafs with default values, MUST be unique within all list entry instances in which all referenced leafs exist or have default values. The constraint is enforced according to the rules in Section 8.

“唯一”约束指定参数字符串中指定的所有叶实例(包括具有默认值的叶)的组合值在所有引用叶存在或具有默认值的所有列表条目实例中必须是唯一的。根据第8节中的规则强制执行约束。

The unique string syntax is formally defined by the rule "unique-arg" in Section 14.

唯一字符串语法由第14节中的规则“unique arg”正式定义。

7.8.3.1. Usage Example
7.8.3.1. 用法示例

With the following list:

以下是:

     list server {
       key "name";
       unique "ip port";
       leaf name {
         type string;
       }
       leaf ip {
         type inet:ip-address;
       }
       leaf port {
         type inet:port-number;
       }
     }
        
     list server {
       key "name";
       unique "ip port";
       leaf name {
         type string;
       }
       leaf ip {
         type inet:ip-address;
       }
       leaf port {
         type inet:port-number;
       }
     }
        

the following configuration is not valid:

以下配置无效:

     <server>
       <name>smtp</name>
       <ip>192.0.2.1</ip>
       <port>25</port>
     </server>
        
     <server>
       <name>smtp</name>
       <ip>192.0.2.1</ip>
       <port>25</port>
     </server>
        
     <server>
       <name>http</name>
       <ip>192.0.2.1</ip>
       <port>25</port>
     </server>
        
     <server>
       <name>http</name>
       <ip>192.0.2.1</ip>
       <port>25</port>
     </server>
        

The following configuration is valid, since the "http" and "ftp" list entries do not have a value for all referenced leafs and are thus not taken into account when the "unique" constraint is enforced:

以下配置是有效的,因为“http”和“ftp”列表项没有针对所有引用的leaf的值,因此在强制执行“unique”约束时不考虑这些值:

     <server>
       <name>smtp</name>
       <ip>192.0.2.1</ip>
       <port>25</port>
     </server>
        
     <server>
       <name>smtp</name>
       <ip>192.0.2.1</ip>
       <port>25</port>
     </server>
        
     <server>
       <name>http</name>
       <ip>192.0.2.1</ip>
     </server>
        
     <server>
       <name>http</name>
       <ip>192.0.2.1</ip>
     </server>
        
     <server>
       <name>ftp</name>
       <ip>192.0.2.1</ip>
     </server>
        
     <server>
       <name>ftp</name>
       <ip>192.0.2.1</ip>
     </server>
        
7.8.4. The list's Child Node Statements
7.8.4. 列表的子节点语句

Within a list, the "container", "leaf", "list", "leaf-list", "uses", "choice", "anydata", and "anyxml" statements can be used to define child nodes to the list.

在列表中,“container”、“leaf”、“list”、“leaf list”、“uses”、“choice”、“anydata”和“anyxml”语句可用于定义列表的子节点。

7.8.5. XML Encoding Rules
7.8.5. XML编码规则

A list is encoded as a series of XML elements, one for each entry in the list. Each element's local name is the list's identifier, and its namespace is the module's XML namespace (see Section 7.1.3). There is no XML element surrounding the list as a whole.

列表被编码为一系列XML元素,列表中的每个条目对应一个XML元素。每个元素的本地名称是列表的标识符,其名称空间是模块的XML名称空间(参见第7.1.3节)。整个列表周围没有XML元素。

The list's key nodes are encoded as subelements to the list's identifier element, in the same order as they are defined within the "key" statement.

列表的关键节点被编码为列表标识符元素的子元素,其顺序与“key”语句中定义的顺序相同。

The rest of the list's child nodes are encoded as subelements to the list element, after the keys. If the list defines RPC or action input or output parameters, the subelements are encoded in the same order as they are defined within the "list" statement. Otherwise, the subelements are encoded in any order.

列表的其余子节点在键之后编码为列表元素的子元素。如果列表定义了RPC或操作输入或输出参数,则子元素的编码顺序与“list”语句中定义的顺序相同。否则,子元素按任意顺序编码。

Any whitespace between the subelements to the list entry is insignificant, i.e., an implementation MAY insert whitespace characters between subelements.

列表项的子元素之间的任何空白都是无关紧要的,即,实现可以在子元素之间插入空白字符。

The XML elements representing list entries MUST appear in the order specified by the user if the list is "ordered-by user"; otherwise, the order is implementation dependent. The XML elements representing list entries MAY be interleaved with elements for siblings of the list, unless the list defines RPC or action input or output parameters.

如果列表是“按用户排序”的,则表示列表项的XML元素必须按照用户指定的顺序出现;否则,顺序取决于实现。表示列表项的XML元素可以与列表同级的元素交错,除非列表定义了RPC或操作输入或输出参数。

7.8.6. NETCONF <edit-config> Operations
7.8.6. NETCONF<edit config>操作

List entries can be created, deleted, replaced, and modified through <edit-config> by using the "operation" attribute in the list's XML element. In each case, the values of all keys are used to uniquely identify a list entry. If all keys are not specified for a list entry, a "missing-element" error is returned.

通过使用列表XML元素中的“operation”属性,可以通过<edit config>创建、删除、替换和修改列表条目。在每种情况下,所有键的值都用于唯一标识列表条目。如果没有为列表项指定所有键,则返回“缺少元素”错误。

In an "ordered-by user" list, the attributes "insert" and "key" in the YANG XML namespace (Section 5.3.1) can be used to control where in the list the entry is inserted. These can be used during "create" operations to insert a new list entry, or during "merge" or "replace" operations to insert a new list entry or move an existing one.

在“按用户排序”列表中,XML名称空间(第5.3.1节)中的属性“插入”和“键”可用于控制条目在列表中插入的位置。可以在“创建”操作期间插入新列表项,或在“合并”或“替换”操作期间插入新列表项或移动现有列表项。

The "insert" attribute can take the values "first", "last", "before", and "after". If the value is "before" or "after", the "key" attribute MUST also be used, to specify an existing element in the list. The value of the "key" attribute is the key predicates of the full instance identifier (see Section 9.13) for the list entry.

“insert”属性可以采用值“first”、“last”、“before”和“after”。如果值为“before”或“after”,则还必须使用“key”属性来指定列表中的现有元素。“key”属性的值是列表项的完整实例标识符(见第9.13节)的键谓词。

If no "insert" attribute is present in the "create" operation, it defaults to "last".

如果“创建”操作中不存在“插入”属性,则默认为“最后”。

If several entries in an "ordered-by user" list are modified in the same <edit-config> request, the entries are modified one at a time, in the order of the XML elements in the request.

如果在同一个<edit config>请求中修改了“ordered by user”(按用户排序)列表中的多个条目,则会按照请求中XML元素的顺序一次修改一个条目。

In a <copy-config> or in an <edit-config> with a "replace" operation that covers the entire list, the list entry order is the same as the order of the XML elements in the request.

在<copy config>或具有覆盖整个列表的“replace”操作的<edit config>中,列表条目顺序与请求中XML元素的顺序相同。

When a NETCONF server processes an <edit-config> request, the elements of procedure for a list node are as follows:

当NETCONF服务器处理<edit config>请求时,列表节点的过程元素如下所示:

o If the operation is "merge" or "replace", the list entry is created if it does not exist. If the list entry already exists and the "insert" and "key" attributes are present, the list entry is moved according to the values of the "insert" and "key" attributes. If the list entry exists and the "insert" and "key" attributes are not present, the list entry is not moved.

o 如果操作为“合并”或“替换”,则会在列表项不存在时创建该列表项。如果列表项已经存在并且存在“插入”和“键”属性,则列表项将根据“插入”和“键”属性的值移动。如果列表条目存在且“插入”和“键”属性不存在,则列表条目不会移动。

o If the operation is "create", the list entry is created if it does not exist. If the list entry already exists, a "data-exists" error is returned.

o 如果操作为“创建”,则在列表项不存在时创建列表项。如果列表条目已经存在,则返回“数据存在”错误。

o If the operation is "delete", the entry is deleted from the list if it exists. If the list entry does not exist, a "data-missing" error is returned.

o 如果操作为“删除”,则该条目将从列表中删除(如果存在)。如果列表项不存在,则返回“数据丢失”错误。

7.8.7. Usage Example
7.8.7. 用法示例

Given the following list:

鉴于以下清单:

     list user {
       key "name";
       config true;
       description
         "This is a list of users in the system.";
        
     list user {
       key "name";
       config true;
       description
         "This is a list of users in the system.";
        
       leaf name {
         type string;
       }
       leaf type {
         type string;
       }
       leaf full-name {
         type string;
       }
     }
        
       leaf name {
         type string;
       }
       leaf type {
         type string;
       }
       leaf full-name {
         type string;
       }
     }
        

A corresponding XML instance example:

对应的XML实例示例:

     <user>
       <name>fred</name>
       <type>admin</type>
       <full-name>Fred Flintstone</full-name>
     </user>
        
     <user>
       <name>fred</name>
       <type>admin</type>
       <full-name>Fred Flintstone</full-name>
     </user>
        

To create a new user "barney":

要创建新用户“barney”:

     <rpc message-id="101"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
          xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
       <edit-config>
         <target>
           <running/>
         </target>
         <config>
           <system xmlns="urn:example:config">
             <user nc:operation="create">
               <name>barney</name>
               <type>admin</type>
               <full-name>Barney Rubble</full-name>
             </user>
           </system>
         </config>
       </edit-config>
     </rpc>
        
     <rpc message-id="101"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
          xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
       <edit-config>
         <target>
           <running/>
         </target>
         <config>
           <system xmlns="urn:example:config">
             <user nc:operation="create">
               <name>barney</name>
               <type>admin</type>
               <full-name>Barney Rubble</full-name>
             </user>
           </system>
         </config>
       </edit-config>
     </rpc>
        

To change the type of "fred" to "superuser":

要将“fred”的类型更改为“超级用户”:

     <rpc message-id="102"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
          xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
       <edit-config>
         <target>
           <running/>
         </target>
         <config>
           <system xmlns="urn:example:config">
             <user>
               <name>fred</name>
               <type>superuser</type>
             </user>
           </system>
         </config>
       </edit-config>
     </rpc>
        
     <rpc message-id="102"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
          xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
       <edit-config>
         <target>
           <running/>
         </target>
         <config>
           <system xmlns="urn:example:config">
             <user>
               <name>fred</name>
               <type>superuser</type>
             </user>
           </system>
         </config>
       </edit-config>
     </rpc>
        

Given the following ordered-by user list:

给定以下按用户顺序排列的列表:

     list user {
       description
         "This is a list of users in the system.";
       ordered-by user;
       config true;
        
     list user {
       description
         "This is a list of users in the system.";
       ordered-by user;
       config true;
        

key "first-name surname";

键“名字姓氏”;

       leaf first-name {
         type string;
       }
       leaf surname {
         type string;
       }
       leaf type {
         type string;
       }
     }
        
       leaf first-name {
         type string;
       }
       leaf surname {
         type string;
       }
       leaf type {
         type string;
       }
     }
        

The following would be used to insert a new user "barney rubble" after the user "fred flintstone":

以下内容将用于在用户“fred flintstone”之后插入新用户“barney Bruse”:

     <rpc message-id="101"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
          xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
          xmlns:yang="urn:ietf:params:xml:ns:yang:1">
       <edit-config>
         <target>
           <running/>
         </target>
         <config>
           <system xmlns="urn:example:config"
                xmlns:ex="urn:example:config">
             <user nc:operation="create"
                   yang:insert="after"
                   yang:key="[ex:first-name='fred']
                             [ex:surname='flintstone']">
               <first-name>barney</first-name>
               <surname>rubble</surname>
               <type>admin</type>
             </user>
           </system>
         </config>
       </edit-config>
     </rpc>
        
     <rpc message-id="101"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
          xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
          xmlns:yang="urn:ietf:params:xml:ns:yang:1">
       <edit-config>
         <target>
           <running/>
         </target>
         <config>
           <system xmlns="urn:example:config"
                xmlns:ex="urn:example:config">
             <user nc:operation="create"
                   yang:insert="after"
                   yang:key="[ex:first-name='fred']
                             [ex:surname='flintstone']">
               <first-name>barney</first-name>
               <surname>rubble</surname>
               <type>admin</type>
             </user>
           </system>
         </config>
       </edit-config>
     </rpc>
        

The following would be used to move the user "barney rubble" before the user "fred flintstone":

以下内容将用于在用户“fred flintstone”之前移动用户“barney碎石”:

     <rpc message-id="102"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
          xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
          xmlns:yang="urn:ietf:params:xml:ns:yang:1">
       <edit-config>
         <target>
           <running/>
         </target>
         <config>
           <system xmlns="urn:example:config"
                xmlns:ex="urn:example:config">
             <user nc:operation="merge"
                   yang:insert="before"
                   yang:key="[ex:name='fred']
                             [ex:surname='flintstone']">
               <first-name>barney</first-name>
               <surname>rubble</surname>
             </user>
           </system>
         </config>
       </edit-config>
     </rpc>
        
     <rpc message-id="102"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
          xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
          xmlns:yang="urn:ietf:params:xml:ns:yang:1">
       <edit-config>
         <target>
           <running/>
         </target>
         <config>
           <system xmlns="urn:example:config"
                xmlns:ex="urn:example:config">
             <user nc:operation="merge"
                   yang:insert="before"
                   yang:key="[ex:name='fred']
                             [ex:surname='flintstone']">
               <first-name>barney</first-name>
               <surname>rubble</surname>
             </user>
           </system>
         </config>
       </edit-config>
     </rpc>
        
7.9. The "choice" Statement
7.9. “选择”声明

The "choice" statement defines a set of alternatives, only one of which may be present in any one data tree. The argument is an identifier, followed by a block of substatements that holds detailed choice information. The identifier is used to identify the choice node in the schema tree. A choice node does not exist in the data tree.

“choice”语句定义了一组备选方案,其中只有一个可能出现在任何一个数据树中。参数是一个标识符,后跟一个包含详细选择信息的子语句块。标识符用于标识模式树中的选择节点。数据树中不存在选择节点。

A choice consists of a number of branches, each defined with a "case" substatement. Each branch contains a number of child nodes. The nodes from at most one of the choice's branches exist at the same time.

选项由多个分支组成,每个分支都定义了一个“case”子语句。每个分支包含多个子节点。最多一个选项分支中的节点同时存在。

Since only one of the choice's cases can be valid at any time in the data tree, the creation of a node from one case implicitly deletes all nodes from all other cases. If a request creates a node from a case, the server will delete any existing nodes that are defined in other cases inside the choice.

由于在数据树中任何时候只有一个选项的案例有效,因此从一个案例创建节点会隐式删除所有其他案例中的所有节点。如果请求从案例中创建节点,服务器将删除在选项中的其他案例中定义的任何现有节点。

7.9.1. The choice's Substatements
7.9.1. 选择的子状态
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | anydata      | 7.10    | 0..n        |
                 | anyxml       | 7.11    | 0..n        |
                 | case         | 7.9.2   | 0..n        |
                 | choice       | 7.9     | 0..n        |
                 | config       | 7.21.1  | 0..1        |
                 | container    | 7.5     | 0..n        |
                 | default      | 7.9.3   | 0..1        |
                 | description  | 7.21.3  | 0..1        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | leaf         | 7.6     | 0..n        |
                 | leaf-list    | 7.7     | 0..n        |
                 | list         | 7.8     | 0..n        |
                 | mandatory    | 7.9.4   | 0..1        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | when         | 7.21.5  | 0..1        |
                 +--------------+---------+-------------+
        
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | anydata      | 7.10    | 0..n        |
                 | anyxml       | 7.11    | 0..n        |
                 | case         | 7.9.2   | 0..n        |
                 | choice       | 7.9     | 0..n        |
                 | config       | 7.21.1  | 0..1        |
                 | container    | 7.5     | 0..n        |
                 | default      | 7.9.3   | 0..1        |
                 | description  | 7.21.3  | 0..1        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | leaf         | 7.6     | 0..n        |
                 | leaf-list    | 7.7     | 0..n        |
                 | list         | 7.8     | 0..n        |
                 | mandatory    | 7.9.4   | 0..1        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | when         | 7.21.5  | 0..1        |
                 +--------------+---------+-------------+
        
7.9.2. The choice's "case" Statement
7.9.2. 选择的“案例”陈述

The "case" statement is used to define branches of the choice. It takes as an argument an identifier, followed by a block of substatements that holds detailed case information.

“case”语句用于定义选项的分支。它将标识符作为参数,后跟一个包含详细案例信息的子语句块。

The identifier is used to identify the case node in the schema tree. A case node does not exist in the data tree.

标识符用于标识模式树中的案例节点。数据树中不存在案例节点。

Within a "case" statement, the "anydata", "anyxml", "choice", "container", "leaf", "list", "leaf-list", and "uses" statements can be used to define child nodes to the case node. The identifiers of all these child nodes MUST be unique within all cases in a choice. For example, the following is illegal:

在“case”语句中,“anydata”、“anyxml”、“choice”、“container”、“leaf”、“list”、“leaf list”和“uses”语句可用于定义case节点的子节点。所有这些子节点的标识符在选项的所有情况下都必须是唯一的。例如,以下行为是非法的:

     choice interface-type {     // This example is illegal YANG
       case a {
         leaf ethernet { ... }
       }
       case b {
         container ethernet { ...}
       }
     }
        
     choice interface-type {     // This example is illegal YANG
       case a {
         leaf ethernet { ... }
       }
       case b {
         container ethernet { ...}
       }
     }
        

As a shorthand, the "case" statement can be omitted if the branch contains a single "anydata", "anyxml", "choice", "container", "leaf", "list", or "leaf-list" statement. In this case, the case node still exists in the schema tree, and its identifier is the same as the identifier of the child node. Schema node identifiers (Section 6.5) MUST always explicitly include case node identifiers. The following example:

简而言之,如果分支包含单个“anydata”、“anyxml”、“choice”、“container”、“leaf”、“list”或“leaf list”语句,则可以省略“case”语句。在这种情况下,案例节点仍然存在于模式树中,其标识符与子节点的标识符相同。模式节点标识符(第6.5节)必须始终明确包括案例节点标识符。下面是一个例子:

     choice interface-type {
       container ethernet { ... }
     }
        
     choice interface-type {
       container ethernet { ... }
     }
        

is equivalent to:

相当于:

     choice interface-type {
       case ethernet {
         container ethernet { ... }
       }
     }
        
     choice interface-type {
       case ethernet {
         container ethernet { ... }
       }
     }
        

The case identifier MUST be unique within a choice.

案例标识符在选项中必须是唯一的。

7.9.2.1. The case's Substatements
7.9.2.1. 本案的子条款
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | anydata      | 7.10    | 0..n        |
                 | anyxml       | 7.11    | 0..n        |
                 | choice       | 7.9     | 0..n        |
                 | container    | 7.5     | 0..n        |
                 | description  | 7.21.3  | 0..1        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | leaf         | 7.6     | 0..n        |
                 | leaf-list    | 7.7     | 0..n        |
                 | list         | 7.8     | 0..n        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | uses         | 7.13    | 0..n        |
                 | when         | 7.21.5  | 0..1        |
                 +--------------+---------+-------------+
        
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | anydata      | 7.10    | 0..n        |
                 | anyxml       | 7.11    | 0..n        |
                 | choice       | 7.9     | 0..n        |
                 | container    | 7.5     | 0..n        |
                 | description  | 7.21.3  | 0..1        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | leaf         | 7.6     | 0..n        |
                 | leaf-list    | 7.7     | 0..n        |
                 | list         | 7.8     | 0..n        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | uses         | 7.13    | 0..n        |
                 | when         | 7.21.5  | 0..1        |
                 +--------------+---------+-------------+
        
7.9.3. The choice's "default" Statement
7.9.3. 选项的“默认”语句

The "default" statement indicates if a case should be considered as the default if no child nodes from any of the choice's cases exist. The argument is the identifier of the default "case" statement. If the "default" statement is missing, there is no default case.

“default”语句表示如果该选项的任何案例都不存在子节点,则该案例是否应被视为默认案例。参数是默认“case”语句的标识符。如果缺少“default”语句,则不存在默认情况。

The "default" statement MUST NOT be present on choices where "mandatory" is "true".

“默认”语句不得出现在“强制”为“真”的选项上。

The default case is only important when considering the "default" statements of nodes under the cases (i.e., default values of leafs and leaf-lists, and default cases of nested choices). The default values and nested default cases under the default case are used if none of the nodes under any of the cases are present.

默认情况仅在考虑情况下节点的“默认”语句时才重要(即,叶和叶列表的默认值,以及嵌套选择的默认情况)。如果任何案例下的节点都不存在,则使用默认案例下的默认值和嵌套默认案例。

There MUST NOT be any mandatory nodes (Section 3) directly under the default case.

默认情况下不得有任何强制节点(第3节)。

Default values for child nodes under a case are only used if one of the nodes under that case is present or if that case is the default case. If none of the nodes under a case are present and the case is not the default case, the default values of the cases' child nodes are ignored.

仅当案例下的一个节点存在或该案例为默认案例时,才会使用该案例下的子节点的默认值。如果案例下的所有节点都不存在且案例不是默认案例,则案例子节点的默认值将被忽略。

In this example, the choice defaults to "interval", and the default value will be used if none of "daily", "time-of-day", or "manual" are present. If "daily" is present, the default value for "time-of-day" will be used.

在本例中,该选项默认为“interval”,如果“daily”、“time of day”或“manual”均不存在,则将使用默认值。如果存在“每日”,则将使用“每日时间”的默认值。

     container transfer {
       choice how {
         default interval;
         case interval {
           leaf interval {
             type uint16;
             units minutes;
             default 30;
           }
         }
         case daily {
           leaf daily {
             type empty;
           }
           leaf time-of-day {
             type string;
             units 24-hour-clock;
             default "01.00";
           }
         }
         case manual {
           leaf manual {
             type empty;
           }
         }
       }
     }
        
     container transfer {
       choice how {
         default interval;
         case interval {
           leaf interval {
             type uint16;
             units minutes;
             default 30;
           }
         }
         case daily {
           leaf daily {
             type empty;
           }
           leaf time-of-day {
             type string;
             units 24-hour-clock;
             default "01.00";
           }
         }
         case manual {
           leaf manual {
             type empty;
           }
         }
       }
     }
        
7.9.4. The choice's "mandatory" Statement
7.9.4. 选择的“强制性”声明

The "mandatory" statement, which is optional, takes as an argument the string "true" or "false" and puts a constraint on valid data. If "mandatory" is "true", at least one node from exactly one of the choice's case branches MUST exist.

“mandatory”语句是可选的,它将字符串“true”或“false”作为参数,并对有效数据进行约束。如果“mandatory”为“true”,则必须至少存在一个节点,该节点恰好来自该选项的一个案例分支。

If not specified, the default is "false".

如果未指定,则默认值为“false”。

The behavior of the constraint depends on the type of the choice's closest ancestor node in the schema tree that is not a non-presence container (see Section 7.5.1):

约束的行为取决于模式树中选择的最近祖先节点的类型,该节点不是非存在容器(参见第7.5.1节):

o If no such ancestor exists in the schema tree, the constraint is enforced.

o 如果模式树中不存在这样的祖先,则强制执行约束。

o Otherwise, if this ancestor is a case node, the constraint is enforced if any other node from the case exists.

o 否则,如果此祖先是案例节点,则如果案例中存在任何其他节点,则强制执行约束。

o Otherwise, it is enforced if the ancestor node exists.

o 否则,如果祖先节点存在,则强制执行。

The constraint is further enforced according to the rules in Section 8.

根据第8节中的规则,进一步实施约束。

7.9.5. XML Encoding Rules
7.9.5. XML编码规则

The choice and case nodes are not visible in XML.

choice和case节点在XML中不可见。

The child nodes of the selected "case" statement MUST be encoded in the same order as they are defined in the "case" statement if they are part of an RPC or action input or output parameter definition. Otherwise, the subelements are encoded in any order.

如果所选“case”语句的子节点是RPC或操作输入或输出参数定义的一部分,则必须按照在“case”语句中定义的顺序对其进行编码。否则,子元素按任意顺序编码。

7.9.6. Usage Example
7.9.6. 用法示例

Given the following choice:

鉴于以下选择:

     container protocol {
       choice name {
         case a {
           leaf udp {
             type empty;
           }
         }
         case b {
           leaf tcp {
             type empty;
           }
         }
       }
     }
        
     container protocol {
       choice name {
         case a {
           leaf udp {
             type empty;
           }
         }
         case b {
           leaf tcp {
             type empty;
           }
         }
       }
     }
        

A corresponding XML instance example:

对应的XML实例示例:

     <protocol>
       <tcp/>
     </protocol>
        
     <protocol>
       <tcp/>
     </protocol>
        

To change the protocol from TCP to UDP:

要将协议从TCP更改为UDP,请执行以下操作:

     <rpc message-id="101"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
          xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
       <edit-config>
         <target>
           <running/>
         </target>
         <config>
           <system xmlns="urn:example:config">
             <protocol>
               <udp nc:operation="create"/>
             </protocol>
           </system>
         </config>
       </edit-config>
     </rpc>
        
     <rpc message-id="101"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
          xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
       <edit-config>
         <target>
           <running/>
         </target>
         <config>
           <system xmlns="urn:example:config">
             <protocol>
               <udp nc:operation="create"/>
             </protocol>
           </system>
         </config>
       </edit-config>
     </rpc>
        
7.10. The "anydata" Statement
7.10. “anydata”语句

The "anydata" statement defines an interior node in the schema tree. It takes one argument, which is an identifier, followed by a block of substatements that holds detailed anydata information.

“anydata”语句定义模式树中的内部节点。它有一个参数,它是一个标识符,后跟一个包含详细anydata信息的子语句块。

The "anydata" statement is used to represent an unknown set of nodes that can be modeled with YANG, except anyxml, but for which the data model is not known at module design time. It is possible, though not required, for the data model for anydata content to become known through protocol signaling or other means that are outside the scope of this document.

“anydata”语句用于表示可以使用YANG建模的未知节点集,anyxml除外,但在模块设计时数据模型未知。任何数据内容的数据模型都可以通过协议信令或本文件范围之外的其他方式而为人所知,尽管不是必需的。

An example of where anydata can be useful is a list of received notifications where the specific notifications are not known at design time.

anydata有用的一个示例是接收到的通知列表,其中特定的通知在设计时是未知的。

An anydata node cannot be augmented (see Section 7.17).

不能扩充anydata节点(参见第7.17节)。

An anydata node exists in zero or one instance in the data tree.

anydata节点存在于数据树中的零个或一个实例中。

An implementation may or may not know the data model used to model a specific instance of an anydata node.

实现可能知道也可能不知道用于对anydata节点的特定实例建模的数据模型。

Since the use of anydata limits the manipulation of the content, the "anydata" statement SHOULD NOT be used to define configuration data.

由于anydata的使用限制了对内容的操作,“anydata”语句不应用于定义配置数据。

7.10.1. The anydata's Substatements
7.10.1. anydata的子语句
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | config       | 7.21.1  | 0..1        |
                 | description  | 7.21.3  | 0..1        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | mandatory    | 7.6.5   | 0..1        |
                 | must         | 7.5.3   | 0..n        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | when         | 7.21.5  | 0..1        |
                 +--------------+---------+-------------+
        
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | config       | 7.21.1  | 0..1        |
                 | description  | 7.21.3  | 0..1        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | mandatory    | 7.6.5   | 0..1        |
                 | must         | 7.5.3   | 0..n        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | when         | 7.21.5  | 0..1        |
                 +--------------+---------+-------------+
        
7.10.2. XML Encoding Rules
7.10.2. XML编码规则

An anydata node is encoded as an XML element. The element's local name is the anydata's identifier, and its namespace is the module's XML namespace (see Section 7.1.3). The value of the anydata node is a set of nodes, which are encoded as XML subelements to the anydata element.

anydata节点编码为XML元素。元素的本地名称是anydata的标识符,其名称空间是模块的XML名称空间(参见第7.1.3节)。anydata节点的值是一组节点,这些节点被编码为anydata元素的XML子元素。

7.10.3. NETCONF <edit-config> Operations
7.10.3. NETCONF<edit config>操作

An anydata node is treated as an opaque chunk of data. This data can be modified in its entirety only.

anydata节点被视为不透明的数据块。此数据只能全部修改。

Any "operation" attributes present on subelements of an anydata node are ignored by the NETCONF server.

NETCONF服务器将忽略anydata节点子元素上的任何“操作”属性。

When a NETCONF server processes an <edit-config> request, the elements of procedure for the anydata node are as follows:

当NETCONF服务器处理<edit config>请求时,anydata节点的过程元素如下所示:

o If the operation is "merge" or "replace", the node is created if it does not exist, and its value is set to the subelements of the anydata node found in the XML RPC data.

o 如果操作为“merge”或“replace”,则将在节点不存在时创建该节点,并将其值设置为在XML RPC数据中找到的anydata节点的子元素。

o If the operation is "create", the node is created if it does not exist, and its value is set to the subelements of the anydata node found in the XML RPC data. If the node already exists, a "data-exists" error is returned.

o 如果操作为“create”,则将在节点不存在时创建该节点,并将其值设置为在XML RPC数据中找到的anydata节点的子元素。如果节点已经存在,则返回“数据存在”错误。

o If the operation is "delete", the node is deleted if it exists. If the node does not exist, a "data-missing" error is returned.

o 如果操作为“删除”,则删除节点(如果存在)。如果节点不存在,则返回“数据丢失”错误。

7.10.4. Usage Example
7.10.4. 用法示例

Given the following "anydata" statement:

给出以下“anydata”语句:

     list logged-notification {
       key time;
       leaf time {
         type yang:date-and-time;
       }
       anydata data;
     }
        
     list logged-notification {
       key time;
       leaf time {
         type yang:date-and-time;
       }
       anydata data;
     }
        

The following is a valid encoding of such a list instance:

以下是此类列表实例的有效编码:

     <logged-notification>
       <time>2014-07-29T13:43:12Z</time>
       <data>
         <notification
           xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
           <eventTime>2014-07-29T13:43:01Z</eventTime>
           <event xmlns="urn:example:event">
             <event-class>fault</event-class>
             <reporting-entity>
               <card>Ethernet0</card>
             </reporting-entity>
             <severity>major</severity>
           </event>
         </notification>
       </data>
     </logged-notification>
        
     <logged-notification>
       <time>2014-07-29T13:43:12Z</time>
       <data>
         <notification
           xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
           <eventTime>2014-07-29T13:43:01Z</eventTime>
           <event xmlns="urn:example:event">
             <event-class>fault</event-class>
             <reporting-entity>
               <card>Ethernet0</card>
             </reporting-entity>
             <severity>major</severity>
           </event>
         </notification>
       </data>
     </logged-notification>
        
7.11. The "anyxml" Statement
7.11. “anyxml”语句

The "anyxml" statement defines an interior node in the schema tree. It takes one argument, which is an identifier, followed by a block of substatements that holds detailed anyxml information.

“anyxml”语句在模式树中定义一个内部节点。它有一个参数,它是一个标识符,后跟一个包含详细的anyxml信息的子语句块。

The "anyxml" statement is used to represent an unknown chunk of XML. No restrictions are placed on the XML. This can be useful, for example, in RPC replies. An example is the <filter> parameter in the <get-config> operation in NETCONF.

“anyxml”语句用于表示未知的XML块。对XML没有任何限制。这可能很有用,例如,在RPC回复中。一个例子是NETCONF中<get config>操作中的<filter>参数。

An anyxml node cannot be augmented (see Section 7.17).

不能扩充anyxml节点(参见第7.17节)。

An anyxml node exists in zero or one instance in the data tree.

anyxml节点存在于数据树中的零个或一个实例中。

Since the use of anyxml limits the manipulation of the content, the "anyxml" statement SHOULD NOT be used to define configuration data.

由于anyxml的使用限制了对内容的操作,“anyxml”语句不应用于定义配置数据。

It should be noted that in YANG version 1, "anyxml" was the only statement that could model an unknown hierarchy of data. In many cases, this unknown hierarchy of data is actually modeled in YANG, but the specific YANG data model is not known at design time. In these situations, it is RECOMMENDED to use "anydata" (Section 7.10) instead of "anyxml".

应该注意的是,在YANG版本1中,“anyxml”是唯一可以对未知数据层次结构建模的语句。在许多情况下,这种未知的数据层次结构实际上是在YANG中建模的,但具体的YANG数据模型在设计时是未知的。在这些情况下,建议使用“anydata”(第7.10节)而不是“anyxml”。

7.11.1. The anyxml's Substatements
7.11.1. anyxml的子语句
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | config       | 7.21.1  | 0..1        |
                 | description  | 7.21.3  | 0..1        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | mandatory    | 7.6.5   | 0..1        |
                 | must         | 7.5.3   | 0..n        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | when         | 7.21.5  | 0..1        |
                 +--------------+---------+-------------+
        
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | config       | 7.21.1  | 0..1        |
                 | description  | 7.21.3  | 0..1        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | mandatory    | 7.6.5   | 0..1        |
                 | must         | 7.5.3   | 0..n        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | when         | 7.21.5  | 0..1        |
                 +--------------+---------+-------------+
        
7.11.2. XML Encoding Rules
7.11.2. XML编码规则

An anyxml node is encoded as an XML element. The element's local name is the anyxml's identifier, and its namespace is the module's XML namespace (see Section 7.1.3). The value of the anyxml node is encoded as XML content of this element.

anyxml节点编码为XML元素。元素的本地名称是anyxml的标识符,其名称空间是模块的XML名称空间(参见第7.1.3节)。anyxml节点的值被编码为该元素的XML内容。

Note that any XML prefixes used in the encoding are local to each instance encoding. This means that the same XML may be encoded differently by different implementations.

请注意,编码中使用的任何XML前缀都是每个实例编码的本地前缀。这意味着相同的XML可以通过不同的实现进行不同的编码。

7.11.3. NETCONF <edit-config> Operations
7.11.3. NETCONF<edit config>操作

An anyxml node is treated as an opaque chunk of data. This data can be modified in its entirety only.

anyxml节点被视为不透明的数据块。此数据只能全部修改。

Any "operation" attributes present on subelements of an anyxml node are ignored by the NETCONF server.

NETCONF服务器将忽略anyxml节点子元素上的任何“操作”属性。

When a NETCONF server processes an <edit-config> request, the elements of procedure for the anyxml node are as follows:

当NETCONF服务器处理<edit config>请求时,anyxml节点的过程元素如下所示:

o If the operation is "merge" or "replace", the node is created if it does not exist, and its value is set to the XML content of the anyxml node found in the XML RPC data.

o 如果操作为“merge”或“replace”,则将在节点不存在时创建该节点,并将其值设置为在XML RPC数据中找到的anyxml节点的XML内容。

o If the operation is "create", the node is created if it does not exist, and its value is set to the XML content of the anyxml node found in the XML RPC data. If the node already exists, a "data-exists" error is returned.

o 如果操作为“create”,则将在节点不存在时创建该节点,并将其值设置为在XML RPC数据中找到的anyxml节点的XML内容。如果节点已经存在,则返回“数据存在”错误。

o If the operation is "delete", the node is deleted if it exists. If the node does not exist, a "data-missing" error is returned.

o 如果操作为“删除”,则删除节点(如果存在)。如果节点不存在,则返回“数据丢失”错误。

7.11.4. Usage Example
7.11.4. 用法示例

Given the following "anyxml" statement:

给出以下“anyxml”语句:

anyxml html-info;

任何XML html信息;

The following are two valid encodings of the same anyxml value:

以下是相同anyxml值的两个有效编码:

      <html-info>
        <p xmlns="http://www.w3.org/1999/xhtml">
          This is <em>very</em> cool.
        </p>
      </html-info>
        
      <html-info>
        <p xmlns="http://www.w3.org/1999/xhtml">
          This is <em>very</em> cool.
        </p>
      </html-info>
        
      <html-info>
        <x:p xmlns:x="http://www.w3.org/1999/xhtml">
          This is <x:em>very</x:em> cool.
        </x:p>
      </html-info>
        
      <html-info>
        <x:p xmlns:x="http://www.w3.org/1999/xhtml">
          This is <x:em>very</x:em> cool.
        </x:p>
      </html-info>
        
7.12. The "grouping" Statement
7.12. “分组”语句

The "grouping" statement is used to define a reusable block of nodes, which may be used locally in the module or submodule, and by other modules that import from it, according to the rules in Section 5.5. It takes one argument, which is an identifier, followed by a block of substatements that holds detailed grouping information.

“分组”语句用于定义一个可重用的节点块,根据第5.5节中的规则,该节点块可以在模块或子模块中本地使用,也可以由从中导入的其他模块使用。它采用一个参数(标识符),后跟一个包含详细分组信息的子语句块。

The "grouping" statement is not a data definition statement and, as such, does not define any nodes in the schema tree.

“grouping”语句不是数据定义语句,因此不定义模式树中的任何节点。

A grouping is like a "structure" or a "record" in conventional programming languages.

分组就像传统编程语言中的“结构”或“记录”。

Once a grouping is defined, it can be referenced in a "uses" statement (see Section 7.13). A grouping MUST NOT reference itself, neither directly nor indirectly through a chain of other groupings.

一旦定义了分组,就可以在“使用”语句中引用它(参见第7.13节)。分组不得直接或间接通过其他分组链引用自身。

If the grouping is defined at the top level of a YANG module or submodule, the grouping's identifier MUST be unique within the module.

如果分组是在模块或子模块的顶层定义的,则分组的标识符在模块内必须是唯一的。

A grouping is more than just a mechanism for textual substitution; it also defines a collection of nodes. Identifiers appearing inside the grouping are resolved relative to the scope in which the grouping is defined, not where it is used. Prefix mappings, type names, grouping names, and extension usage are evaluated in the hierarchy

分组不仅仅是一种文本替换机制;它还定义了一个节点集合。出现在分组中的标识符是相对于定义分组的范围而不是使用分组的位置来解析的。前缀映射、类型名称、分组名称和扩展使用在层次结构中进行评估

where the "grouping" statement appears. For extensions, this means that extensions defined as direct children to a "grouping" statement are applied to the grouping itself.

出现“分组”语句的位置。对于扩展,这意味着定义为“grouping”语句的直接子级的扩展将应用于分组本身。

Note that if a grouping defines an action or a notification node in its hierarchy, then it cannot be used in all contexts. For example, it cannot be used in an rpc definition. See Sections 7.15 and 7.16.

请注意,如果分组在其层次结构中定义了操作或通知节点,则不能在所有上下文中使用它。例如,它不能在rpc定义中使用。见第7.15节和第7.16节。

7.12.1. The grouping's Substatements
7.12.1. 分组的子状态
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | action       | 7.15    | 0..n        |
                 | anydata      | 7.10    | 0..n        |
                 | anyxml       | 7.11    | 0..n        |
                 | choice       | 7.9     | 0..n        |
                 | container    | 7.5     | 0..n        |
                 | description  | 7.21.3  | 0..1        |
                 | grouping     | 7.12    | 0..n        |
                 | leaf         | 7.6     | 0..n        |
                 | leaf-list    | 7.7     | 0..n        |
                 | list         | 7.8     | 0..n        |
                 | notification | 7.16    | 0..n        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | typedef      | 7.3     | 0..n        |
                 | uses         | 7.13    | 0..n        |
                 +--------------+---------+-------------+
        
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | action       | 7.15    | 0..n        |
                 | anydata      | 7.10    | 0..n        |
                 | anyxml       | 7.11    | 0..n        |
                 | choice       | 7.9     | 0..n        |
                 | container    | 7.5     | 0..n        |
                 | description  | 7.21.3  | 0..1        |
                 | grouping     | 7.12    | 0..n        |
                 | leaf         | 7.6     | 0..n        |
                 | leaf-list    | 7.7     | 0..n        |
                 | list         | 7.8     | 0..n        |
                 | notification | 7.16    | 0..n        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | typedef      | 7.3     | 0..n        |
                 | uses         | 7.13    | 0..n        |
                 +--------------+---------+-------------+
        
7.12.2. Usage Example
7.12.2. 用法示例
     import ietf-inet-types {
       prefix "inet";
     }
        
     import ietf-inet-types {
       prefix "inet";
     }
        
     grouping endpoint {
       description "A reusable endpoint group.";
       leaf ip {
         type inet:ip-address;
       }
       leaf port {
         type inet:port-number;
       }
     }
        
     grouping endpoint {
       description "A reusable endpoint group.";
       leaf ip {
         type inet:ip-address;
       }
       leaf port {
         type inet:port-number;
       }
     }
        
7.13. The "uses" Statement
7.13. “使用”语句

The "uses" statement is used to reference a "grouping" definition. It takes one argument, which is the name of the grouping.

“uses”语句用于引用“grouping”定义。它接受一个参数,即分组的名称。

The effect of a "uses" reference to a grouping is that the nodes defined by the grouping are copied into the current schema tree and are then updated according to the "refine" and "augment" statements.

对分组的“uses”引用的效果是将分组定义的节点复制到当前模式树中,然后根据“refine”和“augment”语句进行更新。

The identifiers defined in the grouping are not bound to a namespace until the contents of the grouping are added to the schema tree via a "uses" statement that does not appear inside a "grouping" statement, at which point they are bound to the namespace of the current module.

分组中定义的标识符不会绑定到名称空间,直到分组的内容通过“uses”语句添加到架构树中,该语句不出现在“grouping”语句中,此时它们被绑定到当前模块的名称空间。

7.13.1. The uses's Substatements
7.13.1. 用户的子状态
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | augment      | 7.17    | 0..n        |
                 | description  | 7.21.3  | 0..1        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | reference    | 7.21.4  | 0..1        |
                 | refine       | 7.13.2  | 0..n        |
                 | status       | 7.21.2  | 0..1        |
                 | when         | 7.21.5  | 0..1        |
                 +--------------+---------+-------------+
        
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | augment      | 7.17    | 0..n        |
                 | description  | 7.21.3  | 0..1        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | reference    | 7.21.4  | 0..1        |
                 | refine       | 7.13.2  | 0..n        |
                 | status       | 7.21.2  | 0..1        |
                 | when         | 7.21.5  | 0..1        |
                 +--------------+---------+-------------+
        
7.13.2. The "refine" Statement
7.13.2. “细化”声明

Some of the properties of each node in the grouping can be refined with the "refine" statement. The argument is a string that identifies a node in the grouping. This node is called the refine's target node. If a node in the grouping is not present as a target node of a "refine" statement, it is not refined and thus is used exactly as it was defined in the grouping.

分组中每个节点的某些属性可以使用“refine”语句进行细化。参数是标识分组中节点的字符串。此节点称为优化的目标节点。如果分组中的某个节点未作为“refine”语句的目标节点出现,则该节点不会被细化,因此其使用方式与分组中定义的完全相同。

The argument string is a descendant schema node identifier (see Section 6.5).

参数字符串是子模式节点标识符(参见第6.5节)。

The following refinements can be done:

可以进行以下改进:

o A leaf or choice node may get a default value, or a new default value if it already had one.

o 叶节点或选择节点可能会获得默认值,如果已经有默认值,则可能会获得新的默认值。

o A leaf-list node may get a set of default values, or a new set of default values if it already had defaults; i.e., the set of refined default values replaces the defaults already given.

o 叶列表节点可以获得一组默认值,如果已经有默认值,则可以获得一组新的默认值;i、 例如,经过优化的默认值集将替换已经给定的默认值。

o Any node may get a specialized "description" string.

o 任何节点都可以获得专门的“描述”字符串。

o Any node may get a specialized "reference" string.

o 任何节点都可以获得专门的“引用”字符串。

o Any node may get a different "config" statement.

o 任何节点都可能得到不同的“config”语句。

o A leaf, anydata, anyxml, or choice node may get a different "mandatory" statement.

o 叶、anydata、anyxml或choice节点可能会得到不同的“强制”语句。

o A container node may get a "presence" statement.

o 容器节点可能会得到“presence”语句。

o A leaf, leaf-list, list, container, anydata, or anyxml node may get additional "must" expressions.

o 叶、叶列表、列表、容器、anydata或anyxml节点可能会获得其他“必须”表达式。

o A leaf-list or list node may get a different "min-elements" or "max-elements" statement.

o 叶列表或列表节点可能会得到不同的“最小元素”或“最大元素”语句。

o A leaf, leaf-list, list, container, choice, case, anydata, or anyxml node may get additional "if-feature" expressions.

o 叶、叶列表、列表、容器、选项、大小写、anydata或anyxml节点可能会得到额外的“if-feature”表达式。

o Any node can get refined extensions, if the extension allows refinement. See Section 7.19 for details.

o 如果扩展允许细化,任何节点都可以获得细化扩展。详见第7.19节。

7.13.3. XML Encoding Rules
7.13.3. XML编码规则

Each node in the grouping is encoded as if it was defined inline, even if it is imported from another module with another XML namespace.

分组中的每个节点都被编码为内联定义,即使它是从另一个具有另一个XML命名空间的模块导入的。

7.13.4. Usage Example
7.13.4. 用法示例

To use the "endpoint" grouping defined in Section 7.12.2 in a definition of an HTTP server in some other module, we can do:

要在其他模块的HTTP服务器定义中使用第7.12.2节中定义的“端点”分组,我们可以执行以下操作:

     import example-system {
       prefix "sys";
     }
        
     import example-system {
       prefix "sys";
     }
        
     container http-server {
       leaf name {
         type string;
       }
       uses sys:endpoint;
     }
        
     container http-server {
       leaf name {
         type string;
       }
       uses sys:endpoint;
     }
        

A corresponding XML instance example:

对应的XML实例示例:

     <http-server>
       <name>extern-web</name>
       <ip>192.0.2.1</ip>
       <port>80</port>
     </http-server>
        
     <http-server>
       <name>extern-web</name>
       <ip>192.0.2.1</ip>
       <port>80</port>
     </http-server>
        

If port 80 should be the default for the HTTP server, a default can be added:

如果HTTP服务器的默认端口为80,则可以添加默认端口:

     container http-server {
       leaf name {
         type string;
       }
       uses sys:endpoint {
         refine port {
           default 80;
         }
       }
     }
        
     container http-server {
       leaf name {
         type string;
       }
       uses sys:endpoint {
         refine port {
           default 80;
         }
       }
     }
        

If we want to define a list of servers and each server has "ip" and "port" as keys, we can do:

如果我们要定义一个服务器列表,并且每个服务器都有“ip”和“端口”作为密钥,我们可以执行以下操作:

     list server {
       key "ip port";
       leaf name {
         type string;
       }
       uses sys:endpoint;
     }
        
     list server {
       key "ip port";
       leaf name {
         type string;
       }
       uses sys:endpoint;
     }
        

The following is an error:

以下是一个错误:

     container http-server {
       uses sys:endpoint;
       leaf ip {          // illegal - same identifier "ip" used twice
         type string;
       }
     }
        
     container http-server {
       uses sys:endpoint;
       leaf ip {          // illegal - same identifier "ip" used twice
         type string;
       }
     }
        
7.14. The "rpc" Statement
7.14. “rpc”语句

The "rpc" statement is used to define an RPC operation. It takes one argument, which is an identifier, followed by a block of substatements that holds detailed rpc information. This argument is the name of the RPC.

“rpc”语句用于定义rpc操作。它有一个参数,它是一个标识符,后跟一个包含详细rpc信息的子语句块。此参数是RPC的名称。

The "rpc" statement defines an rpc node in the schema tree. Under the rpc node, a schema node with the name "input" and a schema node with the name "output" are also defined. The nodes "input" and "output" are defined in the module's namespace.

“rpc”语句在模式树中定义了一个rpc节点。在rpc节点下,还定义了名为“input”的模式节点和名为“output”的模式节点。节点“输入”和“输出”在模块的命名空间中定义。

7.14.1. The rpc's Substatements
7.14.1. rpc的子状态
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | description  | 7.21.3  | 0..1        |
                 | grouping     | 7.12    | 0..n        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | input        | 7.14.2  | 0..1        |
                 | output       | 7.14.3  | 0..1        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | typedef      | 7.3     | 0..n        |
                 +--------------+---------+-------------+
        
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | description  | 7.21.3  | 0..1        |
                 | grouping     | 7.12    | 0..n        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | input        | 7.14.2  | 0..1        |
                 | output       | 7.14.3  | 0..1        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | typedef      | 7.3     | 0..n        |
                 +--------------+---------+-------------+
        
7.14.2. The "input" Statement
7.14.2. “输入”语句

The "input" statement, which is optional, is used to define input parameters to the operation. It does not take an argument. The substatements to "input" define nodes under the operation's input node.

“input”语句是可选的,用于定义操作的输入参数。这不需要争论。“input”的子语句定义操作输入节点下的节点。

If a leaf in the input tree has a "mandatory" statement with the value "true", the leaf MUST be present in an RPC invocation.

如果输入树中的某个叶具有值为“true”的“强制”语句,则该叶必须存在于RPC调用中。

If a leaf in the input tree has a default value, the server MUST use this value in the same cases as those described in Section 7.6.1. In these cases, the server MUST operationally behave as if the leaf was present in the RPC invocation with the default value as its value.

如果输入树中的叶具有默认值,则服务器必须在与第7.6.1节所述相同的情况下使用该值。在这些情况下,服务器必须在操作上表现得像RPC调用中存在叶一样,并以默认值作为其值。

If a leaf-list in the input tree has one or more default values, the server MUST use these values in the same cases as those described in Section 7.7.2. In these cases, the server MUST operationally behave as if the leaf-list was present in the RPC invocation with the default values as its values.

如果输入树中的叶列表具有一个或多个默认值,则服务器必须在与第7.7.2节所述相同的情况下使用这些值。在这些情况下,服务器必须在操作上表现得像RPC调用中存在叶列表一样,并使用默认值作为其值。

Since the input tree is not part of any datastore, all "config" statements for nodes in the input tree are ignored.

由于输入树不是任何数据存储的一部分,因此将忽略输入树中节点的所有“config”语句。

If any node has a "when" statement that would evaluate to "false", then this node MUST NOT be present in the input tree.

如果任何节点的“when”语句的计算结果为“false”,则该节点不得出现在输入树中。

7.14.2.1. The input's Substatements
7.14.2.1. 输入的子语句
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | anydata      | 7.10    | 0..n        |
                 | anyxml       | 7.11    | 0..n        |
                 | choice       | 7.9     | 0..n        |
                 | container    | 7.5     | 0..n        |
                 | grouping     | 7.12    | 0..n        |
                 | leaf         | 7.6     | 0..n        |
                 | leaf-list    | 7.7     | 0..n        |
                 | list         | 7.8     | 0..n        |
                 | must         | 7.5.3   | 0..n        |
                 | typedef      | 7.3     | 0..n        |
                 | uses         | 7.13    | 0..n        |
                 +--------------+---------+-------------+
        
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | anydata      | 7.10    | 0..n        |
                 | anyxml       | 7.11    | 0..n        |
                 | choice       | 7.9     | 0..n        |
                 | container    | 7.5     | 0..n        |
                 | grouping     | 7.12    | 0..n        |
                 | leaf         | 7.6     | 0..n        |
                 | leaf-list    | 7.7     | 0..n        |
                 | list         | 7.8     | 0..n        |
                 | must         | 7.5.3   | 0..n        |
                 | typedef      | 7.3     | 0..n        |
                 | uses         | 7.13    | 0..n        |
                 +--------------+---------+-------------+
        
7.14.3. The "output" Statement
7.14.3. “输出”语句

The "output" statement, which is optional, is used to define output parameters to the RPC operation. It does not take an argument. The substatements to "output" define nodes under the operation's output node.

“output”语句是可选的,用于定义RPC操作的输出参数。这不需要争论。“output”的子语句定义操作的输出节点下的节点。

If a leaf in the output tree has a "mandatory" statement with the value "true", the leaf MUST be present in an RPC reply.

如果输出树中的某个叶具有值为“true”的“mandatory”语句,则该叶必须出现在RPC应答中。

If a leaf in the output tree has a default value, the client MUST use this value in the same cases as those described in Section 7.6.1. In these cases, the client MUST operationally behave as if the leaf was present in the RPC reply with the default value as its value.

如果输出树中的叶具有默认值,则客户端必须在与第7.6.1节所述相同的情况下使用该值。在这些情况下,客户端必须在操作上表现得像RPC应答中存在叶一样,并将默认值作为其值。

If a leaf-list in the output tree has one or more default values, the client MUST use these values in the same cases as those described in Section 7.7.2. In these cases, the client MUST operationally behave as if the leaf-list was present in the RPC reply with the default values as its values.

如果输出树中的叶列表具有一个或多个默认值,则客户端必须在与第7.7.2节所述相同的情况下使用这些值。在这些情况下,客户端必须在操作上表现得像RPC应答中存在叶列表一样,并使用默认值作为其值。

Since the output tree is not part of any datastore, all "config" statements for nodes in the output tree are ignored.

由于输出树不是任何数据存储的一部分,因此将忽略输出树中节点的所有“config”语句。

If any node has a "when" statement that would evaluate to "false", then this node MUST NOT be present in the output tree.

如果任何节点的“when”语句的计算结果为“false”,则该节点不得出现在输出树中。

7.14.3.1. The output's Substatements
7.14.3.1. 输出的子语句
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | anydata      | 7.10    | 0..n        |
                 | anyxml       | 7.11    | 0..n        |
                 | choice       | 7.9     | 0..n        |
                 | container    | 7.5     | 0..n        |
                 | grouping     | 7.12    | 0..n        |
                 | leaf         | 7.6     | 0..n        |
                 | leaf-list    | 7.7     | 0..n        |
                 | list         | 7.8     | 0..n        |
                 | must         | 7.5.3   | 0..n        |
                 | typedef      | 7.3     | 0..n        |
                 | uses         | 7.13    | 0..n        |
                 +--------------+---------+-------------+
        
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | anydata      | 7.10    | 0..n        |
                 | anyxml       | 7.11    | 0..n        |
                 | choice       | 7.9     | 0..n        |
                 | container    | 7.5     | 0..n        |
                 | grouping     | 7.12    | 0..n        |
                 | leaf         | 7.6     | 0..n        |
                 | leaf-list    | 7.7     | 0..n        |
                 | list         | 7.8     | 0..n        |
                 | must         | 7.5.3   | 0..n        |
                 | typedef      | 7.3     | 0..n        |
                 | uses         | 7.13    | 0..n        |
                 +--------------+---------+-------------+
        
7.14.4. NETCONF XML Encoding Rules
7.14.4. NETCONF XML编码规则

An rpc node is encoded as a child XML element to the <rpc> element, as designated by the substitution group "rpcOperation" in [RFC6241]. The element's local name is the rpc's identifier, and its namespace is the module's XML namespace (see Section 7.1.3).

rpc节点被编码为<rpc>元素的子XML元素,由[RFC6241]中的替换组“rpcOperation”指定。元素的本地名称是rpc的标识符,其名称空间是模块的XML名称空间(参见第7.1.3节)。

Input parameters are encoded as child XML elements to the rpc node's XML element, in the same order as they are defined within the "input" statement.

输入参数被编码为rpc节点XML元素的子XML元素,其顺序与“Input”语句中定义的顺序相同。

If the RPC operation invocation succeeded and no output parameters are returned, the <rpc-reply> contains a single <ok/> element defined in [RFC6241]. If output parameters are returned, they are encoded as child elements to the <rpc-reply> element defined in [RFC6241], in the same order as they are defined within the "output" statement.

如果RPC操作调用成功且未返回任何输出参数,<RPC reply>包含[RFC6241]中定义的单个<ok/>元素。如果返回输出参数,则将其编码为[RFC6241]中定义的<rpc reply>元素的子元素,其顺序与“output”语句中定义的顺序相同。

7.14.5. Usage Example
7.14.5. 用法示例

The following example defines an RPC operation:

以下示例定义了RPC操作:

     module example-rock {
       yang-version 1.1;
       namespace "urn:example:rock";
       prefix "rock";
        
     module example-rock {
       yang-version 1.1;
       namespace "urn:example:rock";
       prefix "rock";
        
       rpc rock-the-house {
         input {
           leaf zip-code {
             type string;
           }
         }
       }
     }
        
       rpc rock-the-house {
         input {
           leaf zip-code {
             type string;
           }
         }
       }
     }
        

A corresponding XML instance example of the complete rpc and rpc-reply:

完整rpc和rpc应答的对应XML实例示例:

     <rpc message-id="101"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
       <rock-the-house xmlns="urn:example:rock">
         <zip-code>27606-0100</zip-code>
       </rock-the-house>
     </rpc>
        
     <rpc message-id="101"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
       <rock-the-house xmlns="urn:example:rock">
         <zip-code>27606-0100</zip-code>
       </rock-the-house>
     </rpc>
        
     <rpc-reply message-id="101"
                xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
       <ok/>
     </rpc-reply>
        
     <rpc-reply message-id="101"
                xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
       <ok/>
     </rpc-reply>
        
7.15. The "action" Statement
7.15. “行动”声明

The "action" statement is used to define an operation connected to a specific container or list data node. It takes one argument, which is an identifier, followed by a block of substatements that holds detailed action information. The argument is the name of the action.

“action”语句用于定义连接到特定容器或列表数据节点的操作。它有一个参数,它是一个标识符,后跟一个包含详细操作信息的子语句块。参数是操作的名称。

The "action" statement defines an action node in the schema tree. Under the action node, a schema node with the name "input" and a schema node with the name "output" are also defined. The nodes "input" and "output" are defined in the module's namespace.

“action”语句在模式树中定义了一个action节点。在action节点下,还定义了名为“input”的模式节点和名为“output”的模式节点。节点“输入”和“输出”在模块的命名空间中定义。

An action MUST NOT be defined within an rpc, another action, or a notification, i.e., an action node MUST NOT have an rpc, action, or a notification node as one of its ancestors in the schema tree. For example, this means that it is an error if a grouping that contains an action somewhere in its node hierarchy is used in a notification definition.

不得在rpc、其他操作或通知中定义操作,即操作节点不得将rpc、操作或通知节点作为其在架构树中的祖先之一。例如,这意味着如果在通知定义中使用了在其节点层次结构中某处包含操作的分组,则这是一个错误。

An action MUST NOT have any ancestor node that is a list node without a "key" statement.

操作不能有任何祖先节点是没有“key”语句的列表节点。

Since an action cannot be defined at the top level of a module or in a "case" statement, it is an error if a grouping that contains an action at the top of its node hierarchy is used at the top level of a module or in a case definition.

由于无法在模块的顶层或“case”语句中定义操作,因此,如果在模块的顶层或案例定义中使用在其节点层次结构顶部包含操作的分组,则为错误。

The difference between an action and an rpc is that an action is tied to a node in the datastore, whereas an rpc is not. When an action is invoked, the node in the datastore is specified along with the name of the action and the input parameters.

动作和rpc之间的区别在于动作绑定到数据存储中的节点,而rpc不绑定。调用操作时,将指定数据存储中的节点以及操作的名称和输入参数。

7.15.1. The action's Substatements
7.15.1. 动作的子状态
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | description  | 7.21.3  | 0..1        |
                 | grouping     | 7.12    | 0..n        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | input        | 7.14.2  | 0..1        |
                 | output       | 7.14.3  | 0..1        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | typedef      | 7.3     | 0..n        |
                 +--------------+---------+-------------+
        
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | description  | 7.21.3  | 0..1        |
                 | grouping     | 7.12    | 0..n        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | input        | 7.14.2  | 0..1        |
                 | output       | 7.14.3  | 0..1        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | typedef      | 7.3     | 0..n        |
                 +--------------+---------+-------------+
        
7.15.2. NETCONF XML Encoding Rules
7.15.2. NETCONF XML编码规则

When an action is invoked, an element with the local name "action" in the namespace "urn:ietf:params:xml:ns:yang:1" (see Section 5.3.1) is encoded as a child XML element to the <rpc> element defined in [RFC6241], as designated by the substitution group "rpcOperation" in [RFC6241].

调用操作时,命名空间“urn:ietf:params:xml:ns:yang:1”(参见第5.3.1节)中本地名为“action”的元素将被编码为[RFC6241]中定义的<rpc>元素的子xml元素,由[RFC6241]中的替换组“rpcOperation”指定。

The <action> element contains a hierarchy of nodes that identifies the node in the datastore. It MUST contain all containers and list nodes in the direct path from the top level down to the list or container containing the action. For lists, all key leafs MUST also be included. The innermost container or list contains an XML element that carries the name of the defined action. Within this element, the input parameters are encoded as child XML elements, in the same order as they are defined within the "input" statement.

<action>元素包含一个节点层次结构,用于标识数据存储中的节点。它必须包含从顶层到包含操作的列表或容器的直接路径中的所有容器和列表节点。对于列表,还必须包括所有键叶。最里面的容器或列表包含一个XML元素,该元素携带已定义操作的名称。在这个元素中,输入参数被编码为子XML元素,其顺序与“input”语句中定义的顺序相同。

Only one action can be invoked in one <rpc>. If more than one action is present in the <rpc>, the server MUST reply with a "bad-element" <error-tag> in the <rpc-error>.

在一个<rpc>中只能调用一个操作。如果<rpc>中存在多个操作,服务器必须在<rpc error>中使用“bad element”<error tag>进行响应。

If the action operation invocation succeeded and no output parameters are returned, the <rpc-reply> contains a single <ok/> element defined in [RFC6241]. If output parameters are returned, they are encoded as child elements to the <rpc-reply> element defined in [RFC6241], in the same order as they are defined within the "output" statement.

如果操作调用成功且未返回任何输出参数,<rpc reply>包含[RFC6241]中定义的单个<ok/>元素。如果返回输出参数,则将其编码为[RFC6241]中定义的<rpc reply>元素的子元素,其顺序与“output”语句中定义的顺序相同。

7.15.3. Usage Example
7.15.3. 用法示例

The following example defines an action to reset one server at a server farm:

以下示例定义了在服务器场重置一台服务器的操作:

     module example-server-farm {
       yang-version 1.1;
       namespace "urn:example:server-farm";
       prefix "sfarm";
        
     module example-server-farm {
       yang-version 1.1;
       namespace "urn:example:server-farm";
       prefix "sfarm";
        
       import ietf-yang-types {
         prefix "yang";
       }
        
       import ietf-yang-types {
         prefix "yang";
       }
        
       list server {
         key name;
         leaf name {
           type string;
         }
         action reset {
           input {
             leaf reset-at {
               type yang:date-and-time;
               mandatory true;
              }
            }
            output {
              leaf reset-finished-at {
                type yang:date-and-time;
                mandatory true;
              }
            }
          }
        }
      }
        
       list server {
         key name;
         leaf name {
           type string;
         }
         action reset {
           input {
             leaf reset-at {
               type yang:date-and-time;
               mandatory true;
              }
            }
            output {
              leaf reset-finished-at {
                type yang:date-and-time;
                mandatory true;
              }
            }
          }
        }
      }
        

A corresponding XML instance example of the complete rpc and rpc-reply:

完整rpc和rpc应答的对应XML实例示例:

     <rpc message-id="101"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
       <action xmlns="urn:ietf:params:xml:ns:yang:1">
         <server xmlns="urn:example:server-farm">
           <name>apache-1</name>
           <reset>
             <reset-at>2014-07-29T13:42:00Z</reset-at>
           </reset>
         </server>
       </action>
     </rpc>
        
     <rpc message-id="101"
          xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
       <action xmlns="urn:ietf:params:xml:ns:yang:1">
         <server xmlns="urn:example:server-farm">
           <name>apache-1</name>
           <reset>
             <reset-at>2014-07-29T13:42:00Z</reset-at>
           </reset>
         </server>
       </action>
     </rpc>
        
     <rpc-reply message-id="101"
                xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
       <reset-finished-at xmlns="urn:example:server-farm">
         2014-07-29T13:42:12Z
       </reset-finished-at>
     </rpc-reply>
        
     <rpc-reply message-id="101"
                xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
       <reset-finished-at xmlns="urn:example:server-farm">
         2014-07-29T13:42:12Z
       </reset-finished-at>
     </rpc-reply>
        
7.16. The "notification" Statement
7.16. “通知”声明

The "notification" statement is used to define a notification. It takes one argument, which is an identifier, followed by a block of substatements that holds detailed notification information. The "notification" statement defines a notification node in the schema tree.

“通知”语句用于定义通知。它有一个参数,它是一个标识符,后跟一个包含详细通知信息的子语句块。“notification”语句在模式树中定义了一个通知节点。

A notification can be defined at the top level of a module, or connected to a specific container or list data node in the schema tree.

通知可以在模块的顶层定义,也可以连接到模式树中的特定容器或列表数据节点。

A notification MUST NOT be defined within an rpc, action, or another notification, i.e., a notification node MUST NOT have an rpc, action, or a notification node as one of its ancestors in the schema tree. For example, this means that it is an error if a grouping that contains a notification somewhere in its node hierarchy is used in an rpc definition.

通知不得在rpc、操作或其他通知中定义,即通知节点不得将rpc、操作或通知节点作为其在架构树中的祖先之一。例如,这意味着,如果在rpc定义中使用了在其节点层次结构中某处包含通知的分组,则这是一个错误。

A notification MUST NOT have any ancestor node that is a list node without a "key" statement.

通知不能有任何祖先节点是没有“key”语句的列表节点。

Since a notification cannot be defined in a "case" statement, it is an error if a grouping that contains a notification at the top of its node hierarchy is used in a case definition.

由于无法在“case”语句中定义通知,因此,如果在案例定义中使用在其节点层次结构顶部包含通知的分组,则为错误。

If a leaf in the notification tree has a "mandatory" statement with the value "true", the leaf MUST be present in a notification instance.

如果通知树中的某个叶具有值为“true”的“强制”语句,则该叶必须存在于通知实例中。

If a leaf in the notification tree has a default value, the client MUST use this value in the same cases as those described in Section 7.6.1. In these cases, the client MUST operationally behave as if the leaf was present in the notification instance with the default value as its value.

如果通知树中的某个叶具有默认值,则客户端必须在与第7.6.1节所述相同的情况下使用该值。在这些情况下,客户机必须在操作上表现得像通知实例中的叶一样,并以默认值作为其值。

If a leaf-list in the notification tree has one or more default values, the client MUST use these values in the same cases as those described in Section 7.7.2. In these cases, the client MUST operationally behave as if the leaf-list was present in the notification instance with the default values as its values.

如果通知树中的叶列表具有一个或多个默认值,则客户端必须在与第7.7.2节所述相同的情况下使用这些值。在这些情况下,客户机必须在操作上表现为通知实例中存在叶列表,并使用默认值作为其值。

Since the notification tree is not part of any datastore, all "config" statements for nodes in the notification tree are ignored.

由于通知树不是任何数据存储的一部分,因此将忽略通知树中节点的所有“config”语句。

7.16.1. The notification's Substatements
7.16.1. 通知的子语句
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | anydata      | 7.10    | 0..n        |
                 | anyxml       | 7.11    | 0..n        |
                 | choice       | 7.9     | 0..n        |
                 | container    | 7.5     | 0..n        |
                 | description  | 7.21.3  | 0..1        |
                 | grouping     | 7.12    | 0..n        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | leaf         | 7.6     | 0..n        |
                 | leaf-list    | 7.7     | 0..n        |
                 | list         | 7.8     | 0..n        |
                 | must         | 7.5.3   | 0..n        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | typedef      | 7.3     | 0..n        |
                 | uses         | 7.13    | 0..n        |
                 +--------------+---------+-------------+
        
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | anydata      | 7.10    | 0..n        |
                 | anyxml       | 7.11    | 0..n        |
                 | choice       | 7.9     | 0..n        |
                 | container    | 7.5     | 0..n        |
                 | description  | 7.21.3  | 0..1        |
                 | grouping     | 7.12    | 0..n        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | leaf         | 7.6     | 0..n        |
                 | leaf-list    | 7.7     | 0..n        |
                 | list         | 7.8     | 0..n        |
                 | must         | 7.5.3   | 0..n        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | typedef      | 7.3     | 0..n        |
                 | uses         | 7.13    | 0..n        |
                 +--------------+---------+-------------+
        
7.16.2. NETCONF XML Encoding Rules
7.16.2. NETCONF XML编码规则

A notification node that is defined on the top level of a module is encoded as a child XML element to the <notification> element defined in "NETCONF Event Notifications" [RFC5277]. The element's local name is the notification's identifier, and its namespace is the module's XML namespace (see Section 7.1.3).

在模块顶层定义的通知节点被编码为“NETCONF事件通知”[RFC5277]中定义的<notification>元素的子XML元素。元素的本地名称是通知的标识符,其名称空间是模块的XML名称空间(参见第7.1.3节)。

When a notification node is defined as a child to a data node, the <notification> element defined in [RFC5277] contains a hierarchy of nodes that identifies the node in the datastore. It MUST contain all containers and list nodes from the top level down to the list or container containing the notification. For lists, all key leafs MUST also be included. The innermost container or list contains an XML element that carries the name of the defined notification.

当将通知节点定义为数据节点的子节点时,[RFC5277]中定义的<notification>元素包含一个节点层次结构,用于标识数据存储中的节点。它必须包含从顶层到包含通知的列表或容器的所有容器和列表节点。对于列表,还必须包括所有键叶。最里面的容器或列表包含一个XML元素,该元素携带已定义通知的名称。

The notification's child nodes are encoded as subelements to the notification node's XML element, in any order.

通知的子节点按任意顺序编码为通知节点XML元素的子元素。

7.16.3. Usage Example
7.16.3. 用法示例

The following example defines a notification at the top level of a module:

以下示例定义了模块顶层的通知:

     module example-event {
       yang-version 1.1;
       namespace "urn:example:event";
       prefix "ev";
        
     module example-event {
       yang-version 1.1;
       namespace "urn:example:event";
       prefix "ev";
        
       notification event {
         leaf event-class {
           type string;
         }
         leaf reporting-entity {
           type instance-identifier;
         }
         leaf severity {
           type string;
         }
       }
     }
        
       notification event {
         leaf event-class {
           type string;
         }
         leaf reporting-entity {
           type instance-identifier;
         }
         leaf severity {
           type string;
         }
       }
     }
        

A corresponding XML instance example of the complete notification:

完整通知的对应XML实例示例:

     <notification
       xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
       <eventTime>2008-07-08T00:01:00Z</eventTime>
       <event xmlns="urn:example:event">
         <event-class>fault</event-class>
         <reporting-entity>
           /ex:interface[ex:name='Ethernet0']
         </reporting-entity>
         <severity>major</severity>
       </event>
     </notification>
        
     <notification
       xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
       <eventTime>2008-07-08T00:01:00Z</eventTime>
       <event xmlns="urn:example:event">
         <event-class>fault</event-class>
         <reporting-entity>
           /ex:interface[ex:name='Ethernet0']
         </reporting-entity>
         <severity>major</severity>
       </event>
     </notification>
        

The following example defines a notification in a data node:

以下示例定义了数据节点中的通知:

     module example-interface-module {
       yang-version 1.1;
       namespace "urn:example:interface-module";
       prefix "if";
        
     module example-interface-module {
       yang-version 1.1;
       namespace "urn:example:interface-module";
       prefix "if";
        
       container interfaces {
         list interface {
           key "name";
           leaf name {
             type string;
           }
           notification interface-enabled {
             leaf by-user {
               type string;
             }
           }
         }
       }
     }
        
       container interfaces {
         list interface {
           key "name";
           leaf name {
             type string;
           }
           notification interface-enabled {
             leaf by-user {
               type string;
             }
           }
         }
       }
     }
        

A corresponding XML instance example of the complete notification:

完整通知的对应XML实例示例:

     <notification
       xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
       <eventTime>2008-07-08T00:01:00Z</eventTime>
       <interfaces xmlns="urn:example:interface-module">
         <interface>
           <name>eth1</name>
           <interface-enabled>
             <by-user>fred</by-user>
           </interface-enabled>
         </interface>
       </interfaces>
     </notification>
        
     <notification
       xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
       <eventTime>2008-07-08T00:01:00Z</eventTime>
       <interfaces xmlns="urn:example:interface-module">
         <interface>
           <name>eth1</name>
           <interface-enabled>
             <by-user>fred</by-user>
           </interface-enabled>
         </interface>
       </interfaces>
     </notification>
        
7.17. The "augment" Statement
7.17. “增强”语句

The "augment" statement allows a module or submodule to add to a schema tree defined in an external module, or in the current module and its submodules, and to add to the nodes from a grouping in a "uses" statement. The argument is a string that identifies a node in the schema tree. This node is called the augment's target node. The target node MUST be either a container, list, choice, case, input, output, or notification node. It is augmented with the nodes defined in the substatements that follow the "augment" statement.

“augment”语句允许模块或子模块添加到外部模块或当前模块及其子模块中定义的模式树,并从“uses”语句中的分组添加到节点。参数是标识架构树中节点的字符串。此节点称为增强的目标节点。目标节点必须是容器、列表、选项、大小写、输入、输出或通知节点。它通过“augment”语句后面的子语句中定义的节点进行扩充。

The argument string is a schema node identifier (see Section 6.5). If the "augment" statement is on the top level in a module or submodule, the absolute form (defined by the rule "absolute-schema-nodeid" in Section 14) of a schema node identifier MUST be used. If the "augment" statement is a substatement to the "uses" statement, the descendant form (defined by the rule "descendant-schema-nodeid" in Section 14) MUST be used.

参数字符串是一个模式节点标识符(参见第6.5节)。如果“augment”语句位于模块或子模块的顶层,则必须使用模式节点标识符的绝对形式(由第14节中的“绝对模式节点标识”规则定义)。如果“augment”语句是“uses”语句的子语句,则必须使用子体形式(由第14节中的规则“后代模式nodeid”定义)。

If the target node is a container, list, case, input, output, or notification node, the "container", "leaf", "list", "leaf-list", "uses", and "choice" statements can be used within the "augment" statement.

如果目标节点是容器、列表、案例、输入、输出或通知节点,“容器”、“叶”、“列表”、“叶列表”、“使用”和“选择”语句可以在“增强”语句中使用。

If the target node is a container or list node, the "action" and "notification" statements can be used within the "augment" statement.

如果目标节点是容器或列表节点,“action”和“notification”语句可以在“augment”语句中使用。

If the target node is a choice node, the "case" statement or a shorthand "case" statement (see Section 7.9.2) can be used within the "augment" statement.

如果目标节点是选择节点,“case”语句或简写的“case”语句(见第7.9.2节)可在“AUMMENT”语句中使用。

The "augment" statement MUST NOT add multiple nodes with the same name from the same module to the target node.

“augment”语句不能将同一模块中具有相同名称的多个节点添加到目标节点。

If the augmentation adds mandatory nodes (see Section 3) that represent configuration to a target node in another module, the augmentation MUST be made conditional with a "when" statement. Care must be taken when defining the "when" expression so that clients that do not know about the augmenting module do not break.

如果扩充向另一个模块中的目标节点添加表示配置的强制节点(参见第3节),则必须使用“when”语句对扩充进行条件化。定义“when”表达式时必须小心,以便不知道扩充模块的客户端不会中断。

In the following example, it is OK to augment the "interface" entry with "mandatory-leaf" because the augmentation depends on support for "some-new-iftype". The old client does not know about this type, so it would never select this type and would therefore not be adding a mandatory data node.

在下面的示例中,可以使用“mandatory leaf”来扩充“interface”条目,因为扩充依赖于对“somenewiftype”的支持。旧客户端不知道此类型,因此它永远不会选择此类型,因此不会添加强制数据节点。

     module example-augment {
       yang-version 1.1;
       namespace "urn:example:augment";
       prefix mymod;
        
     module example-augment {
       yang-version 1.1;
       namespace "urn:example:augment";
       prefix mymod;
        
       import ietf-interfaces {
         prefix if;
       }
        
       import ietf-interfaces {
         prefix if;
       }
        
       identity some-new-iftype {
          base if:interface-type;
       }
        
       identity some-new-iftype {
          base if:interface-type;
       }
        
       augment "/if:interfaces/if:interface" {
          when 'derived-from-or-self(if:type, "mymod:some-new-iftype")';
        
       augment "/if:interfaces/if:interface" {
          when 'derived-from-or-self(if:type, "mymod:some-new-iftype")';
        
          leaf mandatory-leaf {
             mandatory true;
             type string;
          }
       }
     }
        
          leaf mandatory-leaf {
             mandatory true;
             type string;
          }
       }
     }
        
7.17.1. The augment's Substatements
7.17.1. 增广子状态
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | action       | 7.15    | 0..n        |
                 | anydata      | 7.10    | 0..n        |
                 | anyxml       | 7.11    | 0..n        |
                 | case         | 7.9.2   | 0..n        |
                 | choice       | 7.9     | 0..n        |
                 | container    | 7.5     | 0..n        |
                 | description  | 7.21.3  | 0..1        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | leaf         | 7.6     | 0..n        |
                 | leaf-list    | 7.7     | 0..n        |
                 | list         | 7.8     | 0..n        |
                 | notification | 7.16    | 0..n        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | uses         | 7.13    | 0..n        |
                 | when         | 7.21.5  | 0..1        |
                 +--------------+---------+-------------+
        
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | action       | 7.15    | 0..n        |
                 | anydata      | 7.10    | 0..n        |
                 | anyxml       | 7.11    | 0..n        |
                 | case         | 7.9.2   | 0..n        |
                 | choice       | 7.9     | 0..n        |
                 | container    | 7.5     | 0..n        |
                 | description  | 7.21.3  | 0..1        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | leaf         | 7.6     | 0..n        |
                 | leaf-list    | 7.7     | 0..n        |
                 | list         | 7.8     | 0..n        |
                 | notification | 7.16    | 0..n        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | uses         | 7.13    | 0..n        |
                 | when         | 7.21.5  | 0..1        |
                 +--------------+---------+-------------+
        
7.17.2. XML Encoding Rules
7.17.2. XML编码规则

All data nodes defined in the "augment" statement are defined as XML elements in the XML namespace of the module where the "augment" is specified.

“augment”语句中定义的所有数据节点都在指定“augment”的模块的XML命名空间中定义为XML元素。

When a node is augmented, the augmenting child nodes are encoded as subelements to the augmented node, in any order.

当一个节点被扩充时,扩充的子节点以任何顺序被编码为扩充节点的子元素。

7.17.3. Usage Example
7.17.3. 用法示例

In namespace urn:example:interface-module, we have:

在名称空间urn:example:interface module中,我们有:

     container interfaces {
       list ifEntry {
         key "ifIndex";
        
     container interfaces {
       list ifEntry {
         key "ifIndex";
        
         leaf ifIndex {
           type uint32;
         }
         leaf ifDescr {
           type string;
         }
         leaf ifType {
           type iana:IfType;
         }
         leaf ifMtu {
           type int32;
         }
       }
     }
        
         leaf ifIndex {
           type uint32;
         }
         leaf ifDescr {
           type string;
         }
         leaf ifType {
           type iana:IfType;
         }
         leaf ifMtu {
           type int32;
         }
       }
     }
        

Then, in namespace urn:example:ds0, we have:

然后,在名称空间urn:example:ds0中,我们有:

     import example-interface-module {
       prefix "if";
     }
     augment "/if:interfaces/if:ifEntry" {
       when "if:ifType='ds0'";
       leaf ds0ChannelNumber {
         type ChannelNumber;
       }
     }
        
     import example-interface-module {
       prefix "if";
     }
     augment "/if:interfaces/if:ifEntry" {
       when "if:ifType='ds0'";
       leaf ds0ChannelNumber {
         type ChannelNumber;
       }
     }
        

A corresponding XML instance example:

对应的XML实例示例:

     <interfaces xmlns="urn:example:interface-module"
                 xmlns:ds0="urn:example:ds0">
       <ifEntry>
         <ifIndex>1</ifIndex>
         <ifDescr>Flintstone Inc Ethernet A562</ifDescr>
         <ifType>ethernetCsmacd</ifType>
         <ifMtu>1500</ifMtu>
       </ifEntry>
       <ifEntry>
         <ifIndex>2</ifIndex>
         <ifDescr>Flintstone Inc DS0</ifDescr>
         <ifType>ds0</ifType>
         <ds0:ds0ChannelNumber>1</ds0:ds0ChannelNumber>
       </ifEntry>
     </interfaces>
        
     <interfaces xmlns="urn:example:interface-module"
                 xmlns:ds0="urn:example:ds0">
       <ifEntry>
         <ifIndex>1</ifIndex>
         <ifDescr>Flintstone Inc Ethernet A562</ifDescr>
         <ifType>ethernetCsmacd</ifType>
         <ifMtu>1500</ifMtu>
       </ifEntry>
       <ifEntry>
         <ifIndex>2</ifIndex>
         <ifDescr>Flintstone Inc DS0</ifDescr>
         <ifType>ds0</ifType>
         <ds0:ds0ChannelNumber>1</ds0:ds0ChannelNumber>
       </ifEntry>
     </interfaces>
        

As another example, suppose we have the choice defined in Section 7.9.6. The following construct can be used to extend the protocol definition:

作为另一个例子,假设我们有第7.9.6节中定义的选择。以下构造可用于扩展协议定义:

     augment /ex:system/ex:protocol/ex:name {
       case c {
         leaf smtp {
           type empty;
         }
       }
     }
        
     augment /ex:system/ex:protocol/ex:name {
       case c {
         leaf smtp {
           type empty;
         }
       }
     }
        

A corresponding XML instance example:

对应的XML实例示例:

     <ex:system>
       <ex:protocol>
         <ex:tcp/>
       </ex:protocol>
     </ex:system>
        
     <ex:system>
       <ex:protocol>
         <ex:tcp/>
       </ex:protocol>
     </ex:system>
        

or

     <ex:system>
       <ex:protocol>
         <other:smtp/>
       </ex:protocol>
     </ex:system>
        
     <ex:system>
       <ex:protocol>
         <other:smtp/>
       </ex:protocol>
     </ex:system>
        
7.18. The "identity" Statement
7.18. “身份”声明

The "identity" statement is used to define a new globally unique, abstract, and untyped identity. The identity's only purpose is to denote its name, semantics, and existence. An identity can be either defined from scratch or derived from one or more base identities. The identity's argument is an identifier that is the name of the identity. It is followed by a block of substatements that holds detailed identity information.

“identity”语句用于定义新的全局唯一、抽象和非类型化标识。身份的唯一目的是表示其名称、语义和存在。标识可以从头定义,也可以从一个或多个基本标识派生。标识的参数是标识名的标识符。它后面是一个包含详细身份信息的子状态块。

The built-in datatype "identityref" (see Section 9.10) can be used to reference identities within a data model.

内置数据类型“identityref”(见第9.10节)可用于引用数据模型中的标识。

7.18.1. The identity's Substatements
7.18.1. 身份的子状态
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | base         | 7.18.2  | 0..n        |
                 | description  | 7.21.3  | 0..1        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 +--------------+---------+-------------+
        
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | base         | 7.18.2  | 0..n        |
                 | description  | 7.21.3  | 0..1        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 +--------------+---------+-------------+
        
7.18.2. The "base" Statement
7.18.2. “基本”陈述

The "base" statement, which is optional, takes as an argument a string that is the name of an existing identity, from which the new identity is derived. If no "base" statement is present, the identity is defined from scratch. If multiple "base" statements are present, the identity is derived from all of them.

“base”语句是可选的,它将一个字符串作为参数,该字符串是从中派生新标识的现有标识的名称。如果不存在“base”语句,则从零开始定义标识。如果存在多个“基本”语句,则标识将从所有这些语句派生。

If a prefix is present on the base name, it refers to an identity defined in the module that was imported with that prefix, or the local module if the prefix matches the local module's prefix. Otherwise, an identity with the matching name MUST be defined in the current module or an included submodule.

如果基名称上存在前缀,则它将引用在使用该前缀导入的模块中定义的标识,如果前缀与本地模块的前缀匹配,则它将引用本地模块中定义的标识。否则,必须在当前模块或包含的子模块中定义具有匹配名称的标识。

An identity MUST NOT reference itself, neither directly nor indirectly through a chain of other identities.

身份不能直接或间接地通过一系列其他身份来引用自身。

The derivation of identities has the following properties:

标识的派生具有以下属性:

o It is irreflexive, which means that an identity is not derived from itself.

o 它是不可伸缩的,这意味着一个身份不是从它自身派生出来的。

o It is transitive, which means that if identity B is derived from A and C is derived from B, then C is also derived from A.

o 它是可传递的,也就是说,如果恒等式B是从A派生的,而C是从B派生的,那么C也是从A派生的。

7.18.3. Usage Example
7.18.3. 用法示例
     module example-crypto-base {
       yang-version 1.1;
       namespace "urn:example:crypto-base";
       prefix "crypto";
        
     module example-crypto-base {
       yang-version 1.1;
       namespace "urn:example:crypto-base";
       prefix "crypto";
        
       identity crypto-alg {
         description
           "Base identity from which all crypto algorithms
            are derived.";
       }
        
       identity crypto-alg {
         description
           "Base identity from which all crypto algorithms
            are derived.";
       }
        
       identity symmetric-key {
         description
           "Base identity used to identify symmetric-key crypto
            algorithms.";
         }
        
       identity symmetric-key {
         description
           "Base identity used to identify symmetric-key crypto
            algorithms.";
         }
        
       identity public-key {
         description
           "Base identity used to identify public-key crypto
            algorithms.";
         }
     }
        
       identity public-key {
         description
           "Base identity used to identify public-key crypto
            algorithms.";
         }
     }
        
     module example-des {
       yang-version 1.1;
       namespace "urn:example:des";
       prefix "des";
        
     module example-des {
       yang-version 1.1;
       namespace "urn:example:des";
       prefix "des";
        
       import "example-crypto-base" {
         prefix "crypto";
       }
        
       import "example-crypto-base" {
         prefix "crypto";
       }
        
       identity des {
         base "crypto:crypto-alg";
         base "crypto:symmetric-key";
         description "DES crypto algorithm.";
       }
        
       identity des {
         base "crypto:crypto-alg";
         base "crypto:symmetric-key";
         description "DES crypto algorithm.";
       }
        
       identity des3 {
         base "crypto:crypto-alg";
         base "crypto:symmetric-key";
         description "Triple DES crypto algorithm.";
       }
     }
        
       identity des3 {
         base "crypto:crypto-alg";
         base "crypto:symmetric-key";
         description "Triple DES crypto algorithm.";
       }
     }
        
7.19. The "extension" Statement
7.19. “扩展”声明

The "extension" statement allows the definition of new statements within the YANG language. This new statement definition can be imported and used by other modules.

“extension”语句允许在YANG语言中定义新语句。这个新的语句定义可以被其他模块导入和使用。

The "extension" statement's argument is an identifier that is the new keyword for the extension and must be followed by a block of substatements that holds detailed extension information. The purpose of the "extension" statement is to define a keyword so that it can be imported and used by other modules.

“extension”语句的参数是一个标识符,它是扩展的新关键字,后面必须跟一个包含详细扩展信息的子语句块。“extension”语句的目的是定义关键字,以便其他模块可以导入和使用它。

The extension can be used like a normal YANG statement, with the statement name followed by an argument if one is defined by the "extension" statement, and an optional block of substatements. The statement's name is created by combining the prefix of the module in which the extension was defined, a colon (":"), and the extension's keyword, with no interleaving whitespace. The substatements of an extension are defined by the "extension" statement, using some mechanism outside the scope of this specification. Syntactically, the substatements MUST be YANG statements, including extensions defined using "extension" statements. YANG statements in extensions MUST follow the syntactical rules in Section 14.

扩展可以像普通的YANG语句一样使用,如果由“extension”语句定义,则语句名后面跟着一个参数,以及一个可选的子语句块。该语句的名称是通过组合定义扩展的模块的前缀、冒号(“:”)和扩展的关键字创建的,没有交叉空格。扩展的子语句由“extension”语句定义,使用本规范范围之外的某种机制。在语法上,子语句必须是YANG语句,包括使用“extension”语句定义的扩展。扩展中的YANG语句必须遵循第14节中的语法规则。

An extension can allow refinement (see Section 7.13.2) and deviations (Section 7.20.3.2), but the mechanism for how this is defined is outside the scope of this specification.

扩展可允许细化(见第7.13.2节)和偏差(第7.20.3.2节),但其定义机制不在本规范范围内。

7.19.1. The extension's Substatements
7.19.1. 扩展的子状态
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | argument     | 7.19.2  | 0..1        |
                 | description  | 7.21.3  | 0..1        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 +--------------+---------+-------------+
        
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | argument     | 7.19.2  | 0..1        |
                 | description  | 7.21.3  | 0..1        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 +--------------+---------+-------------+
        
7.19.2. The "argument" Statement
7.19.2. “论点”陈述

The "argument" statement, which is optional, takes as an argument a string that is the name of the argument to the keyword. If no "argument" statement is present, the keyword expects no argument when it is used.

“argument”语句是可选的,它将作为关键字参数名称的字符串作为参数。如果不存在“argument”语句,则使用关键字时不需要参数。

The argument's name is used in the YIN mapping, where it is used as an XML attribute or element name, depending on the argument's "yin-element" statement.

参数的名称在YIN映射中使用,根据参数的“YIN-element”语句,它被用作XML属性或元素名称。

7.19.2.1. The argument's Substatement
7.19.2.1. 论点的替代物
                 +--------------+----------+-------------+
                 | substatement | section  | cardinality |
                 +--------------+----------+-------------+
                 | yin-element  | 7.19.2.2 | 0..1        |
                 +--------------+----------+-------------+
        
                 +--------------+----------+-------------+
                 | substatement | section  | cardinality |
                 +--------------+----------+-------------+
                 | yin-element  | 7.19.2.2 | 0..1        |
                 +--------------+----------+-------------+
        
7.19.2.2. The "yin-element" Statement
7.19.2.2. “阴素”说

The "yin-element" statement, which is optional, takes as an argument the string "true" or "false". This statement indicates whether the argument is mapped to an XML element in YIN or to an XML attribute (see Section 13).

“yin元素”语句是可选的,它将字符串“true”或“false”作为参数。此语句指示参数是映射到YIN中的XML元素还是映射到XML属性(请参见第13节)。

If no "yin-element" statement is present, it defaults to "false".

如果不存在“阴元素”语句,则默认为“false”。

7.19.3. Usage Example
7.19.3. 用法示例

To define an extension:

要定义扩展,请执行以下操作:

     module example-extensions {
       yang-version 1.1;
       ...
        
     module example-extensions {
       yang-version 1.1;
       ...
        
       extension c-define {
         description
           "Takes as an argument a name string.
            Makes the code generator use the given name
            in the #define.";
         argument "name";
       }
     }
        
       extension c-define {
         description
           "Takes as an argument a name string.
            Makes the code generator use the given name
            in the #define.";
         argument "name";
       }
     }
        

To use the extension:

要使用扩展名,请执行以下操作:

     module example-interfaces {
       yang-version 1.1;
        
     module example-interfaces {
       yang-version 1.1;
        
       ...
       import example-extensions {
         prefix "myext";
       }
       ...
        
       ...
       import example-extensions {
         prefix "myext";
       }
       ...
        
       container interfaces {
         ...
         myext:c-define "MY_INTERFACES";
       }
     }
        
       container interfaces {
         ...
         myext:c-define "MY_INTERFACES";
       }
     }
        
7.20. Conformance-Related Statements
7.20. 一致性相关声明

This section defines statements related to conformance, as described in Section 5.6.

本节定义了与合规性相关的声明,如第5.6节所述。

7.20.1. The "feature" Statement
7.20.1. “特色”声明

The "feature" statement is used to define a mechanism by which portions of the schema are marked as conditional. A feature name is defined that can later be referenced using the "if-feature" statement (see Section 7.20.2). Schema nodes tagged with an "if-feature" statement are ignored by the server unless the server supports the given feature expression. This allows portions of the YANG module to be conditional based on conditions in the server. The model can represent the abilities of the server within the model, giving a richer model that allows for differing server abilities and roles.

“feature”语句用于定义一种机制,通过该机制将模式的某些部分标记为条件。定义了一个特征名称,该名称可在以后使用“如果特征”语句引用(见第7.20.2节)。除非服务器支持给定的功能表达式,否则使用“if-feature”语句标记的模式节点将被服务器忽略。这允许模块的某些部分根据服务器中的条件设置条件。该模型可以表示模型中服务器的能力,提供了一个更丰富的模型,允许不同的服务器能力和角色。

The argument to the "feature" statement is the name of the new feature and follows the rules for identifiers in Section 6.2. This name is used by the "if-feature" statement to tie the schema nodes to the feature.

“feature”语句的参数是新特性的名称,并遵循第6.2节中的标识符规则。“if-feature”语句使用此名称将架构节点绑定到该功能。

In this example, a feature called "local-storage" represents the ability for a server to store syslog messages on local storage of some sort. This feature is used to make the "local-storage-limit" leaf conditional on the presence of some sort of local storage. If the server does not report that it supports this feature, the "local-storage-limit" node is not supported.

在本例中,名为“本地存储”的功能表示服务器能够在某种本地存储上存储系统日志消息。此功能用于使“本地存储限制”叶以存在某种本地存储为条件。如果服务器未报告它支持此功能,则不支持“本地存储限制”节点。

     module example-syslog {
       yang-version 1.1;
        
     module example-syslog {
       yang-version 1.1;
        
       ...
       feature local-storage {
         description
           "This feature means that the server supports local
            storage (memory, flash, or disk) that can be used to
            store syslog messages.";
       }
        
       ...
       feature local-storage {
         description
           "This feature means that the server supports local
            storage (memory, flash, or disk) that can be used to
            store syslog messages.";
       }
        
       container syslog {
         leaf local-storage-limit {
           if-feature local-storage;
           type uint64;
           units "kilobyte";
           config false;
           description
             "The amount of local storage that can be
              used to hold syslog messages.";
         }
       }
     }
        
       container syslog {
         leaf local-storage-limit {
           if-feature local-storage;
           type uint64;
           units "kilobyte";
           config false;
           description
             "The amount of local storage that can be
              used to hold syslog messages.";
         }
       }
     }
        

The "if-feature" statement can be used in many places within the YANG syntax. Definitions tagged with "if-feature" are ignored when the server does not support that feature.

“if-feature”语句可以在YANG语法中的许多地方使用。当服务器不支持该功能时,将忽略标记为“if feature”的定义。

A feature MUST NOT reference itself, neither directly nor indirectly through a chain of other features.

特征不得直接或间接通过一系列其他特征引用自身。

In order for a server to support a feature that is dependent on any other features (i.e., the feature has one or more "if-feature" substatements), the server MUST also support all the dependent features.

为了使服务器支持依赖于任何其他功能的功能(即,该功能具有一个或多个“如果功能”子状态),服务器还必须支持所有依赖功能。

7.20.1.1. The feature's Substatements
7.20.1.1. 要素的子状态
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | description  | 7.21.3  | 0..1        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 +--------------+---------+-------------+
        
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | description  | 7.21.3  | 0..1        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 +--------------+---------+-------------+
        
7.20.2. The "if-feature" Statement
7.20.2. “if feature”语句

The "if-feature" statement makes its parent statement conditional. The argument is a boolean expression over feature names. In this expression, a feature name evaluates to "true" if and only if the feature is supported by the server. The parent statement is implemented by servers where the boolean expression evaluates to "true".

“if feature”语句使其父语句具有条件。参数是要素名称上的布尔表达式。在此表达式中,当且仅当服务器支持功能时,功能名称的计算结果为“true”。父语句由布尔表达式计算结果为“true”的服务器实现。

The if-feature boolean expression syntax is formally defined by the rule "if-feature-expr" in Section 14. Parentheses are used to group expressions. When the expression is evaluated, the order of precedence is (highest precedence first): grouping (parentheses), "not", "and", "or".

if功能布尔表达式语法由第14节中的“if功能表达式”规则正式定义。括号用于对表达式进行分组。计算表达式时,优先级顺序为(最高优先级优先):分组(括号)、“非”、“或”。

If a prefix is present on a feature name in the boolean expression, the prefixed name refers to a feature defined in the module that was imported with that prefix, or the local module if the prefix matches the local module's prefix. Otherwise, a feature with the matching name MUST be defined in the current module or an included submodule.

如果布尔表达式中的要素名称上存在前缀,则带前缀的名称将引用在使用该前缀导入的模块中定义的要素,如果前缀与本地模块的前缀匹配,则引用本地模块。否则,必须在当前模块或包含的子模块中定义具有匹配名称的功能。

A leaf that is a list key MUST NOT have any "if-feature" statements.

作为列表键的叶不能有任何“if feature”语句。

7.20.2.1. Usage Example
7.20.2.1. 用法示例

In this example, the container "target" is implemented if either the "outbound-tls" or "outbound-ssh" feature is supported by the server.

在本例中,如果服务器支持“出站tls”或“出站ssh”功能,则实现容器“target”。

     container target {
       if-feature "outbound-tls or outbound-ssh";
       ...
     }
        
     container target {
       if-feature "outbound-tls or outbound-ssh";
       ...
     }
        

The following examples are equivalent:

以下示例是等效的:

if-feature "not foo or bar and baz";

如果功能“不是foo或bar和baz”;

if-feature "(not foo) or (bar and baz)";

如果特征“(非foo)或(bar和baz)”;

7.20.3. The "deviation" Statement
7.20.3. “偏差”陈述

The "deviation" statement defines a hierarchy of a module that the server does not implement faithfully. The argument is a string that identifies the node in the schema tree where a deviation from the module occurs. This node is called the deviation's target node. The contents of the "deviation" statement give details about the deviation.

“偏差”语句定义了服务器无法忠实实现的模块层次结构。参数是一个字符串,用于标识模式树中发生模块偏差的节点。该节点称为偏差的目标节点。“偏差”声明的内容给出了偏差的详细信息。

The argument string is an absolute schema node identifier (see Section 6.5).

参数字符串是绝对模式节点标识符(参见第6.5节)。

Deviations define the way a server or class of servers deviate from a standard. This means that deviations MUST never be part of a published standard, since they are the mechanism for learning how implementations vary from the standards.

偏差定义服务器或服务器类别偏离标准的方式。这意味着偏差决不能成为已发布标准的一部分,因为它们是了解实现如何与标准不同的机制。

Server deviations are strongly discouraged and MUST only be used as a last resort. Telling the application how a server fails to follow a standard is no substitute for implementing the standard correctly. A server that deviates from a module is not fully compliant with the module.

强烈反对服务器偏差,并且只能作为最后手段使用。告诉应用程序服务器如何未能遵循标准不能代替正确实现标准。偏离模块的服务器与该模块不完全兼容。

However, in some cases, a particular device may not have the hardware or software ability to support parts of a standard module. When this occurs, the server makes a choice to either treat attempts to configure unsupported parts of the module as an error that is reported back to the unsuspecting application or ignore those incoming requests. Neither choice is acceptable.

然而,在某些情况下,特定设备可能没有硬件或软件能力来支持标准模块的部分。发生这种情况时,服务器会选择将配置模块不受支持部分的尝试视为一个错误,并报告给不知情的应用程序,或者忽略这些传入的请求。这两种选择都是不可接受的。

Instead, YANG allows servers to document portions of a base module that are not supported, or that are supported but with different syntax, by using the "deviation" statement.

相反,YANG允许服务器使用“偏差”语句记录基本模块中不受支持的部分,或受支持但语法不同的部分。

After applying all deviations announced by a server, in any order, the resulting data model MUST still be valid.

在以任何顺序应用服务器宣布的所有偏差后,生成的数据模型必须仍然有效。

7.20.3.1. The deviation's Substatements
7.20.3.1. 偏差的子状态
                 +--------------+----------+-------------+
                 | substatement | section  | cardinality |
                 +--------------+----------+-------------+
                 | description  | 7.21.3   | 0..1        |
                 | deviate      | 7.20.3.2 | 1..n        |
                 | reference    | 7.21.4   | 0..1        |
                 +--------------+----------+-------------+
        
                 +--------------+----------+-------------+
                 | substatement | section  | cardinality |
                 +--------------+----------+-------------+
                 | description  | 7.21.3   | 0..1        |
                 | deviate      | 7.20.3.2 | 1..n        |
                 | reference    | 7.21.4   | 0..1        |
                 +--------------+----------+-------------+
        
7.20.3.2. The "deviate" Statement
7.20.3.2. “偏离”陈述

The "deviate" statement defines how the server's implementation of the target node deviates from its original definition. The argument is one of the strings "not-supported", "add", "replace", or "delete".

“偏离”语句定义了服务器对目标节点的实现如何偏离其原始定义。参数是字符串“不支持”、“添加”、“替换”或“删除”之一。

The argument "not-supported" indicates that the target node is not implemented by this server.

参数“not supported”表示此服务器未实现目标节点。

The argument "add" adds properties to the target node. The properties to add are identified by substatements to the "deviate" statement. If a property can only appear once, the property MUST NOT exist in the target node.

参数“add”将属性添加到目标节点。要添加的属性由“偏离”语句的子语句标识。如果属性只能出现一次,则该属性不得存在于目标节点中。

The argument "replace" replaces properties of the target node. The properties to replace are identified by substatements to the "deviate" statement. The properties to replace MUST exist in the target node.

参数“replace”替换目标节点的属性。要替换的属性由“偏离”语句的子语句标识。要替换的属性必须存在于目标节点中。

The argument "delete" deletes properties from the target node. The properties to delete are identified by substatements to the "delete" statement. The substatement's keyword MUST match a corresponding keyword in the target node, and the argument's string MUST be equal to the corresponding keyword's argument string in the target node.

参数“delete”从目标节点删除属性。要删除的属性由“delete”语句的子语句标识。子状态的关键字必须与目标节点中相应的关键字匹配,并且参数的字符串必须等于目标节点中相应关键字的参数字符串。

               +--------------+--------------+-------------+
               | substatement | section      | cardinality |
               +--------------+--------------+-------------+
               | config       | 7.21.1       | 0..1        |
               | default      | 7.6.4, 7.7.4 | 0..n        |
               | mandatory    | 7.6.5        | 0..1        |
               | max-elements | 7.7.6        | 0..1        |
               | min-elements | 7.7.5        | 0..1        |
               | must         | 7.5.3        | 0..n        |
               | type         | 7.4          | 0..1        |
               | unique       | 7.8.3        | 0..n        |
               | units        | 7.3.3        | 0..1        |
               +--------------+--------------+-------------+
        
               +--------------+--------------+-------------+
               | substatement | section      | cardinality |
               +--------------+--------------+-------------+
               | config       | 7.21.1       | 0..1        |
               | default      | 7.6.4, 7.7.4 | 0..n        |
               | mandatory    | 7.6.5        | 0..1        |
               | max-elements | 7.7.6        | 0..1        |
               | min-elements | 7.7.5        | 0..1        |
               | must         | 7.5.3        | 0..n        |
               | type         | 7.4          | 0..1        |
               | unique       | 7.8.3        | 0..n        |
               | units        | 7.3.3        | 0..1        |
               +--------------+--------------+-------------+
        

The deviate's Substatements

偏离子状态

If the target node has a property defined by an extension, this property can be deviated if the extension allows deviations. See Section 7.19 for details.

如果目标节点具有由扩展定义的属性,则如果扩展允许偏差,则该属性可以偏差。详见第7.19节。

7.20.3.3. Usage Example
7.20.3.3. 用法示例

In this example, the server is informing client applications that it does not support the "daytime" service in the style of RFC 867.

在本例中,服务器通知客户端应用程序它不支持RFC 867样式的“日间”服务。

     module example-deviations {
       yang-version 1.1;
       namespace "urn:example:deviations";
       prefix md;
        
     module example-deviations {
       yang-version 1.1;
       namespace "urn:example:deviations";
       prefix md;
        
       import example-base {
         prefix base;
       }
        
       import example-base {
         prefix base;
       }
        
       deviation /base:system/base:daytime {
         deviate not-supported;
       }
       ...
     }
        
       deviation /base:system/base:daytime {
         deviate not-supported;
       }
       ...
     }
        

A server would advertise both modules "example-base" and "example-deviations".

服务器将公布模块“示例库”和“示例偏差”。

The following example sets a server-specific default value to a leaf that does not have a default value defined:

以下示例将特定于服务器的默认值设置为未定义默认值的叶:

     deviation /base:system/base:user/base:type {
       deviate add {
         default "admin"; // new users are 'admin' by default
       }
     }
        
     deviation /base:system/base:user/base:type {
       deviate add {
         default "admin"; // new users are 'admin' by default
       }
     }
        

In this example, the server limits the number of name servers to 3:

在此示例中,服务器将名称服务器的数量限制为3:

     deviation /base:system/base:name-server {
       deviate replace {
         max-elements 3;
       }
     }
        
     deviation /base:system/base:name-server {
       deviate replace {
         max-elements 3;
       }
     }
        

If the original definition is:

如果原始定义为:

     container system {
       must "daytime or time";
       ...
     }
        
     container system {
       must "daytime or time";
       ...
     }
        

a server might remove this "must" constraint by doing:

服务器可以通过以下操作删除此“必须”约束:

     deviation /base:system {
       deviate delete {
         must "daytime or time";
       }
     }
        
     deviation /base:system {
       deviate delete {
         must "daytime or time";
       }
     }
        
7.21. Common Statements
7.21. 共同声明

This section defines substatements common to several other statements.

本节定义了几个其他语句共有的子语句。

7.21.1. The "config" Statement
7.21.1. “config”语句

The "config" statement takes as an argument the string "true" or "false". If "config" is "true", the definition represents configuration. Data nodes representing configuration are part of configuration datastores.

“config”语句将字符串“true”或“false”作为参数。如果“config”为“true”,则定义表示配置。表示配置的数据节点是配置数据存储的一部分。

If "config" is "false", the definition represents state data. Data nodes representing state data are not part of configuration datastores.

如果“config”为“false”,则定义表示状态数据。表示状态数据的数据节点不是配置数据存储的一部分。

If "config" is not specified, the default is the same as the parent schema node's "config" value. If the parent node is a case node, the value is the same as the case node's parent choice node.

如果未指定“config”,则默认值与父架构节点的“config”值相同。如果父节点是案例节点,则该值与案例节点的父选择节点相同。

If the top node does not specify a "config" statement, the default is "true".

如果顶部节点未指定“config”语句,则默认值为“true”。

If a node has "config" set to "false", no node underneath it can have "config" set to "true".

如果一个节点的“config”设置为“false”,那么它下面的任何节点都不能将“config”设置为“true”。

7.21.2. The "status" Statement
7.21.2. “地位”声明

The "status" statement takes as an argument one of the strings "current", "deprecated", or "obsolete".

“status”语句将字符串“current”、“deprecated”或“过时”中的一个作为参数。

o "current" means that the definition is current and valid.

o “当前”是指定义是当前有效的。

o "deprecated" indicates an obsolete definition, but it permits new/continued implementation in order to foster interoperability with older/existing implementations.

o “弃用”表示一个过时的定义,但它允许新的/继续的实现,以促进与旧的/现有的实现的互操作性。

o "obsolete" means that the definition is obsolete and SHOULD NOT be implemented and/or can be removed from implementations.

o “过时”是指该定义已过时,不应实施和/或可从实施中删除。

If no status is specified, the default is "current".

如果未指定状态,则默认为“当前”。

If a definition is "current", it MUST NOT reference a "deprecated" or "obsolete" definition within the same module.

如果定义是“当前的”,则它不得引用同一模块中的“已弃用”或“已过时”定义。

If a definition is "deprecated", it MUST NOT reference an "obsolete" definition within the same module.

如果定义是“不推荐的”,则它不得引用同一模块中的“过时”定义。

For example, the following is illegal:

例如,以下行为是非法的:

     typedef my-type {
       status deprecated;
       type int32;
     }
        
     typedef my-type {
       status deprecated;
       type int32;
     }
        
     leaf my-leaf {
       status current;
       type my-type; // illegal, since my-type is deprecated
     }
        
     leaf my-leaf {
       status current;
       type my-type; // illegal, since my-type is deprecated
     }
        
7.21.3. The "description" Statement
7.21.3. “说明”声明

The "description" statement takes as an argument a string that contains a human-readable textual description of this definition. The text is provided in a language (or languages) chosen by the module developer; for the sake of interoperability, it is RECOMMENDED to choose a language that is widely understood among the community of network administrators who will use the module.

“description”语句将包含此定义的可读文本描述的字符串作为参数。文本以模块开发人员选择的一种(或多种)语言提供;为了实现互操作性,建议选择一种将使用该模块的网络管理员社区广泛理解的语言。

7.21.4. The "reference" Statement
7.21.4. “参考”声明

The "reference" statement takes as an argument a string that is a human-readable cross-reference to an external document -- either another module that defines related management information or a document that provides additional information relevant to this definition.

“reference”语句将一个字符串作为参数,该字符串是对外部文档(定义相关管理信息的另一个模块或提供与此定义相关的附加信息的文档)的可读交叉引用。

For example, a typedef for a "uri" data type could look like:

例如,“uri”数据类型的typedef可能如下所示:

     typedef uri {
       type string;
       reference
         "RFC 3986: Uniform Resource Identifier (URI): Generic Syntax";
       ...
     }
        
     typedef uri {
       type string;
       reference
         "RFC 3986: Uniform Resource Identifier (URI): Generic Syntax";
       ...
     }
        
7.21.5. The "when" Statement
7.21.5. “何时”陈述

The "when" statement makes its parent data definition statement conditional. The node defined by the parent data definition statement is only valid when the condition specified by the "when" statement is satisfied. The statement's argument is an XPath expression (see Section 6.4), which is used to formally specify this condition. If the XPath expression conceptually evaluates to "true" for a particular instance, then the node defined by the parent data definition statement is valid; otherwise, it is not.

“when”语句使其父数据定义语句具有条件。父数据定义语句定义的节点仅在满足“when”语句指定的条件时有效。该语句的参数是一个XPath表达式(参见第6.4节),用于正式指定此条件。如果XPath表达式在概念上对特定实例的计算结果为“true”,则父数据定义语句定义的节点是有效的;否则,情况并非如此。

A leaf that is a list key MUST NOT have a "when" statement.

作为列表键的叶不能有“when”语句。

If a key leaf is defined in a grouping that is used in a list, the "uses" statement MUST NOT have a "when" statement.

如果在列表中使用的分组中定义了键叶,则“uses”语句不能有“when”语句。

See Section 8.3.2 for additional information.

更多信息见第8.3.2节。

The XPath expression is conceptually evaluated in the following context, in addition to the definition in Section 6.4.1:

除了第6.4.1节中的定义外,XPath表达式在以下上下文中进行概念性评估:

o If the "when" statement is a child of an "augment" statement, then the context node is the augment's target node in the data tree, if the target node is a data node. Otherwise, the context node is the closest ancestor node to the target node that is also a data node. If no such node exists, the context node is the root node. The accessible tree is tentatively altered during the processing of the XPath expression by removing all instances (if any) of the nodes added by the "augment" statement.

o 如果“when”语句是“augment”语句的子语句,则上下文节点是数据树中的augment的目标节点(如果目标节点是数据节点)。否则,上下文节点是距离目标节点(也是数据节点)最近的祖先节点。如果不存在这样的节点,则上下文节点是根节点。在XPath表达式的处理过程中,通过删除“augment”语句添加的节点的所有实例(如果有),可以暂时更改可访问树。

o If the "when" statement is a child of a "uses", "choice", or "case" statement, then the context node is the closest ancestor node to the node with the "when" statement that is also a data node. If no such node exists, the context node is the root node. The accessible tree is tentatively altered during the processing of the XPath expression by removing all instances (if any) of the nodes added by the "uses", "choice", or "case" statement.

o 如果“when”语句是“uses”、“choice”或“case”语句的子语句,则上下文节点是与同时也是数据节点的“when”语句的节点最近的祖先节点。如果不存在这样的节点,则上下文节点是根节点。在XPath表达式的处理过程中,通过删除由“uses”、“choice”或“case”语句添加的节点的所有实例(如果有),可以暂时更改可访问树。

o If the "when" statement is a child of any other data definition statement, the accessible tree is tentatively altered during the processing of the XPath expression by replacing all instances of the data node for which the "when" statement is defined with a single dummy node with the same name, but with no value and no children. If no such instance exists, the dummy node is tentatively created. The context node is this dummy node.

o 如果“when”语句是任何其他数据定义语句的子级,则在处理XPath表达式的过程中,通过将定义“when”语句的数据节点的所有实例替换为具有相同名称但没有值和子级的单个虚拟节点,可访问树将暂时更改。如果不存在这样的实例,则暂时创建虚拟节点。上下文节点就是这个虚拟节点。

The result of the XPath expression is converted to a boolean value using the standard XPath rules.

XPath表达式的结果使用标准XPath规则转换为布尔值。

If the XPath expression references any node that also has associated "when" statements, those "when" expressions MUST be evaluated first. There MUST NOT be any circular dependencies among "when" expressions.

如果XPath表达式引用的任何节点也有关联的“when”语句,则必须首先计算那些“when”表达式。“when”表达式之间不得存在任何循环依赖关系。

Note that the XPath expression is conceptually evaluated. This means that an implementation does not have to use an XPath evaluator in the server. The "when" statement can very well be implemented with specially written code.

请注意,XPath表达式是在概念上进行计算的。这意味着实现不必在服务器中使用XPath计算器。“when”语句可以用专门编写的代码很好地实现。

8. Constraints
8. 约束条件
8.1. Constraints on Data
8.1. 对数据的限制

Several YANG statements define constraints on valid data. These constraints are enforced in different ways, depending on what type of data the statement defines.

几个语句定义了对有效数据的约束。根据语句定义的数据类型,这些约束以不同的方式强制执行。

o If the constraint is defined on configuration data, it MUST be true in a valid configuration data tree.

o 如果约束是在配置数据上定义的,则在有效的配置数据树中必须为true。

o If the constraint is defined on state data, it MUST be true in a valid state data tree.

o 如果约束是在状态数据上定义的,则在有效的状态数据树中必须为true。

o If the constraint is defined on notification content, it MUST be true in any notification data tree.

o 如果约束是在通知内容上定义的,则在任何通知数据树中都必须为true。

o If the constraint is defined on RPC or action input parameters, it MUST be true in an invocation of the RPC or action operation.

o 如果约束是在RPC或操作输入参数上定义的,则在调用RPC或操作操作时必须为true。

o If the constraint is defined on RPC or action output parameters, it MUST be true in the RPC or action reply.

o 如果约束是在RPC或操作输出参数上定义的,则在RPC或操作回复中必须为true。

The following properties are true in all data trees:

以下属性在所有数据树中均为真:

o All leaf data values MUST match the type constraints for the leaf, including those defined in the type's "range", "length", and "pattern" properties.

o 所有叶数据值必须与叶的类型约束匹配,包括在类型的“范围”、“长度”和“模式”属性中定义的约束。

o All key leafs MUST be present for all list entries.

o 所有列表条目的所有键叶都必须存在。

o Nodes MUST be present for at most one case branch in all choices.

o 在所有选项中,节点最多必须存在一个案例分支。

o There MUST be no nodes tagged with "if-feature" present if the "if-feature" expression evaluates to "false" in the server.

o 如果“if feature”表达式在服务器中的计算结果为“false”,则必须不存在标记为“if feature”的节点。

o There MUST be no nodes tagged with "when" present if the "when" condition evaluates to "false" in the data tree.

o 如果数据树中的“when”条件计算为“false”,则不得存在标记为“when”的节点。

The following properties are true in a valid data tree:

以下属性在有效数据树中为真:

o All "must" constraints MUST evaluate to "true".

o 所有“必须”约束的计算结果必须为“真”。

o All referential integrity constraints defined via the "path" statement MUST be satisfied.

o 必须满足通过“path”语句定义的所有引用完整性约束。

o All "unique" constraints on lists MUST be satisfied.

o 必须满足列表上的所有“唯一”约束。

o The "mandatory" constraint is enforced for leafs and choices, unless the node or any of its ancestors has a "when" condition or "if-feature" expression that evaluates to "false".

o 除非节点或其任何祖先具有计算结果为“false”的“when”条件或“if feature”表达式,否则对叶和选项强制执行“mandatory”约束。

o The "min-elements" and "max-elements" constraints are enforced for lists and leaf-lists, unless the node or any of its ancestors has a "when" condition or "if-feature" expression that evaluates to "false".

o “最小元素”和“最大元素”约束对列表和叶列表强制执行,除非节点或其任何祖先具有计算结果为“false”的“when”条件或“if feature”表达式。

The running configuration datastore MUST always be valid.

正在运行的配置数据存储必须始终有效。

8.2. Configuration Data Modifications
8.2. 配置数据修改

o If a request creates configuration data nodes under a choice, any existing nodes from other case branches in the data tree are deleted by the server.

o 如果请求在选项下创建配置数据节点,则服务器将删除数据树中其他案例分支中的任何现有节点。

o If a request modifies a configuration data node such that any node's "when" expression becomes false, then the node in the data tree with the "when" expression is deleted by the server.

o 如果请求修改配置数据节点,使得任何节点的“何时”表达式变为false,则服务器将删除数据树中具有“何时”表达式的节点。

8.3. NETCONF Constraint Enforcement Model
8.3. NETCONF约束实施模型

For configuration data, there are three windows when constraints MUST be enforced:

对于配置数据,必须强制执行约束时有三个窗口:

o during parsing of RPC payloads

o 在分析RPC有效负载期间

o during processing of the <edit-config> operation

o 在处理<edit config>操作期间

o during validation

o 验证期间

Each of these scenarios is considered in the following sections.

以下各节将考虑其中的每种情况。

8.3.1. Payload Parsing
8.3.1. 有效负载解析

When content arrives in RPC payloads, it MUST be well-formed XML, following the hierarchy and content rules defined by the set of models the server implements.

当内容到达RPC有效负载时,它必须是格式良好的XML,遵循服务器实现的模型集定义的层次结构和内容规则。

o If a leaf data value does not match the type constraints for the leaf, including those defined in the type's "range", "length", and "pattern" properties, the server MUST reply with an "invalid-value" <error-tag> in the <rpc-error>, and with the error-app-tag (Section 7.5.4.2) and error-message (Section 7.5.4.1) associated with the constraint, if any exist.

o 如果叶数据值与叶的类型约束(包括在类型的“范围”、“长度”和“模式”属性中定义的约束)不匹配,服务器必须在<rpc error>中使用“无效值”<error tag>,并使用与约束相关联的error app tag(第7.5.4.2节)和错误消息(第7.5.4.1节)进行回复,如果有的话。

o If all keys of a list entry are not present, the server MUST reply with a "missing-element" <error-tag> in the <rpc-error>.

o 如果列表项的所有键都不存在,服务器必须在<rpc error>中使用“缺少元素”<error tag>进行回复。

o If data for more than one case branch of a choice is present, the server MUST reply with a "bad-element" <error-tag> in the <rpc-error>.

o 如果存在一个选项的多个案例分支的数据,服务器必须在<rpc error>中使用“bad element”<error tag>进行回复。

o If data for a node tagged with "if-feature" is present and the "if-feature" expression evaluates to "false" in the server, the server MUST reply with an "unknown-element" <error-tag> in the <rpc-error>.

o 如果在服务器中存在标记为“If feature”的节点的数据,并且“If feature”表达式的计算结果为“false”,则服务器必须在<rpc error>中使用“unknown element”<error tag>进行回复。

o If data for a node tagged with "when" is present and the "when" condition evaluates to "false", the server MUST reply with an "unknown-element" <error-tag> in the <rpc-error>.

o 如果标记为“when”的节点的数据存在,并且“when”条件的计算结果为“false”,则服务器必须在<rpc error>中使用“unknown element”<error tag>进行回复。

o For insert handling, if the values for the attributes "before" and "after" are not valid for the type of the appropriate key leafs, the server MUST reply with a "bad-attribute" <error-tag> in the <rpc-error>.

o 对于插入处理,如果属性“before”和“after”的值对于相应密钥叶的类型无效,服务器必须在<rpc error>中使用“bad attribute”<error tag>进行回复。

o If the attributes "before" and "after" appear in any element that is not a list whose "ordered-by" property is "user", the server MUST reply with an "unknown-attribute" <error-tag> in the <rpc-error>.

o 如果属性“before”和“after”出现在不是“ordered by”属性为“user”的列表的任何元素中,则服务器必须在<rpc error>中使用“unknown attribute”<error tag>。

8.3.2. NETCONF <edit-config> Processing
8.3.2. NETCONF<edit config>处理

After the incoming data is parsed, the NETCONF server performs the <edit-config> operation by applying the data to the configuration datastore. During this processing, the following errors MUST be detected:

解析传入数据后,NETCONF服务器通过将数据应用于配置数据存储来执行<edit config>操作。在此处理过程中,必须检测到以下错误:

o Delete requests for non-existent data.

o 删除对不存在数据的请求。

o Create requests for existent data.

o 创建对现有数据的请求。

o Insert requests with "before" or "after" parameters that do not exist.

o 使用不存在的“before”或“after”参数插入请求。

o Modification requests for nodes tagged with "when", and the "when" condition evaluates to "false". In this case, the server MUST reply with an "unknown-element" <error-tag> in the <rpc-error>.

o 对标记为“when”且“when”条件评估为“false”的节点的修改请求。在这种情况下,服务器必须在<rpc error>中使用“未知元素”<error tag>进行回复。

8.3.3. Validation
8.3.3. 验证

When datastore processing is complete, the final contents MUST obey all validation constraints. This validation processing is performed at differing times according to the datastore. If the datastore is "running" or "startup", these constraints MUST be enforced at the end of the <edit-config> or <copy-config> operation. If the datastore is "candidate", the constraint enforcement is delayed until a <commit> or <validate> operation takes place.

数据存储处理完成后,最终内容必须遵守所有验证约束。此验证处理根据数据存储在不同的时间执行。如果数据存储正在“运行”或“启动”,则必须在<edit config>或<copy config>操作结束时强制执行这些约束。如果数据存储为“候选”,则约束实施将延迟,直到发生<commit>或<validate>操作。

9. Built-In Types
9. 内置类型

YANG has a set of built-in types, similar to those of many programming languages, but with some differences due to special requirements from the management information model.

YANG有一组内置类型,类似于许多编程语言的类型,但由于管理信息模型的特殊要求而有所不同。

Additional types may be defined that are derived from those built-in types or from other derived types. Derived types may use subtyping to formally restrict the set of possible values.

可以定义从这些内置类型或其他派生类型派生的其他类型。派生类型可以使用子类型来正式限制可能的值集。

The different built-in types and their derived types allow different kinds of subtyping, namely length and regular expression restrictions of strings (Sections 9.4.4 and 9.4.5) and range restrictions of numeric types (Section 9.2.4).

不同的内置类型及其派生类型允许不同类型的子类型,即字符串的长度和正则表达式限制(第9.4.4节和第9.4.5节)和数字类型的范围限制(第9.2.4节)。

The lexical representation of a value of a certain type is used in the XML encoding and when specifying default values and numerical ranges in YANG modules.

在XML编码中以及在模块中指定默认值和数字范围时,使用特定类型值的词汇表示。

9.1. Canonical Representation
9.1. 典范表示

For most types, there is a single canonical representation of the type's values. Some types allow multiple lexical representations of the same value; for example, the positive integer "17" can be represented as "+17" or "17". Implementations MUST support all lexical representations specified in this document.

对于大多数类型,该类型的值只有一个规范表示形式。某些类型允许相同值的多个词汇表示;例如,正整数“17”可以表示为“+17”或“17”。实现必须支持本文档中指定的所有词汇表示。

When a server sends XML-encoded data, it MUST use the canonical form defined in this section. Other encodings may introduce alternate representations. Note, however, that values in the data tree are conceptually stored in the canonical representation as defined in this section. In particular, any XPath expression evaluations are done using the canonical form if the data type has a canonical form. If the data type does not have a canonical form, the format of the value MUST match the data type's lexical representation, but the exact format is implementation dependent.

当服务器发送XML编码的数据时,它必须使用本节中定义的规范格式。其他编码可能引入替代表示。但是,请注意,数据树中的值在概念上存储在本节中定义的规范表示中。特别是,如果数据类型具有规范形式,则任何XPath表达式计算都是使用规范形式完成的。如果数据类型没有规范形式,则值的格式必须与数据类型的词汇表示形式匹配,但确切的格式取决于实现。

Some types have a lexical representation that depends on the encoding, e.g., the XML context in which they occur. These types do not have a canonical form.

某些类型的词汇表示取决于编码,例如,它们出现的XML上下文。这些类型没有规范形式。

9.2. The Integer Built-In Types
9.2. 内置类型的整数

The integer built-in types are int8, int16, int32, int64, uint8, uint16, uint32, and uint64. They represent signed and unsigned integers of different sizes:

内置的整数类型有int8、int16、int32、int64、uint8、uint16、uint32和uint64。它们表示大小不同的有符号和无符号整数:

int8 represents integer values between -128 and 127, inclusively.

int8表示介于-128和127之间的整数值。

int16 represents integer values between -32768 and 32767, inclusively.

int16表示介于-32768和32767之间的整数值。

int32 represents integer values between -2147483648 and 2147483647, inclusively.

int32表示介于-2147483648和2147483647之间的整数值。

int64 represents integer values between -9223372036854775808 and 9223372036854775807, inclusively.

int64表示介于-9223372036854775808和9223372036854775807之间的整数值(包括)。

uint8 represents integer values between 0 and 255, inclusively.

uint8表示介于0和255之间的整数值(包括)。

uint16 represents integer values between 0 and 65535, inclusively.

uint16表示介于0和65535之间的整数值。

uint32 represents integer values between 0 and 4294967295, inclusively.

uint32表示0和4294967295之间的整数值,包括0和4294967295。

uint64 represents integer values between 0 and 18446744073709551615, inclusively.

uint64表示介于0和18446744073709551615之间的整数值。

9.2.1. Lexical Representation
9.2.1. 词汇表征

An integer value is lexically represented as an optional sign ("+" or "-"), followed by a sequence of decimal digits. If no sign is specified, "+" is assumed.

整数值在词汇上表示为可选符号(“+”或“-”),后跟一系列十进制数字。如果未指定符号,则假定为“+”。

For convenience, when specifying a default value for an integer in a YANG module, an alternative lexical representation can be used that represents the value in a hexadecimal or octal notation. The hexadecimal notation consists of an optional sign ("+" or "-"), followed by the characters "0x", followed by a number of hexadecimal digits where letters may be uppercase or lowercase. The octal notation consists of an optional sign ("+" or "-"), followed by the character "0", followed by a number of octal digits.

为方便起见,在阳模块中为整数指定默认值时,可以使用另一种词汇表示法,以十六进制或八进制表示值。十六进制表示法由可选符号(“+”或“-”)组成,后面是字符“0x”,后面是一些十六进制数字,其中字母可以是大写或小写。八进制表示法由可选符号(“+”或“-”)组成,后跟字符“0”,后跟许多八进制数字。

Note that if a default value in a YANG module has a leading zero ("0"), it is interpreted as an octal number. In the XML encoding, an integer is always interpreted as a decimal number, and leading zeros are allowed.

请注意,如果YANG模块中的默认值具有前导零(“0”),则会将其解释为八进制数。在XML编码中,整数总是被解释为十进制数,并且允许前导零。

Examples:

示例:

     // legal values
     +4711                       // legal positive value
     4711                        // legal positive value
     -123                        // legal negative value
     0xf00f                      // legal positive hexadecimal value
     -0xf                        // legal negative hexadecimal value
     052                         // legal positive octal value
        
     // legal values
     +4711                       // legal positive value
     4711                        // legal positive value
     -123                        // legal negative value
     0xf00f                      // legal positive hexadecimal value
     -0xf                        // legal negative hexadecimal value
     052                         // legal positive octal value
        
     // illegal values
     - 1                         // illegal intermediate space
        
     // illegal values
     - 1                         // illegal intermediate space
        
9.2.2. Canonical Form
9.2.2. 标准形

The canonical form of a positive integer does not include the sign "+". Leading zeros are prohibited. The value zero is represented as "0".

正整数的标准形式不包括符号“+”。禁止使用前导零。值0表示为“0”。

9.2.3. Restrictions
9.2.3. 限制

All integer types can be restricted with the "range" statement (Section 9.2.4).

所有整数类型都可以用“range”语句进行限制(第9.2.4节)。

9.2.4. The "range" Statement
9.2.4. “范围”声明

The "range" statement, which is an optional substatement to the "type" statement, takes as an argument a range expression string. It is used to restrict integer and decimal built-in types, or types derived from them.

“range”语句是“type”语句的可选子语句,它将range表达式字符串作为参数。它用于限制整数和十进制内置类型,或从它们派生的类型。

A range consists of an explicit value, or a lower-inclusive bound, two consecutive dots "..", and an upper-inclusive bound. Multiple values or ranges can be given, separated by "|". If multiple values or ranges are given, they all MUST be disjoint and MUST be in ascending order. If a range restriction is applied to a type that is already range-restricted, the new restriction MUST be equally limiting or more limiting, i.e., raising the lower bounds, reducing the upper bounds, removing explicit values or ranges, or splitting ranges into multiple ranges with intermediate gaps. Each explicit value and range boundary value given in the range expression MUST

范围由一个显式值或一个包含下限、两个连续点“.”和一个包含上限组成。可以给出多个值或范围,以“|”分隔。如果给定了多个值或范围,则它们都必须是不相交的,并且必须按升序排列。如果将范围限制应用于已受范围限制的类型,则新限制必须具有相同的限制或更大的限制,即提高下限、降低上限、删除显式值或范围,或将范围拆分为具有中间间隙的多个范围。范围表达式中给出的每个显式值和范围边界值必须

match the type being restricted or be one of the special values "min" or "max". "min" and "max" mean the minimum and maximum values accepted for the type being restricted, respectively.

匹配被限制的类型,或者是特殊值“最小”或“最大”之一。“最小值”和“最大值”分别指受限制类型可接受的最小值和最大值。

The range expression syntax is formally defined by the rule "range-arg" in Section 14.

范围表达式语法由第14节中的规则“range arg”正式定义。

9.2.4.1. The range's Substatements
9.2.4.1. 范围的子状态
                 +---------------+---------+-------------+
                 | substatement  | section | cardinality |
                 +---------------+---------+-------------+
                 | description   | 7.21.3  | 0..1        |
                 | error-app-tag | 7.5.4.2 | 0..1        |
                 | error-message | 7.5.4.1 | 0..1        |
                 | reference     | 7.21.4  | 0..1        |
                 +---------------+---------+-------------+
        
                 +---------------+---------+-------------+
                 | substatement  | section | cardinality |
                 +---------------+---------+-------------+
                 | description   | 7.21.3  | 0..1        |
                 | error-app-tag | 7.5.4.2 | 0..1        |
                 | error-message | 7.5.4.1 | 0..1        |
                 | reference     | 7.21.4  | 0..1        |
                 +---------------+---------+-------------+
        
9.2.5. Usage Example
9.2.5. 用法示例
     typedef my-base-int32-type {
       type int32 {
         range "1..4 | 10..20";
       }
     }
        
     typedef my-base-int32-type {
       type int32 {
         range "1..4 | 10..20";
       }
     }
        
     typedef my-type1 {
       type my-base-int32-type {
         // legal range restriction
         range "11..max"; // 11..20
       }
     }
        
     typedef my-type1 {
       type my-base-int32-type {
         // legal range restriction
         range "11..max"; // 11..20
       }
     }
        
     typedef my-type2 {
       type my-base-int32-type {
         // illegal range restriction
         range "11..100";
       }
     }
        
     typedef my-type2 {
       type my-base-int32-type {
         // illegal range restriction
         range "11..100";
       }
     }
        
9.3. The decimal64 Built-In Type
9.3. 小数64内置类型

The decimal64 built-in type represents a subset of the real numbers, which can be represented by decimal numerals. The value space of decimal64 is the set of numbers that can be obtained by multiplying a 64-bit signed integer by a negative power of ten, i.e., expressible as "i x 10^-n" where i is an integer64 and n is an integer between 1 and 18, inclusively.

decimal64内置类型表示实数的子集,可以用十进制数字表示。小数64的值空间是可通过将64位有符号整数乘以10的负幂而获得的一组数字,即,可表示为“i x 10^-n”,其中i是整数64,n是介于1和18之间的整数。

9.3.1. Lexical Representation
9.3.1. 词汇表征

A decimal64 value is lexically represented as an optional sign ("+" or "-"), followed by a sequence of decimal digits, optionally followed by a period ('.') as a decimal indicator and a sequence of decimal digits. If no sign is specified, "+" is assumed.

十进制64值在词汇上表示为可选符号(“+”或“-”),后跟十进制数字序列,可选后跟句点(“.”)作为十进制指示符和十进制数字序列。如果未指定符号,则假定为“+”。

9.3.2. Canonical Form
9.3.2. 标准形

The canonical form of a positive decimal64 value does not include the sign "+". The decimal point is required. Leading and trailing zeros are prohibited, subject to the rule that there MUST be at least one digit before and after the decimal point. The value zero is represented as "0.0".

正小数64值的标准形式不包括符号“+”。小数点是必需的。禁止使用前导零和尾随零,前提是小数点前后必须至少有一位数字。值0表示为“0.0”。

9.3.3. Restrictions
9.3.3. 限制

A decimal64 type can be restricted with the "range" statement (Section 9.2.4).

小数64类型可通过“范围”语句进行限制(第9.2.4节)。

9.3.4. The "fraction-digits" Statement
9.3.4. “分数位数”语句

The "fraction-digits" statement, which is a substatement to the "type" statement, MUST be present if the type is "decimal64". It takes as an argument an integer between 1 and 18, inclusively. It controls the size of the minimum difference between values of a decimal64 type by restricting the value space to numbers that are expressible as "i x 10^-n" where n is the fraction-digits argument.

“小数位数”语句是“type”语句的子语句,如果类型为“decimal64”,则必须存在该语句。它接受一个介于1和18之间的整数作为参数。它通过将值空间限制为可表示为“i x 10^-n”的数字来控制小数64类型的值之间最小差值的大小,其中n是小数位数参数。

The following table lists the minimum and maximum values for each fraction-digit value:

下表列出了每个分数位数的最小值和最大值:

     +----------------+-----------------------+----------------------+
     | fraction-digit | min                   | max                  |
     +----------------+-----------------------+----------------------+
     | 1              | -922337203685477580.8 | 922337203685477580.7 |
     | 2              | -92233720368547758.08 | 92233720368547758.07 |
     | 3              | -9223372036854775.808 | 9223372036854775.807 |
     | 4              | -922337203685477.5808 | 922337203685477.5807 |
     | 5              | -92233720368547.75808 | 92233720368547.75807 |
     | 6              | -9223372036854.775808 | 9223372036854.775807 |
     | 7              | -922337203685.4775808 | 922337203685.4775807 |
     | 8              | -92233720368.54775808 | 92233720368.54775807 |
     | 9              | -9223372036.854775808 | 9223372036.854775807 |
     | 10             | -922337203.6854775808 | 922337203.6854775807 |
     | 11             | -92233720.36854775808 | 92233720.36854775807 |
     | 12             | -9223372.036854775808 | 9223372.036854775807 |
     | 13             | -922337.2036854775808 | 922337.2036854775807 |
     | 14             | -92233.72036854775808 | 92233.72036854775807 |
     | 15             | -9223.372036854775808 | 9223.372036854775807 |
     | 16             | -922.3372036854775808 | 922.3372036854775807 |
     | 17             | -92.23372036854775808 | 92.23372036854775807 |
     | 18             | -9.223372036854775808 | 9.223372036854775807 |
     +----------------+-----------------------+----------------------+
        
     +----------------+-----------------------+----------------------+
     | fraction-digit | min                   | max                  |
     +----------------+-----------------------+----------------------+
     | 1              | -922337203685477580.8 | 922337203685477580.7 |
     | 2              | -92233720368547758.08 | 92233720368547758.07 |
     | 3              | -9223372036854775.808 | 9223372036854775.807 |
     | 4              | -922337203685477.5808 | 922337203685477.5807 |
     | 5              | -92233720368547.75808 | 92233720368547.75807 |
     | 6              | -9223372036854.775808 | 9223372036854.775807 |
     | 7              | -922337203685.4775808 | 922337203685.4775807 |
     | 8              | -92233720368.54775808 | 92233720368.54775807 |
     | 9              | -9223372036.854775808 | 9223372036.854775807 |
     | 10             | -922337203.6854775808 | 922337203.6854775807 |
     | 11             | -92233720.36854775808 | 92233720.36854775807 |
     | 12             | -9223372.036854775808 | 9223372.036854775807 |
     | 13             | -922337.2036854775808 | 922337.2036854775807 |
     | 14             | -92233.72036854775808 | 92233.72036854775807 |
     | 15             | -9223.372036854775808 | 9223.372036854775807 |
     | 16             | -922.3372036854775808 | 922.3372036854775807 |
     | 17             | -92.23372036854775808 | 92.23372036854775807 |
     | 18             | -9.223372036854775808 | 9.223372036854775807 |
     +----------------+-----------------------+----------------------+
        
9.3.5. Usage Example
9.3.5. 用法示例
     typedef my-decimal {
       type decimal64 {
         fraction-digits 2;
         range "1 .. 3.14 | 10 | 20..max";
       }
     }
        
     typedef my-decimal {
       type decimal64 {
         fraction-digits 2;
         range "1 .. 3.14 | 10 | 20..max";
       }
     }
        
9.4. The string Built-In Type
9.4. 字符串内置类型

The string built-in type represents human-readable strings in YANG. Legal characters are the Unicode and ISO/IEC 10646 [ISO.10646] characters, including tab, carriage return, and line feed but excluding the other C0 control characters, the surrogate blocks, and the noncharacters. The string syntax is formally defined by the rule "yang-string" in Section 14.

字符串内置类型表示YANG中的人类可读字符串。合法字符是Unicode和ISO/IEC 10646[ISO.10646]字符,包括制表符、回车符和换行符,但不包括其他C0控制字符、代理块和非字符。字符串语法由第14节中的规则“yang string”正式定义。

9.4.1. Lexical Representation
9.4.1. 词汇表征

A string value is lexically represented as character data in the XML encoding.

在XML编码中,字符串值在词汇上表示为字符数据。

9.4.2. Canonical Form
9.4.2. 标准形

The canonical form is the same as the lexical representation. No Unicode normalization of string values is performed.

规范形式与词汇表示相同。不执行字符串值的Unicode规范化。

9.4.3. Restrictions
9.4.3. 限制

A string can be restricted with the "length" (Section 9.4.4) and "pattern" (Section 9.4.5) statements.

可以使用“长度”(第9.4.4节)和“模式”(第9.4.5节)语句限制字符串。

9.4.4. The "length" Statement
9.4.4. “长度”陈述

The "length" statement, which is an optional substatement to the "type" statement, takes as an argument a length expression string. It is used to restrict the built-in types "string" and "binary" or types derived from them.

“length”语句是“type”语句的可选子语句,它以长度表达式字符串作为参数。它用于限制内置类型“string”和“binary”或从它们派生的类型。

A "length" statement restricts the number of Unicode characters in the string.

“length”语句限制字符串中Unicode字符的数量。

A length range consists of an explicit value, or a lower bound, two consecutive dots "..", and an upper bound. Multiple values or ranges can be given, separated by "|". Length-restricting values MUST NOT be negative. If multiple values or ranges are given, they all MUST be disjoint and MUST be in ascending order. If a length restriction is applied to a type that is already length-restricted, the new restriction MUST be equally limiting or more limiting, i.e., raising the lower bounds, reducing the upper bounds, removing explicit length values or ranges, or splitting ranges into multiple ranges with intermediate gaps. A length value is a non-negative integer or one of the special values "min" or "max". "min" and "max" mean the minimum and maximum lengths accepted for the type being restricted, respectively. An implementation is not required to support a length value larger than 18446744073709551615.

长度范围由一个显式值或一个下限、两个连续点“.”和一个上限组成。可以给出多个值或范围,以“|”分隔。长度限制值不得为负值。如果给定了多个值或范围,则它们都必须是不相交的,并且必须按升序排列。如果将长度限制应用于已受长度限制的类型,则新限制必须具有相同的限制或更大的限制,即提高下界、降低上界、删除显式长度值或范围,或将范围拆分为具有中间间隙的多个范围。长度值是非负整数或特殊值“min”或“max”之一。“最小”和“最大”分别指受限制类型可接受的最小和最大长度。实现不需要支持大于18446744073709551615的长度值。

The length expression syntax is formally defined by the rule "length-arg" in Section 14.

长度表达式语法由第14节中的规则“length arg”正式定义。

9.4.4.1. The length's Substatements
9.4.4.1. 长度的子状态
                 +---------------+---------+-------------+
                 | substatement  | section | cardinality |
                 +---------------+---------+-------------+
                 | description   | 7.21.3  | 0..1        |
                 | error-app-tag | 7.5.4.2 | 0..1        |
                 | error-message | 7.5.4.1 | 0..1        |
                 | reference     | 7.21.4  | 0..1        |
                 +---------------+---------+-------------+
        
                 +---------------+---------+-------------+
                 | substatement  | section | cardinality |
                 +---------------+---------+-------------+
                 | description   | 7.21.3  | 0..1        |
                 | error-app-tag | 7.5.4.2 | 0..1        |
                 | error-message | 7.5.4.1 | 0..1        |
                 | reference     | 7.21.4  | 0..1        |
                 +---------------+---------+-------------+
        
9.4.5. The "pattern" Statement
9.4.5. “模式”声明

The "pattern" statement, which is an optional substatement to the "type" statement, takes as an argument a regular expression string, as defined in [XSD-TYPES]. It is used to restrict the built-in type "string", or types derived from "string", to values that match the pattern.

“pattern”语句是“type”语句的可选子语句,它将[XSD-TYPES]中定义的正则表达式字符串作为参数。它用于将内置类型“string”或从“string”派生的类型限制为与模式匹配的值。

If the type has multiple "pattern" statements, the expressions are ANDed together, i.e., all such expressions have to match.

如果类型有多个“模式”语句,则表达式将被AND放在一起,即所有此类表达式都必须匹配。

If a pattern restriction is applied to a type that is already pattern-restricted, values must match all patterns in the base type, in addition to the new patterns.

如果对已受模式限制的类型应用了模式限制,则除了新模式外,值还必须与基类型中的所有模式匹配。

9.4.5.1. The pattern's Substatements
9.4.5.1. 模式的子状态
                 +---------------+---------+-------------+
                 | substatement  | section | cardinality |
                 +---------------+---------+-------------+
                 | description   | 7.21.3  | 0..1        |
                 | error-app-tag | 7.5.4.2 | 0..1        |
                 | error-message | 7.5.4.1 | 0..1        |
                 | modifier      | 9.4.6   | 0..1        |
                 | reference     | 7.21.4  | 0..1        |
                 +---------------+---------+-------------+
        
                 +---------------+---------+-------------+
                 | substatement  | section | cardinality |
                 +---------------+---------+-------------+
                 | description   | 7.21.3  | 0..1        |
                 | error-app-tag | 7.5.4.2 | 0..1        |
                 | error-message | 7.5.4.1 | 0..1        |
                 | modifier      | 9.4.6   | 0..1        |
                 | reference     | 7.21.4  | 0..1        |
                 +---------------+---------+-------------+
        
9.4.6. The "modifier" Statement
9.4.6. “修饰语”语句

The "modifier" statement, which is an optional substatement to the "pattern" statement, takes as an argument the string "invert-match".

“modifier”语句是“pattern”语句的可选子语句,它将字符串“invert match”作为参数。

If a pattern has the "invert-match" modifier present, the type is restricted to values that do not match the pattern.

如果图案具有“反转匹配”修饰符,则该类型仅限于与图案不匹配的值。

9.4.7. Usage Example
9.4.7. 用法示例

With the following typedef:

使用以下typedef:

     typedef my-base-str-type {
       type string {
         length "1..255";
       }
     }
        
     typedef my-base-str-type {
       type string {
         length "1..255";
       }
     }
        

the following refinement is legal:

以下改进是合法的:

     type my-base-str-type {
       // legal length refinement
       length "11 | 42..max"; // 11 | 42..255
     }
        
     type my-base-str-type {
       // legal length refinement
       length "11 | 42..max"; // 11 | 42..255
     }
        

and the following refinement is illegal:

以下细化是非法的:

     type my-base-str-type {
       // illegal length refinement
       length "1..999";
     }
        
     type my-base-str-type {
       // illegal length refinement
       length "1..999";
     }
        

With the following type:

使用以下类型:

     type string {
       length "0..4";
       pattern "[0-9a-fA-F]*";
     }
        
     type string {
       length "0..4";
       pattern "[0-9a-fA-F]*";
     }
        

the following strings match:

以下字符串匹配:

     AB          // legal
     9A00        // legal
        
     AB          // legal
     9A00        // legal
        

and the following strings do not match:

并且以下字符串不匹配:

     00ABAB      // illegal, too long
     xx00        // illegal, bad characters
        
     00ABAB      // illegal, too long
     xx00        // illegal, bad characters
        

With the following type:

使用以下类型:

     type string {
       length "1..max";
       pattern '[a-zA-Z_][a-zA-Z0-9\-_.]*';
       pattern '[xX][mM][lL].*' {
         modifier invert-match;
       }
     }
        
     type string {
       length "1..max";
       pattern '[a-zA-Z_][a-zA-Z0-9\-_.]*';
       pattern '[xX][mM][lL].*' {
         modifier invert-match;
       }
     }
        

the following string matches:

以下字符串匹配:

enabled // legal

启用//合法

and the following strings do not match:

并且以下字符串不匹配:

     10-mbit     // illegal, starts with a number
     xml-element // illegal, starts with illegal sequence
        
     10-mbit     // illegal, starts with a number
     xml-element // illegal, starts with illegal sequence
        
9.5. The boolean Built-In Type
9.5. 布尔型内置类型

The boolean built-in type represents a boolean value.

布尔内置类型表示布尔值。

9.5.1. Lexical Representation
9.5.1. 词汇表征

The lexical representation of a boolean value is a string with a value of "true" or "false". These values MUST be in lowercase.

布尔值的词汇表示是一个值为“真”或“假”的字符串。这些值必须为小写。

9.5.2. Canonical Form
9.5.2. 标准形

The canonical form is the same as the lexical representation.

规范形式与词汇表示相同。

9.5.3. Restrictions
9.5.3. 限制

A boolean cannot be restricted.

布尔值不能被限制。

9.6. The enumeration Built-In Type
9.6. 枚举内置类型

The enumeration built-in type represents values from a set of assigned names.

枚举内置类型表示一组指定名称中的值。

9.6.1. Lexical Representation
9.6.1. 词汇表征

The lexical representation of an enumeration value is the assigned name string.

枚举值的词法表示是指定的名称字符串。

9.6.2. Canonical Form
9.6.2. 标准形

The canonical form is the assigned name string.

规范形式是指定的名称字符串。

9.6.3. Restrictions
9.6.3. 限制

An enumeration can be restricted with one or more "enum" (Section 9.6.4) statements, which enumerate a subset of the values for the base type.

可以使用一个或多个“enum”(第9.6.4节)语句限制枚举,这些语句枚举基类型值的子集。

9.6.4. The "enum" Statement
9.6.4. “enum”语句

The "enum" statement, which is a substatement to the "type" statement, MUST be present if the type is "enumeration". It is repeatedly used to specify each assigned name of an enumeration type. It takes as an argument a string that is the assigned name. The string MUST NOT be zero-length and MUST NOT have any leading or trailing whitespace characters (any Unicode character with the "White_Space" property). The use of Unicode control codes SHOULD be avoided.

“enum”语句是“type”语句的子语句,如果类型为“enumeration”,则必须存在该语句。它反复用于指定枚举类型的每个指定名称。它将指定名称的字符串作为参数。字符串长度不得为零,且不得包含任何前导或尾随空格字符(任何具有“White_Space”属性的Unicode字符)。应避免使用Unicode控制代码。

The statement is optionally followed by a block of substatements that holds detailed enum information.

该语句后面有一个包含详细枚举信息的子语句块(可选)。

All assigned names in an enumeration MUST be unique.

枚举中所有分配的名称都必须是唯一的。

When an existing enumeration type is restricted, the set of assigned names in the new type MUST be a subset of the base type's set of assigned names. The value of such an assigned name MUST NOT be changed.

当限制现有枚举类型时,新类型中的已分配名称集必须是基类型的已分配名称集的子集。不得更改此类指定名称的值。

9.6.4.1. The enum's Substatements
9.6.4.1. 枚举的子语句
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | description  | 7.21.3  | 0..1        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | value        | 9.6.4.2 | 0..1        |
                 +--------------+---------+-------------+
        
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | description  | 7.21.3  | 0..1        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 | value        | 9.6.4.2 | 0..1        |
                 +--------------+---------+-------------+
        
9.6.4.2. The "value" Statement
9.6.4.2. “价值”陈述

The "value" statement, which is optional, is used to associate an integer value with the assigned name for the enum. This integer value MUST be in the range -2147483648 to 2147483647, and it MUST be unique within the enumeration type.

“value”语句是可选的,用于将整数值与枚举的指定名称相关联。此整数值必须在-2147483648到2147483647之间,并且在枚举类型中必须是唯一的。

If a value is not specified, then one will be automatically assigned. If the "enum" substatement is the first one defined, the assigned value is zero (0); otherwise, the assigned value is one greater than the current highest enum value (i.e., the highest enum value, implicit or explicit, prior to the current "enum" substatement in the parent "type" statement).

如果未指定值,则将自动指定一个值。如果“enum”子状态是第一个定义的子状态,则赋值为零(0);否则,分配的值比当前最高枚举值大一个(即,在父“type”语句中当前“enum”子语句之前的隐式或显式最高枚举值)。

Note that the presence of an "if-feature" statement in an "enum" statement does not affect the automatically assigned value.

请注意,“enum”语句中存在“if feature”语句不会影响自动分配的值。

If the current highest value is equal to 2147483647, then an enum value MUST be specified for "enum" substatements following the one with the current highest value.

如果当前最大值等于2147483647,则必须为具有当前最大值的子状态之后的“enum”子状态指定枚举值。

When an existing enumeration type is restricted, the "value" statement MUST either have the same value as in the base type or not be present, in which case the value is the same as in the base type.

当限制现有枚举类型时,“value”语句必须与基类型中的值相同或不存在,在这种情况下,该值与基类型中的值相同。

9.6.5. Usage Example
9.6.5. 用法示例
     leaf myenum {
       type enumeration {
         enum zero;
         enum one;
         enum seven {
           value 7;
         }
       }
     }
        
     leaf myenum {
       type enumeration {
         enum zero;
         enum one;
         enum seven {
           value 7;
         }
       }
     }
        

The lexical representation of the leaf "myenum" with value "seven" is:

值为“seven”的叶“myenum”的词汇表示为:

     <myenum>seven</myenum>
        
     <myenum>seven</myenum>
        

With the following typedef:

使用以下typedef:

     typedef my-base-enumeration-type {
       type enumeration {
         enum white {
           value 1;
         }
         enum yellow {
           value 2;
         }
         enum red {
           value 3;
         }
       }
     }
        
     typedef my-base-enumeration-type {
       type enumeration {
         enum white {
           value 1;
         }
         enum yellow {
           value 2;
         }
         enum red {
           value 3;
         }
       }
     }
        

the following refinement is legal:

以下改进是合法的:

     type my-base-enumeration-type {
       // legal enum refinement
       enum yellow;
       enum red {
         value 3;
       }
     }
        
     type my-base-enumeration-type {
       // legal enum refinement
       enum yellow;
       enum red {
         value 3;
       }
     }
        

and the following refinement is illegal:

以下细化是非法的:

     type my-base-enumeration-type {
       // illegal enum refinement
       enum yellow {
         value 4; // illegal value change
       }
       enum black; // illegal addition of new name
     }
        
     type my-base-enumeration-type {
       // illegal enum refinement
       enum yellow {
         value 4; // illegal value change
       }
       enum black; // illegal addition of new name
     }
        

The following example shows how an "enum" can be tagged with "if-feature", making the value legal only on servers that advertise the corresponding feature:

以下示例显示了如何使用“if feature”标记“enum”,使该值仅在发布相应功能的服务器上合法:

     type enumeration {
       enum tcp;
       enum ssh {
         if-feature ssh;
       }
       enum tls {
         if-feature tls;
       }
     }
        
     type enumeration {
       enum tcp;
       enum ssh {
         if-feature ssh;
       }
       enum tls {
         if-feature tls;
       }
     }
        
9.7. The bits Built-In Type
9.7. 内置式钻头

The bits built-in type represents a bit set. That is, a bits value is a set of flags identified by small integer position numbers starting at 0. Each bit number has an assigned name.

bits内置类型表示位集。也就是说,位值是由从0开始的小整数位置号标识的一组标志。每个位号都有一个指定的名称。

When an existing bits type is restricted, the set of assigned names in the new type MUST be a subset of the base type's set of assigned names. The bit position of such an assigned name MUST NOT be changed.

当现有bits类型受到限制时,新类型中的已分配名称集必须是基本类型的已分配名称集的子集。不得更改此类指定名称的位位置。

9.7.1. Restrictions
9.7.1. 限制

A bits type can be restricted with the "bit" (Section 9.7.4) statement.

bits类型可通过“bit”(第9.7.4节)语句进行限制。

9.7.2. Lexical Representation
9.7.2. 词汇表征

The lexical representation of the bits type is a space-separated list of the names of the bits that are set. A zero-length string thus represents a value where no bits are set.

bits类型的词汇表示是一个以空格分隔的列表,其中列出了所设置的位的名称。因此,零长度字符串表示未设置位的值。

9.7.3. Canonical Form
9.7.3. 标准形

In the canonical form, the bit values are separated by a single space character and they appear ordered by their position (see Section 9.7.4.2).

在标准格式中,位值由单个空格字符分隔,并按其位置排列(见第9.7.4.2节)。

9.7.4. The "bit" Statement
9.7.4. “比特”声明

The "bit" statement, which is a substatement to the "type" statement, MUST be present if the type is "bits". It is repeatedly used to specify each assigned named bit of a bits type. It takes as an argument a string that is the assigned name of the bit. It is followed by a block of substatements that holds detailed bit information. The assigned name follows the same syntax rules as an identifier (see Section 6.2).

“bit”语句是“type”语句的子语句,如果类型为“bits”,则必须存在该语句。它反复用于指定位类型的每个指定的命名位。它接受一个字符串作为参数,该字符串是位的指定名称。它后面是一个包含详细位信息的子语句块。分配的名称遵循与标识符相同的语法规则(参见第6.2节)。

All assigned names in a bits type MUST be unique.

bits类型中所有分配的名称必须是唯一的。

9.7.4.1. The bit's Substatements
9.7.4.1. 钻头的子级
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | description  | 7.21.3  | 0..1        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | position     | 9.7.4.2 | 0..1        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 +--------------+---------+-------------+
        
                 +--------------+---------+-------------+
                 | substatement | section | cardinality |
                 +--------------+---------+-------------+
                 | description  | 7.21.3  | 0..1        |
                 | if-feature   | 7.20.2  | 0..n        |
                 | position     | 9.7.4.2 | 0..1        |
                 | reference    | 7.21.4  | 0..1        |
                 | status       | 7.21.2  | 0..1        |
                 +--------------+---------+-------------+
        
9.7.4.2. The "position" Statement
9.7.4.2. “立场”声明

The "position" statement, which is optional, takes as an argument a non-negative integer value that specifies the bit's position within a hypothetical bit field. The position value MUST be in the range 0 to 4294967295, and it MUST be unique within the bits type.

“position”语句是可选的,它接受一个非负整数值作为参数,该数值指定位在假设位字段中的位置。位置值必须在0到4294967295之间,并且在bits类型中必须是唯一的。

If a bit position is not specified, then one will be automatically assigned. If the "bit" substatement is the first one defined, the assigned value is zero (0); otherwise, the assigned value is one greater than the current highest bit position (i.e., the highest bit position, implicit or explicit, prior to the current "bit" substatement in the parent "type" statement).

如果未指定位位置,则将自动分配一个位位置。如果“位”子状态是第一个定义的子状态,则赋值为零(0);否则,分配的值比当前最高位位置大一个(即,在父“type”语句中当前“bit”子状态之前的隐式或显式最高位位置)。

Note that the presence of an "if-feature" statement in a "bit" statement does not affect the automatically assigned position.

请注意,“bit”语句中出现“if feature”语句不会影响自动分配的位置。

If the current highest bit position value is equal to 4294967295, then a position value MUST be specified for "bit" substatements following the one with the current highest position value.

如果当前最高位位置值等于4294967295,则必须为具有当前最高位置值的子状态之后的“位”子状态指定位置值。

When an existing bits type is restricted, the "position" statement MUST either have the same value as in the base type or not be present, in which case the value is the same as in the base type.

当现有bits类型受到限制时,“position”语句必须与基类型中的值相同或不存在,在这种情况下,该值与基类型中的值相同。

9.7.5. Usage Example
9.7.5. 用法示例

Given the following typedef and leaf:

给定以下typedef和leaf:

     typedef mybits-type {
       type bits {
         bit disable-nagle {
           position 0;
         }
         bit auto-sense-speed {
           position 1;
         }
         bit ten-mb-only {
           position 2;
         }
       }
     }
        
     typedef mybits-type {
       type bits {
         bit disable-nagle {
           position 0;
         }
         bit auto-sense-speed {
           position 1;
         }
         bit ten-mb-only {
           position 2;
         }
       }
     }
        
     leaf mybits {
       type mybits-type;
       default "auto-sense-speed";
     }
        
     leaf mybits {
       type mybits-type;
       default "auto-sense-speed";
     }
        

The lexical representation of this leaf with bit values disable-nagle and ten-mb-only set would be:

此叶的词法表示(位值为disable nagle且仅设置了10 mb)为:

     <mybits>disable-nagle ten-mb-only</mybits>
        
     <mybits>disable-nagle ten-mb-only</mybits>
        

The following example shows a legal refinement of this type:

以下示例显示了此类型的法律细化:

     type mybits-type {
       // legal bit refinement
       bit disable-nagle {
         position 0;
       }
       bit auto-sense-speed {
         position 1;
       }
     }
        
     type mybits-type {
       // legal bit refinement
       bit disable-nagle {
         position 0;
       }
       bit auto-sense-speed {
         position 1;
       }
     }
        

and the following refinement is illegal:

以下细化是非法的:

     type mybits-type {
       // illegal bit refinement
       bit disable-nagle {
         position 2; // illegal position change
       }
       bit hundred-mb-only; // illegal addition of new name
     }
        
     type mybits-type {
       // illegal bit refinement
       bit disable-nagle {
         position 2; // illegal position change
       }
       bit hundred-mb-only; // illegal addition of new name
     }
        
9.8. The binary Built-In Type
9.8. 二进制内置类型

The binary built-in type represents any binary data, i.e., a sequence of octets.

二进制内置类型表示任何二进制数据,即八位字节序列。

9.8.1. Restrictions
9.8.1. 限制

A binary type can be restricted with the "length" (Section 9.4.4) statement. The length of a binary value is the number of octets it contains.

二进制类型可以通过“长度”(第9.4.4节)语句进行限制。二进制值的长度是它包含的八位字节数。

9.8.2. Lexical Representation
9.8.2. 词汇表征

Binary values are encoded with the base64 encoding scheme (see Section 4 in [RFC4648]).

二进制值采用base64编码方案进行编码(参见[RFC4648]中的第4节)。

9.8.3. Canonical Form
9.8.3. 标准形

The canonical form of a binary value follows the rules of "Base 64 Encoding" in [RFC4648].

二进制值的标准形式遵循[RFC4648]中的“base64编码”规则。

9.9. The leafref Built-In Type
9.9. leafref内置类型

The leafref built-in type is restricted to the value space of some leaf or leaf-list node in the schema tree and optionally further restricted by corresponding instance nodes in the data tree. The "path" substatement (Section 9.9.2) is used to identify the referred leaf or leaf-list node in the schema tree. The value space of the referring node is the value space of the referred node.

leafref内置类型仅限于模式树中某个叶或叶列表节点的值空间,并且还可以进一步受到数据树中相应实例节点的限制。“路径”子语句(第9.9.2节)用于标识模式树中引用的叶或叶列表节点。引用节点的值空间是引用节点的值空间。

If the "require-instance" property (Section 9.9.3) is "true", there MUST exist a node in the data tree, or a node with a default value in use (see Sections 7.6.1 and 7.7.2), of the referred schema tree leaf or leaf-list node with the same value as the leafref value in a valid data tree.

如果“require instance”属性(第9.9.3节)为“true”,则数据树中必须存在一个节点,或者引用的模式树叶或叶列表节点的默认值(见第7.6.1节和第7.7.2节)与有效数据树中的leafref值相同的节点。

If the referring node represents configuration data and the "require-instance" property (Section 9.9.3) is "true", the referred node MUST also represent configuration.

如果引用节点表示配置数据且“require instance”属性(第9.9.3节)为“true”,则引用节点还必须表示配置。

There MUST NOT be any circular chains of leafrefs.

叶参照不得有任何环形链。

If the leaf that the leafref refers to is conditional based on one or more features (see Section 7.20.2), then the leaf with the leafref type MUST also be conditional based on at least the same set of features.

如果leafref引用的叶基于一个或多个特征(见第7.20.2节),则具有leafref类型的叶也必须基于至少相同的特征集。

9.9.1. Restrictions
9.9.1. 限制

A leafref can be restricted with the "require-instance" statement (Section 9.9.3).

leafref可以通过“require instance”语句进行限制(第9.9.3节)。

9.9.2. The "path" Statement
9.9.2. “路径”语句

The "path" statement, which is a substatement to the "type" statement, MUST be present if the type is "leafref". It takes as an argument a string that MUST refer to a leaf or leaf-list node.

“path”语句是“type”语句的子语句,如果类型为“leafref”,则必须存在该语句。它接受一个必须引用叶或叶列表节点的字符串作为参数。

The syntax for a path argument is a subset of the XPath abbreviated syntax. Predicates are used only for constraining the values for the key nodes for list entries. Each predicate consists of exactly one equality test per key, and multiple adjacent predicates MAY be present if a list has multiple keys. The syntax is formally defined by the rule "path-arg" in Section 14.

path参数的语法是XPath缩写语法的子集。谓词仅用于约束列表项的关键节点的值。每个谓词对于每个键只包含一个相等测试,如果列表有多个键,则可能存在多个相邻谓词。语法由第14节中的规则“path arg”正式定义。

The predicates are only used when more than one key reference is needed to uniquely identify a leaf instance. This occurs if a list has multiple keys or a reference to a leaf other than the key in a list is needed. In these cases, multiple leafrefs are typically specified, and predicates are used to tie them together.

谓词仅在需要多个键引用来唯一标识叶实例时使用。如果列表有多个键,或者需要对列表中键以外的叶的引用,则会发生这种情况。在这些情况下,通常会指定多个leafref,并使用谓词将它们连接在一起。

The "path" expression evaluates to a node set consisting of zero, one, or more nodes. If the "require-instance" property is "true", this node set MUST be non-empty.

“路径”表达式的计算结果是由零个、一个或多个节点组成的节点集。如果“require instance”属性为“true”,则此节点集必须为非空。

The "path" XPath expression is conceptually evaluated in the following context, in addition to the definition in Section 6.4.1:

除了第6.4.1节中的定义外,还将在以下上下文中对“path”XPath表达式进行概念性评估:

o If the "path" statement is defined within a typedef, the context node is the leaf or leaf-list node in the data tree that references the typedef.

o 如果在typedef中定义了“path”语句,则上下文节点是引用typedef的数据树中的叶或叶列表节点。

o Otherwise, the context node is the node in the data tree for which the "path" statement is defined.

o 否则,上下文节点就是为其定义“path”语句的数据树中的节点。

9.9.3. The "require-instance" Statement
9.9.3. “require instance”语句

The "require-instance" statement, which is a substatement to the "type" statement, MAY be present if the type is "instance-identifier" or "leafref". It takes as an argument the string "true" or "false". If this statement is not present, it defaults to "true".

“require instance”语句是“type”语句的子语句,如果类型是“instance identifier”或“leafref”,则可能存在该语句。它将字符串“true”或“false”作为参数。如果此语句不存在,则默认为“true”。

If "require-instance" is "true", it means that the instance being referred to MUST exist for the data to be valid. This constraint is enforced according to the rules in Section 8.

如果“require instance”为“true”,则表示引用的实例必须存在才能使数据有效。此约束根据第8节中的规则强制执行。

If "require-instance" is "false", it means that the instance being referred to MAY exist in valid data.

如果“require instance”为“false”,则表示引用的实例可能存在于有效数据中。

9.9.4. Lexical Representation
9.9.4. 词汇表征

A leafref value is lexically represented the same way as the leaf it references represents its value.

leafref值在词汇上的表示方式与其引用的叶表示其值的方式相同。

9.9.5. Canonical Form
9.9.5. 标准形

The canonical form of a leafref is the same as the canonical form of the leaf it references.

leafref的标准形式与它引用的叶的标准形式相同。

9.9.6. Usage Example
9.9.6. 用法示例

With the following list:

以下是:

     list interface {
       key "name";
       leaf name {
         type string;
       }
       leaf admin-status {
         type admin-status;
       }
       list address {
         key "ip";
         leaf ip {
           type yang:ip-address;
         }
       }
     }
        
     list interface {
       key "name";
       leaf name {
         type string;
       }
       leaf admin-status {
         type admin-status;
       }
       list address {
         key "ip";
         leaf ip {
           type yang:ip-address;
         }
       }
     }
        

the following leafref refers to an existing interface:

以下leafref引用现有接口:

     leaf mgmt-interface {
       type leafref {
         path "../interface/name";
       }
     }
        
     leaf mgmt-interface {
       type leafref {
         path "../interface/name";
       }
     }
        

An example of a corresponding XML snippet:

对应的XML代码段示例:

     <interface>
       <name>eth0</name>
     </interface>
     <interface>
       <name>lo</name>
     </interface>
        
     <interface>
       <name>eth0</name>
     </interface>
     <interface>
       <name>lo</name>
     </interface>
        
     <mgmt-interface>eth0</mgmt-interface>
        
     <mgmt-interface>eth0</mgmt-interface>
        

The following leafrefs refer to an existing address of an interface:

以下叶引用引用接口的现有地址:

     container default-address {
       leaf ifname {
         type leafref {
           path "../../interface/name";
         }
       }
       leaf address {
         type leafref {
           path "../../interface[name = current()/../ifname]"
              + "/address/ip";
         }
       }
     }
        
     container default-address {
       leaf ifname {
         type leafref {
           path "../../interface/name";
         }
       }
       leaf address {
         type leafref {
           path "../../interface[name = current()/../ifname]"
              + "/address/ip";
         }
       }
     }
        

An example of a corresponding XML snippet:

对应的XML代码段示例:

     <interface>
       <name>eth0</name>
       <admin-status>up</admin-status>
       <address>
         <ip>192.0.2.1</ip>
       </address>
       <address>
         <ip>192.0.2.2</ip>
       </address>
     </interface>
     <interface>
       <name>lo</name>
       <admin-status>up</admin-status>
       <address>
         <ip>127.0.0.1</ip>
       </address>
     </interface>
        
     <interface>
       <name>eth0</name>
       <admin-status>up</admin-status>
       <address>
         <ip>192.0.2.1</ip>
       </address>
       <address>
         <ip>192.0.2.2</ip>
       </address>
     </interface>
     <interface>
       <name>lo</name>
       <admin-status>up</admin-status>
       <address>
         <ip>127.0.0.1</ip>
       </address>
     </interface>
        
     <default-address>
       <ifname>eth0</ifname>
       <address>192.0.2.2</address>
     </default-address>
        
     <default-address>
       <ifname>eth0</ifname>
       <address>192.0.2.2</address>
     </default-address>
        

The following list uses a leafref for one of its keys. This is similar to a foreign key in a relational database.

下面的列表使用leafref作为其键之一。这类似于关系数据库中的外键。

     list packet-filter {
       key "if-name filter-id";
       leaf if-name {
         type leafref {
           path "/interface/name";
         }
       }
       leaf filter-id {
         type uint32;
       }
       ...
     }
        
     list packet-filter {
       key "if-name filter-id";
       leaf if-name {
         type leafref {
           path "/interface/name";
         }
       }
       leaf filter-id {
         type uint32;
       }
       ...
     }
        

An example of a corresponding XML snippet:

对应的XML代码段示例:

     <interface>
       <name>eth0</name>
       <admin-status>up</admin-status>
       <address>
         <ip>192.0.2.1</ip>
       </address>
       <address>
         <ip>192.0.2.2</ip>
       </address>
     </interface>
        
     <interface>
       <name>eth0</name>
       <admin-status>up</admin-status>
       <address>
         <ip>192.0.2.1</ip>
       </address>
       <address>
         <ip>192.0.2.2</ip>
       </address>
     </interface>
        
     <packet-filter>
       <if-name>eth0</if-name>
       <filter-id>1</filter-id>
       ...
     </packet-filter>
     <packet-filter>
       <if-name>eth0</if-name>
       <filter-id>2</filter-id>
       ...
     </packet-filter>
        
     <packet-filter>
       <if-name>eth0</if-name>
       <filter-id>1</filter-id>
       ...
     </packet-filter>
     <packet-filter>
       <if-name>eth0</if-name>
       <filter-id>2</filter-id>
       ...
     </packet-filter>
        

The following notification defines two leafrefs to refer to an existing admin-status:

以下通知定义了两个LeafRef以引用现有管理员状态:

     notification link-failure {
       leaf if-name {
         type leafref {
           path "/interface/name";
         }
       }
       leaf admin-status {
         type leafref {
           path "/interface[name = current()/../if-name]"
              + "/admin-status";
         }
       }
     }
        
     notification link-failure {
       leaf if-name {
         type leafref {
           path "/interface/name";
         }
       }
       leaf admin-status {
         type leafref {
           path "/interface[name = current()/../if-name]"
              + "/admin-status";
         }
       }
     }
        

An example of a corresponding XML notification:

相应的XML通知示例如下:

     <notification
       xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
       <eventTime>2008-04-01T00:01:00Z</eventTime>
       <link-failure xmlns="urn:example:system">
         <if-name>eth0</if-name>
         <admin-status>up</admin-status>
       </link-failure>
     </notification>
        
     <notification
       xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
       <eventTime>2008-04-01T00:01:00Z</eventTime>
       <link-failure xmlns="urn:example:system">
         <if-name>eth0</if-name>
         <admin-status>up</admin-status>
       </link-failure>
     </notification>
        
9.10. The identityref Built-In Type
9.10. identityref内置类型

The identityref built-in type is used to reference an existing identity (see Section 7.18).

identityref内置类型用于引用现有标识(见第7.18节)。

9.10.1. Restrictions
9.10.1. 限制

An identityref cannot be restricted.

无法限制identityref。

9.10.2. The identityref's "base" Statement
9.10.2. identityref的“base”语句

The "base" statement, which is a substatement to the "type" statement, MUST be present at least once if the type is "identityref". The argument is the name of an identity, as defined by an "identity" statement. If a prefix is present on the identity name, it refers to an identity defined in the module that was imported with that prefix. Otherwise, an identity with the matching name MUST be defined in the current module or an included submodule.

如果类型为“identityref”,则作为“type”语句的子语句的“base”语句必须至少出现一次。参数是由“identity”语句定义的标识的名称。如果标识名上存在前缀,则它指的是使用该前缀导入的模块中定义的标识。否则,必须在当前模块或包含的子模块中定义具有匹配名称的标识。

Valid values for an identityref are any identities derived from all the identityref's base identities. On a particular server, the valid values are further restricted to the set of identities defined in the modules implemented by the server.

identityref的有效值是从所有identityref的基本标识派生的任何标识。在特定服务器上,有效值进一步限制为服务器实现的模块中定义的标识集。

9.10.3. Lexical Representation
9.10.3. 词汇表征

An identityref is lexically represented as the referred identity's qualified name as defined in [XML-NAMES]. If the prefix is not present, the namespace of the identityref is the default namespace in effect on the element that contains the identityref value.

identityref在词汇上表示为[XML-NAMES]中定义的引用标识的限定名。如果前缀不存在,则identityref的命名空间是对包含identityref值的元素有效的默认命名空间。

When an identityref is given a default value using the "default" statement, the identity name in the default value MAY have a prefix. If a prefix is present on the identity name, it refers to an identity defined in the module that was imported with that prefix, or the prefix for the current module if the identity is defined in the

当使用“default”语句为identityref指定默认值时,默认值中的标识名可能有前缀。如果标识名上存在前缀,则该前缀指的是使用该前缀导入的模块中定义的标识,或者如果标识是在中定义的,则指的是当前模块的前缀

current module or one of its submodules. Otherwise, an identity with the matching name MUST be defined in the current module or one of its submodules.

当前模块或其子模块之一。否则,必须在当前模块或其子模块之一中定义具有匹配名称的标识。

The string value of a node of type "identityref" in a "must" or "when" XPath expression is the referred identity's qualified name with the prefix present. If the referred identity is defined in an imported module, the prefix in the string value is the prefix defined in the corresponding "import" statement. Otherwise, the prefix in the string value is the prefix for the current module.

“must”或“when”XPath表达式中类型为“identityref”的节点的字符串值是引用的标识的限定名,前缀为present。如果引用的标识是在导入的模块中定义的,则字符串值中的前缀是在相应的“import”语句中定义的前缀。否则,字符串值中的前缀就是当前模块的前缀。

9.10.4. Canonical Form
9.10.4. 标准形

Since the lexical form depends on the XML context in which the value occurs, this type does not have a canonical form.

由于词汇形式取决于值出现的XML上下文,因此该类型没有规范形式。

9.10.5. Usage Example
9.10.5. 用法示例

With the identity definitions in Section 7.18.3 and the following module:

使用第7.18.3节中的标识定义和以下模块:

     module example-my-crypto {
       yang-version 1.1;
       namespace "urn:example:my-crypto";
       prefix mc;
        
     module example-my-crypto {
       yang-version 1.1;
       namespace "urn:example:my-crypto";
       prefix mc;
        
       import "example-crypto-base" {
         prefix "crypto";
       }
        
       import "example-crypto-base" {
         prefix "crypto";
       }
        
       identity aes {
         base "crypto:crypto-alg";
       }
        
       identity aes {
         base "crypto:crypto-alg";
       }
        
       leaf crypto {
         type identityref {
           base "crypto:crypto-alg";
         }
       }
        
       leaf crypto {
         type identityref {
           base "crypto:crypto-alg";
         }
       }
        
       container aes-parameters {
         when "../crypto = 'mc:aes'";
         ...
       }
     }
        
       container aes-parameters {
         when "../crypto = 'mc:aes'";
         ...
       }
     }
        

the following is an example of how the leaf "crypto" can be encoded, if the value is the "des3" identity defined in the "des" module:

如果值是“des”模块中定义的“des3”标识,下面是如何对叶“crypto”进行编码的示例:

     <crypto xmlns:des="urn:example:des">des:des3</crypto>
        
     <crypto xmlns:des="urn:example:des">des:des3</crypto>
        

Any prefixes used in the encoding are local to each instance encoding. This means that the same identityref may be encoded differently by different implementations. For example, the following example encodes the same leaf as above:

编码中使用的任何前缀都是每个实例编码的本地前缀。这意味着相同的identityref可以通过不同的实现进行不同的编码。例如,以下示例对与上面相同的叶进行编码:

     <crypto xmlns:x="urn:example:des">x:des3</crypto>
        
     <crypto xmlns:x="urn:example:des">x:des3</crypto>
        

If the "crypto" leaf's value is instead "aes", defined in the "example-my-crypto" module, it can be encoded as:

如果“加密”叶的值改为“aes”(在“示例my crypto”模块中定义),则可以将其编码为:

     <crypto xmlns:mc="urn:example:my-crypto">mc:aes</crypto>
        
     <crypto xmlns:mc="urn:example:my-crypto">mc:aes</crypto>
        

or, using the default namespace:

或者,使用默认名称空间:

     <crypto>aes</crypto>
        
     <crypto>aes</crypto>
        
9.11. The empty Built-In Type
9.11. 空的内置类型

The empty built-in type represents a leaf that does not have any value; it conveys information by its presence or absence.

空的内置类型表示没有任何值的叶;它通过存在或不存在来传递信息。

An empty type cannot have a default value.

空类型不能有默认值。

9.11.1. Restrictions
9.11.1. 限制

An empty type cannot be restricted.

不能限制空类型。

9.11.2. Lexical Representation
9.11.2. 词汇表征

Not applicable.

不适用。

9.11.3. Canonical Form
9.11.3. 标准形

Not applicable.

不适用。

9.11.4. Usage Example
9.11.4. 用法示例

With the following leaf:

具有以下叶:

     leaf enable-qos {
       type empty;
     }
        
     leaf enable-qos {
       type empty;
     }
        

the following is an example of a valid encoding if the leaf exists:

以下是叶存在时有效编码的示例:

     <enable-qos/>
        
     <enable-qos/>
        
9.12. The union Built-In Type
9.12. 内置式工会

The union built-in type represents a value that corresponds to one of its member types.

union内置类型表示与其成员类型之一对应的值。

When the type is "union", the "type" statement (Section 7.4) MUST be present. It is repeatedly used to specify each member type of the union. It takes as an argument a string that is the name of a member type.

当类型为“union”时,“type”语句(第7.4节)必须存在。它反复用于指定联合的每个成员类型。它接受一个字符串作为参数,该字符串是成员类型的名称。

A member type can be of any built-in or derived type.

成员类型可以是任何内置类型或派生类型。

When generating an XML encoding, a value is encoded according to the rules of the member type to which the value belongs. When interpreting an XML encoding, a value is validated consecutively against each member type, in the order they are specified in the "type" statement, until a match is found. The type that matched will be the type of the value for the node that was validated, and the encoding is interpreted according to the rules for that type.

生成XML编码时,将根据值所属的成员类型的规则对值进行编码。解释XML编码时,将按照“type”语句中指定的顺序,针对每个成员类型连续验证一个值,直到找到匹配项。匹配的类型将是已验证节点的值的类型,编码将根据该类型的规则进行解释。

Any default value or "units" property defined in the member types is not inherited by the union type.

联合类型不会继承成员类型中定义的任何默认值或“units”属性。

9.12.1. Restrictions
9.12.1. 限制

A union cannot be restricted. However, each member type can be restricted, based on the rules defined in Section 9.

工会不能受到限制。但是,根据第9节中定义的规则,可以限制每种成员类型。

9.12.2. Lexical Representation
9.12.2. 词汇表征

The lexical representation of a union is a value that corresponds to the representation of any one of the member types.

联合的词法表示是与任何一种成员类型的表示相对应的值。

9.12.3. Canonical Form
9.12.3. 标准形

The canonical form of a union value is the same as the canonical form of the member type of the value.

联合值的标准形式与值的成员类型的标准形式相同。

9.12.4. Usage Example
9.12.4. 用法示例

The following is a union of an int32 and an enumeration:

以下是int32和枚举的并集:

     type union {
       type int32;
       type enumeration {
         enum "unbounded";
       }
     }
        
     type union {
       type int32;
       type enumeration {
         enum "unbounded";
       }
     }
        

Care must be taken when a member type is a leafref where the "require-instance" property (Section 9.9.3) is "true". If a leaf of such a type refers to an existing instance, the leaf's value must be revalidated if the target instance is deleted. For example, with the following definitions:

当成员类型为leafref,且“require instance”属性(第9.9.3节)为“true”时,必须小心。如果此类叶引用现有实例,则如果删除目标实例,则必须重新验证该叶的值。例如,使用以下定义:

     list filter {
       key name;
       leaf name {
         type string;
       }
       ...
     }
        
     list filter {
       key name;
       leaf name {
         type string;
       }
       ...
     }
        
     leaf outbound-filter {
       type union {
         type leafref {
           path "/filter/name";
         }
         type enumeration {
           enum default-filter;
         }
       }
     }
        
     leaf outbound-filter {
       type union {
         type leafref {
           path "/filter/name";
         }
         type enumeration {
           enum default-filter;
         }
       }
     }
        

assume that there exists an entry in the filter list with the name "http" and that the outbound-filter leaf has this value:

假设过滤器列表中存在一个名为“http”的条目,并且出站过滤器叶具有以下值:

     <filter>
       <name>http</name>
     </filter>
     <outbound-filter>http</outbound-filter>
        
     <filter>
       <name>http</name>
     </filter>
     <outbound-filter>http</outbound-filter>
        

If the filter entry "http" is removed, the outbound-filter leaf's value doesn't match the leafref, and the next member type is checked. The current value ("http") doesn't match the enumeration, so the resulting configuration is invalid.

如果删除了筛选器条目“http”,则出站筛选器叶的值与leafref不匹配,并检查下一个成员类型。当前值(“http”)与枚举不匹配,因此生成的配置无效。

If the second member type in the union had been of type "string" instead of an enumeration, the current value would have matched, and the resulting configuration would have been valid.

如果联合中的第二个成员类型是“string”类型而不是枚举类型,则当前值将匹配,并且生成的配置将是有效的。

9.13. The instance-identifier Built-In Type
9.13. 内置类型的实例标识符

The instance-identifier built-in type is used to uniquely identify a particular instance node in the data tree.

实例标识符内置类型用于唯一标识数据树中的特定实例节点。

The syntax for an instance-identifier is a subset of the XPath abbreviated syntax, formally defined by the rule "instance-identifier" in Section 14. It is used to uniquely identify a node in the data tree. Predicates are used only for specifying the values for the key nodes for list entries, a value of a leaf-list entry, or a positional index for a list without keys. For identifying list entries with keys, each predicate consists of one equality test per key, and each key MUST have a corresponding predicate. If a key is of type "empty", it is represented as a zero-length string ("").

实例标识符的语法是XPath缩写语法的子集,由第14节中的规则“实例标识符”正式定义。它用于唯一标识数据树中的节点。谓词仅用于指定列表项的键节点值、叶列表项的值或无键列表的位置索引。为了用键标识列表项,每个谓词由每个键的一个相等性测试组成,每个键必须有一个对应的谓词。如果键的类型为“empty”,则表示为长度为零的字符串(“”)。

If the leaf with the instance-identifier type represents configuration data and the "require-instance" property (Section 9.9.3) is "true", the node it refers to MUST also represent configuration. Such a leaf puts a constraint on valid data. All such leaf nodes MUST reference existing nodes or leaf or leaf-list nodes with their default value in use (see Sections 7.6.1 and 7.7.2) for the data to be valid. This constraint is enforced according to the rules in Section 8.

如果具有实例标识符类型的叶表示配置数据,且“require instance”属性(第9.9.3节)为“true”,则其引用的节点也必须表示配置。这样的叶子对有效数据施加了约束。所有此类叶节点必须引用现有节点或叶或叶列表节点及其默认值(见第7.6.1节和第7.7.2节),以使数据有效。此约束根据第8节中的规则强制执行。

The "instance-identifier" XPath expression is conceptually evaluated in the following context, in addition to the definition in Section 6.4.1:

除了第6.4.1节中的定义外,“实例标识符”XPath表达式在以下上下文中进行概念性评估:

o The context node is the root node in the accessible tree.

o 上下文节点是可访问树中的根节点。

9.13.1. Restrictions
9.13.1. 限制

An instance-identifier can be restricted with the "require-instance" statement (Section 9.9.3).

实例标识符可以通过“require instance”语句进行限制(第9.9.3节)。

9.13.2. Lexical Representation
9.13.2. 词汇表征

An instance-identifier value is lexically represented as a string. All node names in an instance-identifier value MUST be qualified with explicit namespace prefixes, and these prefixes MUST be declared in the XML namespace scope in the instance-identifier's XML element.

实例标识符值在词汇上表示为字符串。实例标识符值中的所有节点名称都必须使用显式命名空间前缀限定,并且这些前缀必须在实例标识符的XML元素的XML命名空间范围中声明。

Any prefixes used in the encoding are local to each instance encoding. This means that the same instance-identifier may be encoded differently by different implementations.

编码中使用的任何前缀都是每个实例编码的本地前缀。这意味着相同的实例标识符可以通过不同的实现进行不同的编码。

9.13.3. Canonical Form
9.13.3. 标准形

Since the lexical form depends on the XML context in which the value occurs, this type does not have a canonical form.

由于词汇形式取决于值出现的XML上下文,因此该类型没有规范形式。

9.13.4. Usage Example
9.13.4. 用法示例

The following are examples of instance identifiers:

以下是实例标识符的示例:

     /* instance-identifier for a container */
     /ex:system/ex:services/ex:ssh
        
     /* instance-identifier for a container */
     /ex:system/ex:services/ex:ssh
        
     /* instance-identifier for a leaf */
     /ex:system/ex:services/ex:ssh/ex:port
        
     /* instance-identifier for a leaf */
     /ex:system/ex:services/ex:ssh/ex:port
        
     /* instance-identifier for a list entry */
     /ex:system/ex:user[ex:name='fred']
        
     /* instance-identifier for a list entry */
     /ex:system/ex:user[ex:name='fred']
        
     /* instance-identifier for a leaf in a list entry */
     /ex:system/ex:user[ex:name='fred']/ex:type
        
     /* instance-identifier for a leaf in a list entry */
     /ex:system/ex:user[ex:name='fred']/ex:type
        
     /* instance-identifier for a list entry with two keys */
     /ex:system/ex:server[ex:ip='192.0.2.1'][ex:port='80']
        
     /* instance-identifier for a list entry with two keys */
     /ex:system/ex:server[ex:ip='192.0.2.1'][ex:port='80']
        
     /* instance-identifier for a list entry where the second
        key ("enabled") is of type "empty" */
     /ex:system/ex:service[ex:name='foo'][ex:enabled='']
        
     /* instance-identifier for a list entry where the second
        key ("enabled") is of type "empty" */
     /ex:system/ex:service[ex:name='foo'][ex:enabled='']
        
     /* instance-identifier for a leaf-list entry */
     /ex:system/ex:services/ex:ssh/ex:cipher[.='blowfish-cbc']
        
     /* instance-identifier for a leaf-list entry */
     /ex:system/ex:services/ex:ssh/ex:cipher[.='blowfish-cbc']
        
     /* instance-identifier for a list entry without keys */
     /ex:stats/ex:port[3]
        
     /* instance-identifier for a list entry without keys */
     /ex:stats/ex:port[3]
        
10. XPath Functions
10. XPath函数

This document defines two generic XPath functions and five YANG type-specific XPath functions. The function signatures are specified with the syntax used in [XPATH].

本文档定义了两个通用XPath函数和五个特定于类型的XPath函数。函数签名是使用[XPATH]中使用的语法指定的。

10.1. Function for Node Sets
10.1. 节点集函数
10.1.1. current()
10.1.1. 当前()

node-set current()

节点集当前值()

The current() function takes no input parameters and returns a node set with the initial context node as its only member.

current()函数不接受任何输入参数,并返回一个节点集,其中初始上下文节点是其唯一成员。

10.1.1.1. Usage Example
10.1.1.1. 用法示例

With this list:

在此列表中:

     list interface {
       key "name";
       ...
       leaf enabled {
         type boolean;
       }
       ...
     }
        
     list interface {
       key "name";
       ...
       leaf enabled {
         type boolean;
       }
       ...
     }
        

the following leaf defines a "must" expression that ensures that the referred interface is enabled:

以下叶定义了一个“必须”表达式,以确保启用引用的接口:

     leaf outgoing-interface {
       type leafref {
         path "/interface/name";
       }
       must '/interface[name=current()]/enabled = "true"';
     }
        
     leaf outgoing-interface {
       type leafref {
         path "/interface/name";
       }
       must '/interface[name=current()]/enabled = "true"';
     }
        
10.2. Function for Strings
10.2. 字符串函数
10.2.1. re-match()
10.2.1. 重新匹配()

boolean re-match(string subject, string pattern)

布尔值重新匹配(字符串主题、字符串模式)

The re-match() function returns "true" if the "subject" string matches the regular expression "pattern"; otherwise, it returns "false".

如果“subject”字符串与正则表达式“pattern”匹配,则re-match()函数返回“true”;否则,它将返回“false”。

The re-match() function checks to see if a string matches a given regular expression. The regular expressions used are the XML Schema regular expressions [XSD-TYPES]. Note that this includes implicit anchoring of the regular expression at the head and tail.

函数的作用是:检查字符串是否与给定的正则表达式匹配。使用的正则表达式是XML模式正则表达式[XSD-TYPES]。注意,这包括正则表达式在头部和尾部的隐式锚定。

10.2.1.1. Usage Example
10.2.1.1. 用法示例

The expression:

表达方式:

     re-match("1.22.333", "\d{1,3}\.\d{1,3}\.\d{1,3}")
        
     re-match("1.22.333", "\d{1,3}\.\d{1,3}\.\d{1,3}")
        

returns "true".

返回“true”。

To count all logical interfaces called eth0.<number>, do:

要统计所有名为eth0的逻辑接口,请执行以下操作:

     count(/interface[re-match(name, "eth0\.\d+")])
        
     count(/interface[re-match(name, "eth0\.\d+")])
        
10.3. Function for the YANG Types "leafref" and "instance-identifier"
10.3. 用于类型“leafref”和“实例标识符”的函数
10.3.1. deref()
10.3.1. 德里夫()

node-set deref(node-set nodes)

节点集deref(节点集节点)

The deref() function follows the reference defined by the first node in document order in the argument "nodes" and returns the nodes it refers to.

函数的作用是:根据参数“nodes”中文档顺序的第一个节点定义的引用,返回它引用的节点。

If the first argument node is of type "instance-identifier", the function returns a node set that contains the single node that the instance identifier refers to, if it exists. If no such node exists, an empty node set is returned.

如果第一个参数节点的类型为“实例标识符”,则函数返回一个节点集,该节点集包含实例标识符引用的单个节点(如果存在)。如果不存在这样的节点,则返回一个空节点集。

If the first argument node is of type "leafref", the function returns a node set that contains the nodes that the leafref refers to. Specifically, this set contains the nodes selected by the leafref's "path" statement (Section 9.9.2) that have the same value as the first argument node.

如果第一个参数节点的类型为“leafref”,则函数将返回一个节点集,其中包含leafref引用的节点。具体而言,此集合包含由leafref的“path”语句(第9.9.2节)选择的节点,这些节点的值与第一个参数节点的值相同。

If the first argument node is of any other type, an empty node set is returned.

如果第一个参数节点属于任何其他类型,则返回空节点集。

10.3.1.1. Usage Example
10.3.1.1. 用法示例
     list interface {
       key "name type";
       leaf name { ... }
       leaf type { ... }
       leaf enabled {
         type boolean;
       }
       ...
     }
        
     list interface {
       key "name type";
       leaf name { ... }
       leaf type { ... }
       leaf enabled {
         type boolean;
       }
       ...
     }
        
     container mgmt-interface {
       leaf name {
         type leafref {
           path "/interface/name";
         }
       }
       leaf type {
         type leafref {
           path "/interface[name=current()/../name]/type";
         }
         must 'deref(.)/../enabled = "true"' {
           error-message
             "The management interface cannot be disabled.";
         }
       }
     }
        
     container mgmt-interface {
       leaf name {
         type leafref {
           path "/interface/name";
         }
       }
       leaf type {
         type leafref {
           path "/interface[name=current()/../name]/type";
         }
         must 'deref(.)/../enabled = "true"' {
           error-message
             "The management interface cannot be disabled.";
         }
       }
     }
        
10.4. Functions for the YANG Type "identityref"
10.4. 用于YANG类型“identityref”的函数
10.4.1. derived-from()
10.4.1. 派生自

boolean derived-from(node-set nodes, string identity)

从(节点集节点、字符串标识)派生的布尔值

The derived-from() function returns "true" if any node in the argument "nodes" is a node of type "identityref" and its value is an identity that is derived from (see Section 7.18.2) the identity "identity"; otherwise, it returns "false".

如果参数“nodes”中的任何节点是“identityref”类型的节点,并且其值是从标识“identity”派生的标识(参见第7.18.2节),则派生自()函数返回“true”;否则,它将返回“false”。

The parameter "identity" is a string matching the rule "identifier-ref" in Section 14. If a prefix is present on the identity, it refers to an identity defined in the module that was imported with that prefix, or the local module if the prefix matches the local module's prefix. If no prefix is present, the identity refers to an identity defined in the current module or an included submodule.

参数“identity”是与第14节中的规则“identifier ref”匹配的字符串。如果标识上存在前缀,则它指的是使用该前缀导入的模块中定义的标识,如果前缀与本地模块的前缀匹配,则指的是本地模块。如果不存在前缀,则标识引用当前模块或包含的子模块中定义的标识。

10.4.1.1. Usage Example
10.4.1.1. 用法示例
     module example-interface {
       yang-version 1.1;
        
     module example-interface {
       yang-version 1.1;
        

... identity interface-type;

... 身份接口类型;

       identity ethernet {
         base interface-type;
       }
        
       identity ethernet {
         base interface-type;
       }
        
       identity fast-ethernet {
         base ethernet;
       }
        
       identity fast-ethernet {
         base ethernet;
       }
        
       identity gigabit-ethernet {
         base ethernet;
       }
        
       identity gigabit-ethernet {
         base ethernet;
       }
        
       list interface {
         key name;
         ...
         leaf type {
           type identityref {
             base interface-type;
           }
         }
         ...
       }
        
       list interface {
         key name;
         ...
         leaf type {
           type identityref {
             base interface-type;
           }
         }
         ...
       }
        
       augment "/interface" {
         when 'derived-from(type, "exif:ethernet")';
         // generic Ethernet definitions here
       }
       ...
     }
        
       augment "/interface" {
         when 'derived-from(type, "exif:ethernet")';
         // generic Ethernet definitions here
       }
       ...
     }
        
10.4.2. derived-from-or-self()
10.4.2. 派生自或自()

boolean derived-from-or-self(node-set nodes, string identity)

从或自身派生的布尔值(节点集节点、字符串标识)

The derived-from-or-self() function returns "true" if any node in the argument "nodes" is a node of type "identityref" and its value is an identity that is equal to or derived from (see Section 7.18.2) the identity "identity"; otherwise, it returns "false".

如果参数“nodes”中的任何节点是“identityref”类型的节点,且其值是等于或派生自标识“identity”的标识(见第7.18.2节),则派生自或self()函数返回“true”;否则,它将返回“false”。

The parameter "identity" is a string matching the rule "identifier-ref" in Section 14. If a prefix is present on the identity, it refers to an identity defined in the module that was imported with that prefix, or the local module if the prefix matches the local module's prefix. If no prefix is present, the identity refers to an identity defined in the current module or an included submodule.

参数“identity”是与第14节中的规则“identifier ref”匹配的字符串。如果标识上存在前缀,则它指的是使用该前缀导入的模块中定义的标识,如果前缀与本地模块的前缀匹配,则指的是本地模块。如果不存在前缀,则标识引用当前模块或包含的子模块中定义的标识。

10.4.2.1. Usage Example
10.4.2.1. 用法示例

The module defined in Section 10.4.1.1 might also have:

第10.4.1.1节中定义的模块也可能具有:

       augment "/interface" {
         when 'derived-from-or-self(type, "exif:fast-ethernet");
         // Fast-Ethernet-specific definitions here
       }
        
       augment "/interface" {
         when 'derived-from-or-self(type, "exif:fast-ethernet");
         // Fast-Ethernet-specific definitions here
       }
        
10.5. Function for the YANG Type "enumeration"
10.5. 用于YANG类型“枚举”的函数
10.5.1. enum-value()
10.5.1. 枚举值()

number enum-value(node-set nodes)

编号枚举值(节点集节点)

The enum-value() function checks to see if the first node in document order in the argument "nodes" is a node of type "enumeration" and returns the enum's integer value. If the "nodes" node set is empty or if the first node in "nodes" is not of type "enumeration", it returns NaN (not a number).

函数的作用是:检查参数“nodes”中文档顺序中的第一个节点是否为“enumeration”类型的节点,并返回枚举的整数值。如果“节点”节点集为空或“节点”中的第一个节点不是“枚举”类型,则返回NaN(不是数字)。

10.5.1.1. Usage Example
10.5.1.1. 用法示例

With this data model:

使用此数据模型:

     list alarm {
       ...
       leaf severity {
         type enumeration {
           enum cleared {
             value 1;
           }
           enum indeterminate {
             value 2;
           }
           enum minor {
             value 3;
           }
           enum warning {
             value 4;
           }
           enum major {
             value 5;
           }
           enum critical {
             value 6;
           }
         }
       }
     }
        
     list alarm {
       ...
       leaf severity {
         type enumeration {
           enum cleared {
             value 1;
           }
           enum indeterminate {
             value 2;
           }
           enum minor {
             value 3;
           }
           enum warning {
             value 4;
           }
           enum major {
             value 5;
           }
           enum critical {
             value 6;
           }
         }
       }
     }
        

the following XPath expression selects only alarms that are of severity "major" or higher:

以下XPath表达式仅选择严重性为“严重”或更高的报警:

     /alarm[enum-value(severity) >= 5]
        
     /alarm[enum-value(severity) >= 5]
        
10.6. Function for the YANG Type "bits"
10.6. 阳型“位”的功能
10.6.1. bit-is-set()
10.6.1. bit-is-set()

boolean bit-is-set(node-set nodes, string bit-name)

已设置布尔位(节点集节点、字符串位名称)

The bit-is-set() function returns "true" if the first node in document order in the argument "nodes" is a node of type "bits" and its value has the bit "bit-name" set; otherwise, it returns "false".

如果参数“nodes”中文档顺序中的第一个节点是“bits”类型的节点,并且其值设置了位“bit name”,则bit-is-set()函数返回“true”;否则,它将返回“false”。

10.6.1.1. Usage Example
10.6.1.1. 用法示例

If an interface has this leaf:

如果接口具有此叶:

     leaf flags {
       type bits {
         bit UP;
         bit PROMISCUOUS
         bit DISABLED;
       }
      }
        
     leaf flags {
       type bits {
         bit UP;
         bit PROMISCUOUS
         bit DISABLED;
       }
      }
        

the following XPath expression can be used to select all interfaces with the UP flag set:

以下XPath表达式可用于选择设置了UP标志的所有接口:

/interface[bit-is-set(flags, "UP")]

/接口[位已设置(标志“向上”)]

11. Updating a Module
11. 更新模块

As experience is gained with a module, it may be desirable to revise that module. However, changes to published modules are not allowed if they have any potential to cause interoperability problems between a client using an original specification and a server using an updated specification.

由于从一个模块中获得了经验,因此可能需要修改该模块。但是,如果对已发布模块的更改可能导致使用原始规范的客户端和使用更新规范的服务器之间的互操作性问题,则不允许对这些模块进行更改。

For any published change, a new "revision" statement (Section 7.1.9) MUST be included in front of the existing "revision" statements. If there are no existing "revision" statements, then one MUST be added to identify the new revision. Furthermore, any necessary changes MUST be applied to any metadata statements, including the "organization" and "contact" statements (Sections 7.1.7 and 7.1.8).

对于任何已发布的变更,必须在现有“修订”声明之前包含新的“修订”声明(第7.1.9节)。如果没有现有的“修订”声明,则必须添加一个以标识新修订。此外,任何必要的更改必须应用于任何元数据语句,包括“组织”和“联系人”语句(第7.1.7节和第7.1.8节)。

Note that definitions contained in a module are available to be imported by any other module and are referenced in "import" statements via the module name. Thus, a module name MUST NOT be changed. Furthermore, the "namespace" statement MUST NOT be changed, since all XML elements are qualified by the namespace.

请注意,模块中包含的定义可由任何其他模块导入,并通过模块名称在“导入”语句中引用。因此,模块名称不得更改。此外,“namespace”语句不能更改,因为所有XML元素都由名称空间限定。

Obsolete definitions MUST NOT be removed from published modules, since their identifiers may still be referenced by other modules.

不能从已发布的模块中删除过时的定义,因为它们的标识符仍可能被其他模块引用。

A definition in a published module may be revised in any of the following ways:

已发布模块中的定义可通过以下任何方式进行修订:

o An "enumeration" type may have new enums added, provided the old enums's values do not change. Note that inserting a new enum before an existing enum or reordering existing enums will result in new values for the existing enums, unless they have explicit values assigned to them.

o “枚举”类型可以添加新的枚举,前提是旧枚举的值不变。请注意,在现有枚举之前插入新枚举或对现有枚举重新排序将为现有枚举生成新值,除非已为其指定显式值。

o A "bits" type may have new bits added, provided the old bit positions do not change. Note that inserting a new bit before an existing bit or reordering existing bits will result in new positions for the existing bits, unless they have explicit positions assigned to them.

o “位”类型可以添加新位,前提是旧位位置不变。请注意,在现有位之前插入新位或对现有位重新排序将导致现有位的新位置,除非已为其指定显式位置。

o A "range", "length", or "pattern" statement may expand the allowed value space.

o “range”、“length”或“pattern”语句可以扩展允许的值空间。

o A "default" statement may be added to a leaf that does not have a default value (either directly or indirectly through its type).

o “default”语句可以添加到没有默认值(直接或通过其类型间接)的叶中。

o A "units" statement may be added.

o 可以添加“单位”语句。

o A "reference" statement may be added or updated.

o 可以添加或更新“参考”声明。

o A "must" statement may be removed or its constraint relaxed.

o 可以删除“必须”语句或放松其约束。

o A "when" statement may be removed or its constraint relaxed.

o 可以删除“when”语句或放松其约束。

o A "mandatory" statement may be removed or changed from "true" to "false".

o “强制性”声明可以删除或从“真”改为“假”。

o A "min-elements" statement may be removed, or changed to require fewer elements.

o “min elements”语句可以删除,也可以更改为需要更少的元素。

o A "max-elements" statement may be removed, or changed to allow more elements.

o “max elements”语句可以删除,也可以更改以允许更多元素。

o A "description" statement may be added or changed without changing the semantics of the definition.

o 在不改变定义语义的情况下,可以添加或更改“description”语句。

o A "base" statement may be added to an "identity" statement.

o “base”语句可以添加到“identity”语句中。

o A "base" statement may be removed from an "identityref" type, provided there is at least one "base" statement left.

o 可以从“identityref”类型中删除“base”语句,前提是至少剩下一个“base”语句。

o New typedefs, groupings, rpcs, notifications, extensions, features, and identities may be added.

o 可以添加新的类型定义、分组、RPC、通知、扩展、功能和标识。

o New data definition statements may be added if they do not add mandatory nodes (Section 3) to existing nodes or at the top level in a module or submodule, or if they are conditionally dependent on a new feature (i.e., have an "if-feature" statement that refers to a new feature).

o 如果新的数据定义语句没有向现有节点或模块或子模块的顶层添加强制节点(第3节),或者如果它们有条件地依赖于新特性(即,具有引用新特性的“如果特性”语句),则可以添加新的数据定义语句。

o A new "case" statement may be added.

o 可以添加新的“案例”陈述。

o A node that represented state data may be changed to represent configuration, provided it is not mandatory (Section 3).

o 表示状态数据的节点可以更改为表示配置,前提是它不是强制性的(第3节)。

o An "if-feature" statement may be removed, provided its node is not mandatory (Section 3).

o “如果特征”语句可以删除,前提是其节点不是强制性的(第3节)。

o A "status" statement may be added, or changed from "current" to "deprecated" or "obsolete", or changed from "deprecated" to "obsolete".

o 可以添加“状态”语句,或将其从“当前”更改为“已弃用”或“过时”,或将其从“已弃用”更改为“过时”。

o A "type" statement may be replaced with another "type" statement that does not change the syntax or semantics of the type. For example, an inline type definition may be replaced with a typedef, but an int8 type cannot be replaced by an int16, since the syntax would change.

o “type”语句可以替换为另一个“type”语句,该语句不会更改该类型的语法或语义。例如,内联类型定义可以替换为typedef,但int8类型不能替换为int16,因为语法会发生变化。

o Any set of data definition nodes may be replaced with another set of syntactically and semantically equivalent nodes. For example, a set of leafs may be replaced by a "uses" statement of a grouping with the same leafs.

o 任何一组数据定义节点都可以用另一组语法和语义上等价的节点来替换。例如,一组leaf可以替换为具有相同leaf的分组的“uses”语句。

o A module may be split into a set of submodules or a submodule may be removed, provided the definitions in the module do not change in any way other than those allowed here.

o 一个模块可以拆分为一组子模块,或者可以删除一个子模块,前提是该模块中的定义不会以此处允许的方式以外的任何方式发生更改。

o The "prefix" statement may be changed, provided all local uses of the prefix are also changed.

o “prefix”语句可能会更改,前提是前缀的所有本地使用也会更改。

Otherwise, if the semantics of any previous definition are changed (i.e., if a non-editorial change is made to any definition other than those specifically allowed above), then this MUST be achieved by a new definition with a new identifier.

否则,如果更改了任何先前定义的语义(即,如果对除上述明确允许的定义以外的任何定义进行了非编辑性更改),则必须通过使用新标识符的新定义来实现。

In statements that have any data definition statements as substatements, those data definition substatements MUST NOT be reordered. If new data definition statements are added, they can be added anywhere in the sequence of existing substatements.

在将任何数据定义语句作为子语句的语句中,不得对这些数据定义子语句重新排序。如果添加了新的数据定义语句,则可以将它们添加到现有子语句序列中的任何位置。

12. Coexistence with YANG Version 1
12. 与杨共存第1版

A YANG version 1.1 module MUST NOT include a YANG version 1 submodule, and a YANG version 1 module MUST NOT include a YANG version 1.1 submodule.

YANG版本1.1模块不得包含YANG版本1子模块,YANG版本1模块不得包含YANG版本1.1子模块。

A YANG version 1 module or submodule MUST NOT import a YANG version 1.1 module by revision.

YANG版本1模块或子模块不得通过修订导入YANG版本1.1模块。

A YANG version 1.1 module or submodule MAY import a YANG version 1 module by revision.

YANG版本1.1模块或子模块可以通过修订版导入YANG版本1模块。

If a YANG version 1 module A imports module B without revision and module B is updated to YANG version 1.1, a server MAY implement both of these modules (A and B) at the same time. In such cases, a NETCONF server MUST advertise both modules using the rules defined in Section 5.6.4, and SHOULD advertise module A and the latest revision of module B that is specified with YANG version 1 according to the rules defined in [RFC6020].

如果YANG版本1模块a未经修订就导入模块B,并且模块B更新为YANG版本1.1,则服务器可能同时实现这两个模块(a和B)。在这种情况下,NETCONF服务器必须使用第5.6.4节中定义的规则发布这两个模块,并应根据[RFC6020]中定义的规则发布模块a和模块B的最新版本,该版本由YANG版本1指定。

This rule exists in order to allow implementations of existing YANG version 1 modules together with YANG version 1.1 modules. Without this rule, updating a single module to YANG version 1.1 would have a cascading effect on modules that import it, requiring all of them to also be updated to YANG version 1.1, and so on.

此规则的存在是为了允许现有的YANG版本1模块与YANG版本1.1模块一起实现。如果没有这个规则,将单个模块更新到YANG版本1.1会对导入它的模块产生级联效应,要求所有模块也更新到YANG版本1.1,以此类推。

13. YIN
13. 尹

A YANG module can be translated into an alternative XML-based syntax called YIN. The translated module is called a YIN module. This section describes bidirectional mapping rules between the two formats.

YANG模块可以转换为另一种基于XML的语法,称为YIN。翻译后的模块称为阴模块。本节介绍两种格式之间的双向映射规则。

The YANG and YIN formats contain equivalent information using different notations. The YIN notation enables developers to represent YANG data models in XML and therefore use the rich set of XML-based tools for data filtering and validation, automated generation of code and documentation, and other tasks. Tools like XSLT or XML validators can be utilized.

阳和阴格式包含使用不同符号的等效信息。YIN符号使开发人员能够用XML表示YANG数据模型,从而使用丰富的基于XML的工具集进行数据过滤和验证、代码和文档的自动生成以及其他任务。可以使用XSLT或XML验证器等工具。

The mapping between YANG and YIN does not modify the information content of the model. Comments and whitespace are not preserved.

阳与阴之间的映射不会修改模型的信息内容。注释和空白不保留。

13.1. Formal YIN Definition
13.1. 形式阴定义

There is a one-to-one correspondence between YANG keywords and YIN elements. The local name of a YIN element is identical to the corresponding YANG keyword. This means, in particular, that the document element (root) of a YIN document is always <module> or <submodule>.

阳关键词和阴元素之间有一对一的对应关系。阴元素的本地名称与对应的阳关键字相同。这特别意味着,YIN文档的文档元素(根)总是<module>或<submodule>。

YIN elements corresponding to the YANG keywords belong to the namespace whose associated URI is "urn:ietf:params:xml:ns:yang:yin:1".

与YANG关键字对应的YIN元素属于名称空间,其关联URI为“urn:ietf:params:xml:ns:YANG:YIN:1”。

YIN elements corresponding to extension keywords belong to the namespace of the YANG module where the extension keyword is declared via the "extension" statement.

与扩展关键字对应的YIN元素属于YANG模块的名称空间,在该名称空间中,扩展关键字通过“extension”语句声明。

The names of all YIN elements MUST be properly qualified with their namespaces (as specified above) using the standard mechanisms of [XML-NAMES], i.e., "xmlns" and "xmlns:xxx" attributes.

所有YIN元素的名称必须使用[XML-names]的标准机制,即“xmlns”和“xmlns:xxx”属性,使用它们的名称空间(如上所述)进行适当限定。

The argument of a YANG statement is represented in YIN as either an XML attribute or a subelement of the keyword element. Table 1 defines the mapping for the set of YANG keywords. For extensions, the argument mapping is specified within the "extension" statement (see Section 7.19). The following rules hold for arguments:

YANG语句的参数用YIN表示为XML属性或keyword元素的子元素。表1定义了YANG关键字集的映射。对于扩展,参数映射在“extension”语句中指定(参见第7.19节)。以下规则适用于参数:

o If the argument is represented as an attribute, this attribute has no namespace.

o 如果参数表示为属性,则此属性没有命名空间。

o If the argument is represented as an element, it is qualified by the same namespace as its parent keyword element.

o 如果参数表示为一个元素,则它由与其父关键字元素相同的命名空间限定。

o If the argument is represented as an element, it MUST be the first child of the keyword element.

o 如果参数表示为元素,则它必须是关键字元素的第一个子元素。

Substatements of a YANG statement are represented as (additional) children of the keyword element, and their relative order MUST be the same as the order of substatements in YANG.

YANG语句的子语句表示为关键字元素的(附加)子语句,它们的相对顺序必须与YANG语句中的子语句顺序相同。

Comments in YANG MAY be mapped to XML comments.

YANG中的注释可以映射到XML注释。

            +------------------+---------------+-------------+
            | keyword          | argument name | yin-element |
            +------------------+---------------+-------------+
            | action           | name          | false       |
            | anydata          | name          | false       |
            | anyxml           | name          | false       |
            | argument         | name          | false       |
            | augment          | target-node   | false       |
            | base             | name          | false       |
            | belongs-to       | module        | false       |
            | bit              | name          | false       |
            | case             | name          | false       |
            | choice           | name          | false       |
            | config           | value         | false       |
            | contact          | text          | true        |
            | container        | name          | false       |
            | default          | value         | false       |
            | description      | text          | true        |
            | deviate          | value         | false       |
            | deviation        | target-node   | false       |
            | enum             | name          | false       |
            | error-app-tag    | value         | false       |
            | error-message    | value         | true        |
            | extension        | name          | false       |
            | feature          | name          | false       |
            | fraction-digits  | value         | false       |
            | grouping         | name          | false       |
            | identity         | name          | false       |
            | if-feature       | name          | false       |
            | import           | module        | false       |
            | include          | module        | false       |
            | input            | <no argument> | n/a         |
            | key              | value         | false       |
            | leaf             | name          | false       |
            | leaf-list        | name          | false       |
            | length           | value         | false       |
            | list             | name          | false       |
            | mandatory        | value         | false       |
            | max-elements     | value         | false       |
            | min-elements     | value         | false       |
            | modifier         | value         | false       |
            | module           | name          | false       |
            | must             | condition     | false       |
            | namespace        | uri           | false       |
            | notification     | name          | false       |
            | ordered-by       | value         | false       |
            | organization     | text          | true        |
            | output           | <no argument> | n/a         |
        
            +------------------+---------------+-------------+
            | keyword          | argument name | yin-element |
            +------------------+---------------+-------------+
            | action           | name          | false       |
            | anydata          | name          | false       |
            | anyxml           | name          | false       |
            | argument         | name          | false       |
            | augment          | target-node   | false       |
            | base             | name          | false       |
            | belongs-to       | module        | false       |
            | bit              | name          | false       |
            | case             | name          | false       |
            | choice           | name          | false       |
            | config           | value         | false       |
            | contact          | text          | true        |
            | container        | name          | false       |
            | default          | value         | false       |
            | description      | text          | true        |
            | deviate          | value         | false       |
            | deviation        | target-node   | false       |
            | enum             | name          | false       |
            | error-app-tag    | value         | false       |
            | error-message    | value         | true        |
            | extension        | name          | false       |
            | feature          | name          | false       |
            | fraction-digits  | value         | false       |
            | grouping         | name          | false       |
            | identity         | name          | false       |
            | if-feature       | name          | false       |
            | import           | module        | false       |
            | include          | module        | false       |
            | input            | <no argument> | n/a         |
            | key              | value         | false       |
            | leaf             | name          | false       |
            | leaf-list        | name          | false       |
            | length           | value         | false       |
            | list             | name          | false       |
            | mandatory        | value         | false       |
            | max-elements     | value         | false       |
            | min-elements     | value         | false       |
            | modifier         | value         | false       |
            | module           | name          | false       |
            | must             | condition     | false       |
            | namespace        | uri           | false       |
            | notification     | name          | false       |
            | ordered-by       | value         | false       |
            | organization     | text          | true        |
            | output           | <no argument> | n/a         |
        
            | path             | value         | false       |
            | pattern          | value         | false       |
            | position         | value         | false       |
            | prefix           | value         | false       |
            | presence         | value         | false       |
            | range            | value         | false       |
            | reference        | text          | true        |
            | refine           | target-node   | false       |
            | require-instance | value         | false       |
            | revision         | date          | false       |
            | revision-date    | date          | false       |
            | rpc              | name          | false       |
            | status           | value         | false       |
            | submodule        | name          | false       |
            | type             | name          | false       |
            | typedef          | name          | false       |
            | unique           | tag           | false       |
            | units            | name          | false       |
            | uses             | name          | false       |
            | value            | value         | false       |
            | when             | condition     | false       |
            | yang-version     | value         | false       |
            | yin-element      | value         | false       |
            +------------------+---------------+-------------+
        
            | path             | value         | false       |
            | pattern          | value         | false       |
            | position         | value         | false       |
            | prefix           | value         | false       |
            | presence         | value         | false       |
            | range            | value         | false       |
            | reference        | text          | true        |
            | refine           | target-node   | false       |
            | require-instance | value         | false       |
            | revision         | date          | false       |
            | revision-date    | date          | false       |
            | rpc              | name          | false       |
            | status           | value         | false       |
            | submodule        | name          | false       |
            | type             | name          | false       |
            | typedef          | name          | false       |
            | unique           | tag           | false       |
            | units            | name          | false       |
            | uses             | name          | false       |
            | value            | value         | false       |
            | when             | condition     | false       |
            | yang-version     | value         | false       |
            | yin-element      | value         | false       |
            +------------------+---------------+-------------+
        

Table 1: Mapping of Arguments of the YANG Statements

表1:YANG语句的参数映射

13.1.1. Usage Example
13.1.1. 用法示例

The following YANG module:

以下模块:

     module example-foo {
       yang-version 1.1;
       namespace "urn:example:foo";
       prefix "foo";
        
     module example-foo {
       yang-version 1.1;
       namespace "urn:example:foo";
       prefix "foo";
        
       import example-extensions {
         prefix "myext";
       }
        
       import example-extensions {
         prefix "myext";
       }
        
       list interface {
         key "name";
         leaf name {
           type string;
         }
        
       list interface {
         key "name";
         leaf name {
           type string;
         }
        
         leaf mtu {
           type uint32;
           description "The MTU of the interface.";
           myext:c-define "MY_MTU";
         }
       }
     }
        
         leaf mtu {
           type uint32;
           description "The MTU of the interface.";
           myext:c-define "MY_MTU";
         }
       }
     }
        

where the extension "c-define" is defined in Section 7.19.3, is translated into the following YIN:

如果第7.19.3节中定义了扩展名“c-define”,则将其翻译为:

     <module name="example-foo"
             xmlns="urn:ietf:params:xml:ns:yang:yin:1"
             xmlns:foo="urn:example:foo"
             xmlns:myext="urn:example:extensions">
        
     <module name="example-foo"
             xmlns="urn:ietf:params:xml:ns:yang:yin:1"
             xmlns:foo="urn:example:foo"
             xmlns:myext="urn:example:extensions">
        
       <namespace uri="urn:example:foo"/>
       <prefix value="foo"/>
        
       <namespace uri="urn:example:foo"/>
       <prefix value="foo"/>
        
       <import module="example-extensions">
         <prefix value="myext"/>
       </import>
        
       <import module="example-extensions">
         <prefix value="myext"/>
       </import>
        
       <list name="interface">
         <key value="name"/>
         <leaf name="name">
           <type name="string"/>
         </leaf>
         <leaf name="mtu">
           <type name="uint32"/>
           <description>
             <text>The MTU of the interface.</text>
           </description>
           <myext:c-define name="MY_MTU"/>
         </leaf>
       </list>
     </module>
        
       <list name="interface">
         <key value="name"/>
         <leaf name="name">
           <type name="string"/>
         </leaf>
         <leaf name="mtu">
           <type name="uint32"/>
           <description>
             <text>The MTU of the interface.</text>
           </description>
           <myext:c-define name="MY_MTU"/>
         </leaf>
       </list>
     </module>
        
14. YANG ABNF Grammar
14. 杨氏语法

In YANG, almost all statements are unordered. The ABNF grammar [RFC5234] [RFC7405] defines the canonical order. To improve module readability, it is RECOMMENDED that clauses be entered in this order.

在杨,几乎所有的陈述都是无序的。ABNF语法[RFC5234][RFC7405]定义了规范顺序。为了提高模块的可读性,建议按此顺序输入子句。

Within the ABNF grammar, unordered statements are marked with comments.

在ABNF语法中,无序语句用注释标记。

This grammar assumes that the scanner replaces YANG comments with a single space character.

此语法假定扫描程序使用单个空格字符替换注释。

<CODE BEGINS> file "yang.abnf"

<CODE start>文件“yang.abnf”

module-stmt = optsep module-keyword sep identifier-arg-str optsep "{" stmtsep module-header-stmts linkage-stmts meta-stmts revision-stmts body-stmts "}" optsep

模块stmt=optsep模块关键字sep标识符arg str optsep“{”stmtsep模块头stmts链接stmts元stmts修订stmts正文stmts“}”optsep

submodule-stmt = optsep submodule-keyword sep identifier-arg-str optsep "{" stmtsep submodule-header-stmts linkage-stmts meta-stmts revision-stmts body-stmts "}" optsep

子模块stmt=optsep子模块关键字sep标识符arg str optsep“{”stmtsep子模块头stmts链接stmts元stmts修订stmts正文stmts“}”optsep

module-header-stmts = ;; these stmts can appear in any order yang-version-stmt namespace-stmt prefix-stmt

模块头stmts=;;这些stmt可以以任何顺序出现在版本stmt namespace stmt prefix stmt中

submodule-header-stmts = ;; these stmts can appear in any order yang-version-stmt belongs-to-stmt

子模块头stmts=;;这些stmt可以以stmt所属的任何顺序出现

   meta-stmts          = ;; these stmts can appear in any order
                         [organization-stmt]
                         [contact-stmt]
                         [description-stmt]
                         [reference-stmt]
        
   meta-stmts          = ;; these stmts can appear in any order
                         [organization-stmt]
                         [contact-stmt]
                         [description-stmt]
                         [reference-stmt]
        
   linkage-stmts       = ;; these stmts can appear in any order
                         *import-stmt
                         *include-stmt
        
   linkage-stmts       = ;; these stmts can appear in any order
                         *import-stmt
                         *include-stmt
        
   revision-stmts      = *revision-stmt
        
   revision-stmts      = *revision-stmt
        
   body-stmts          = *(extension-stmt /
                           feature-stmt /
                           identity-stmt /
                           typedef-stmt /
                           grouping-stmt /
                           data-def-stmt /
                           augment-stmt /
                           rpc-stmt /
                           notification-stmt /
                           deviation-stmt)
        
   body-stmts          = *(extension-stmt /
                           feature-stmt /
                           identity-stmt /
                           typedef-stmt /
                           grouping-stmt /
                           data-def-stmt /
                           augment-stmt /
                           rpc-stmt /
                           notification-stmt /
                           deviation-stmt)
        

data-def-stmt = container-stmt / leaf-stmt / leaf-list-stmt / list-stmt / choice-stmt / anydata-stmt / anyxml-stmt / uses-stmt

data def stmt=容器stmt/leaf stmt/leaf list stmt/list stmt/choice stmt/anydata stmt/anyxml stmt/uses stmt

yang-version-stmt = yang-version-keyword sep yang-version-arg-str stmtend

阳版本stmt=阳版本关键字sep阳版本arg str stmtend

   yang-version-arg-str = < a string that matches the rule >
                          < yang-version-arg >
        
   yang-version-arg-str = < a string that matches the rule >
                          < yang-version-arg >
        

yang-version-arg = "1.1"

yang版本arg=“1.1”

   import-stmt         = import-keyword sep identifier-arg-str optsep
                         "{" stmtsep
                             ;; these stmts can appear in any order
                             prefix-stmt
                             [revision-date-stmt]
                             [description-stmt]
                             [reference-stmt]
                         "}" stmtsep
        
   import-stmt         = import-keyword sep identifier-arg-str optsep
                         "{" stmtsep
                             ;; these stmts can appear in any order
                             prefix-stmt
                             [revision-date-stmt]
                             [description-stmt]
                             [reference-stmt]
                         "}" stmtsep
        
   include-stmt        = include-keyword sep identifier-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [revision-date-stmt]
                              [description-stmt]
                              [reference-stmt]
                          "}") stmtsep
        
   include-stmt        = include-keyword sep identifier-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [revision-date-stmt]
                              [description-stmt]
                              [reference-stmt]
                          "}") stmtsep
        
   namespace-stmt      = namespace-keyword sep uri-str stmtend
        
   namespace-stmt      = namespace-keyword sep uri-str stmtend
        
   uri-str             = < a string that matches the rule >
                         < URI in RFC 3986 >
        
   uri-str             = < a string that matches the rule >
                         < URI in RFC 3986 >
        

prefix-stmt = prefix-keyword sep prefix-arg-str stmtend

前缀stmt=前缀关键字sep prefix arg str stmtend

belongs-to-stmt = belongs-to-keyword sep identifier-arg-str optsep "{" stmtsep prefix-stmt "}" stmtsep

属于stmt=属于关键字sep标识符arg str optsep“{”stmtsep prefix stmt“}”stmtsep

   organization-stmt   = organization-keyword sep string stmtend
        
   organization-stmt   = organization-keyword sep string stmtend
        
   contact-stmt        = contact-keyword sep string stmtend
        
   contact-stmt        = contact-keyword sep string stmtend
        
   description-stmt    = description-keyword sep string stmtend
        
   description-stmt    = description-keyword sep string stmtend
        
   reference-stmt      = reference-keyword sep string stmtend
        
   reference-stmt      = reference-keyword sep string stmtend
        
   units-stmt          = units-keyword sep string stmtend
        
   units-stmt          = units-keyword sep string stmtend
        

revision-stmt = revision-keyword sep revision-date optsep (";" / "{" stmtsep ;; these stmts can appear in any order [description-stmt] [reference-stmt] "}") stmtsep

revision stmt=修订关键字sep revision date optsep(“;”/“{”stmtsep;;这些stmt可以以任何顺序出现[description stmt][reference stmt]“}”)stmtsep

   revision-date       = date-arg-str
        
   revision-date       = date-arg-str
        

revision-date-stmt = revision-date-keyword sep revision-date stmtend

修订日期stmt=修订日期关键字sep修订日期stmtend

   extension-stmt      = extension-keyword sep identifier-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [argument-stmt]
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                          "}") stmtsep
        
   extension-stmt      = extension-keyword sep identifier-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [argument-stmt]
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                          "}") stmtsep
        

argument-stmt = argument-keyword sep identifier-arg-str optsep (";" / "{" stmtsep [yin-element-stmt] "}") stmtsep

参数stmt=参数关键字sep标识符arg str optsep(“;”/“{”stmtsep[yin元素stmt]“}”)stmtsep

yin-element-stmt = yin-element-keyword sep yin-element-arg-str stmtend

yin element stmt=yin element关键字sep yin element arg str stmtend

   yin-element-arg-str = < a string that matches the rule >
                         < yin-element-arg >
        
   yin-element-arg-str = < a string that matches the rule >
                         < yin-element-arg >
        
   yin-element-arg     = true-keyword / false-keyword
        
   yin-element-arg     = true-keyword / false-keyword
        
   identity-stmt       = identity-keyword sep identifier-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              *if-feature-stmt
                              *base-stmt
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                          "}") stmtsep
        
   identity-stmt       = identity-keyword sep identifier-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              *if-feature-stmt
                              *base-stmt
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                          "}") stmtsep
        

base-stmt = base-keyword sep identifier-ref-arg-str stmtend

base stmt=基本关键字sep标识符ref arg str stmtend

   feature-stmt        = feature-keyword sep identifier-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              *if-feature-stmt
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                          "}") stmtsep
        
   feature-stmt        = feature-keyword sep identifier-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              *if-feature-stmt
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                          "}") stmtsep
        

if-feature-stmt = if-feature-keyword sep if-feature-expr-str stmtend

if feature stmt=if feature关键字sep if feature expr str stmtend

   if-feature-expr-str = < a string that matches the rule >
                         < if-feature-expr >
        
   if-feature-expr-str = < a string that matches the rule >
                         < if-feature-expr >
        

if-feature-expr = if-feature-term [sep or-keyword sep if-feature-expr]

if feature expr=if feature term[sep或关键字sep if feature expr]

if-feature-term = if-feature-factor [sep and-keyword sep if-feature-term]

如果特征项=如果特征因子[sep和关键字sep如果特征项]

if-feature-factor = not-keyword sep if-feature-factor / "(" optsep if-feature-expr optsep ")" / identifier-ref-arg

if feature factor=not关键字sep if feature factor/“(“optsep if feature expr optsep”)”/identifier ref arg

   typedef-stmt        = typedef-keyword sep identifier-arg-str optsep
                         "{" stmtsep
                             ;; these stmts can appear in any order
                             type-stmt
                             [units-stmt]
                             [default-stmt]
                             [status-stmt]
                             [description-stmt]
                             [reference-stmt]
                          "}" stmtsep
        
   typedef-stmt        = typedef-keyword sep identifier-arg-str optsep
                         "{" stmtsep
                             ;; these stmts can appear in any order
                             type-stmt
                             [units-stmt]
                             [default-stmt]
                             [status-stmt]
                             [description-stmt]
                             [reference-stmt]
                          "}" stmtsep
        

type-stmt = type-keyword sep identifier-ref-arg-str optsep (";" / "{" stmtsep [type-body-stmts] "}") stmtsep

类型stmt=type关键字sep标识符ref arg str optsep(“;”/“{”stmtsep[type body stmts]“}”)stmtsep

type-body-stmts = numerical-restrictions / decimal64-specification / string-restrictions / enum-specification / leafref-specification / identityref-specification / instance-identifier-specification / bits-specification / union-specification / binary-specification

类型body stmts=数字限制/小数64规范/字符串限制/枚举规范/leafref规范/identityref规范/实例标识符规范/位规范/联合规范/二进制规范

   numerical-restrictions = [range-stmt]
        
   numerical-restrictions = [range-stmt]
        
   range-stmt          = range-keyword sep range-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [error-message-stmt]
                              [error-app-tag-stmt]
                              [description-stmt]
                              [reference-stmt]
                           "}") stmtsep
        
   range-stmt          = range-keyword sep range-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [error-message-stmt]
                              [error-app-tag-stmt]
                              [description-stmt]
                              [reference-stmt]
                           "}") stmtsep
        

decimal64-specification = ;; these stmts can appear in any order fraction-digits-stmt [range-stmt]

小数64规范=;;这些stmt可以以分数位数stmt[范围stmt]的任何顺序出现

fraction-digits-stmt = fraction-digits-keyword sep fraction-digits-arg-str stmtend

分数位数stmt=分数位数关键字sep分数位数arg str stmtend

   fraction-digits-arg-str = < a string that matches the rule >
                             < fraction-digits-arg >
        
   fraction-digits-arg-str = < a string that matches the rule >
                             < fraction-digits-arg >
        
   fraction-digits-arg = ("1" ["0" / "1" / "2" / "3" / "4" /
                               "5" / "6" / "7" / "8"])
                         / "2" / "3" / "4" / "5" / "6" / "7" / "8" / "9"
        
   fraction-digits-arg = ("1" ["0" / "1" / "2" / "3" / "4" /
                               "5" / "6" / "7" / "8"])
                         / "2" / "3" / "4" / "5" / "6" / "7" / "8" / "9"
        

string-restrictions = ;; these stmts can appear in any order [length-stmt] *pattern-stmt

字符串限制=;;这些stmt可以按任意顺序显示[长度stmt]*图案stmt

   length-stmt         = length-keyword sep length-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [error-message-stmt]
                              [error-app-tag-stmt]
                              [description-stmt]
                              [reference-stmt]
                           "}") stmtsep
        
   length-stmt         = length-keyword sep length-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [error-message-stmt]
                              [error-app-tag-stmt]
                              [description-stmt]
                              [reference-stmt]
                           "}") stmtsep
        
   pattern-stmt        = pattern-keyword sep string optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [modifier-stmt]
                              [error-message-stmt]
                              [error-app-tag-stmt]
                              [description-stmt]
                              [reference-stmt]
                           "}") stmtsep
        
   pattern-stmt        = pattern-keyword sep string optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [modifier-stmt]
                              [error-message-stmt]
                              [error-app-tag-stmt]
                              [description-stmt]
                              [reference-stmt]
                           "}") stmtsep
        

modifier-stmt = modifier-keyword sep modifier-arg-str stmtend

修饰符stmt=修饰符关键字sep修饰符arg str stmtend

   modifier-arg-str    = < a string that matches the rule >
                         < modifier-arg >
        
   modifier-arg-str    = < a string that matches the rule >
                         < modifier-arg >
        
   modifier-arg        = invert-match-keyword
        
   modifier-arg        = invert-match-keyword
        
   default-stmt        = default-keyword sep string stmtend
        
   default-stmt        = default-keyword sep string stmtend
        
   enum-specification  = 1*enum-stmt
        
   enum-specification  = 1*enum-stmt
        
   enum-stmt           = enum-keyword sep string optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              *if-feature-stmt
                              [value-stmt]
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                           "}") stmtsep
        
   enum-stmt           = enum-keyword sep string optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              *if-feature-stmt
                              [value-stmt]
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                           "}") stmtsep
        

leafref-specification = ;; these stmts can appear in any order path-stmt [require-instance-stmt]

leafref规范=;;这些stmt可以以任何顺序出现路径stmt[需要实例stmt]

   path-stmt           = path-keyword sep path-arg-str stmtend
        
   path-stmt           = path-keyword sep path-arg-str stmtend
        

require-instance-stmt = require-instance-keyword sep require-instance-arg-str stmtend

require instance stmt=require instance关键字sep require instance arg str stmtend

   require-instance-arg-str = < a string that matches the rule >
                              < require-instance-arg >
        
   require-instance-arg-str = < a string that matches the rule >
                              < require-instance-arg >
        
   require-instance-arg = true-keyword / false-keyword
        
   require-instance-arg = true-keyword / false-keyword
        

instance-identifier-specification = [require-instance-stmt]

实例标识符规范=[需要实例stmt]

   identityref-specification =
                         1*base-stmt
        
   identityref-specification =
                         1*base-stmt
        
   union-specification = 1*type-stmt
        
   union-specification = 1*type-stmt
        
   binary-specification = [length-stmt]
        
   binary-specification = [length-stmt]
        
   bits-specification  = 1*bit-stmt
        
   bits-specification  = 1*bit-stmt
        
   bit-stmt            = bit-keyword sep identifier-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              *if-feature-stmt
                              [position-stmt]
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                          "}") stmtsep
        
   bit-stmt            = bit-keyword sep identifier-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              *if-feature-stmt
                              [position-stmt]
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                          "}") stmtsep
        

position-stmt = position-keyword sep position-value-arg-str stmtend

position stmt=位置关键字sep位置值arg str stmtend

   position-value-arg-str = < a string that matches the rule >
                            < position-value-arg >
        
   position-value-arg-str = < a string that matches the rule >
                            < position-value-arg >
        
   position-value-arg  = non-negative-integer-value
        
   position-value-arg  = non-negative-integer-value
        

status-stmt = status-keyword sep status-arg-str stmtend

status stmt=状态关键字sep status arg str stmtend

   status-arg-str      = < a string that matches the rule >
                         < status-arg >
        
   status-arg-str      = < a string that matches the rule >
                         < status-arg >
        

status-arg = current-keyword / obsolete-keyword / deprecated-keyword

状态参数=当前关键字/过时关键字/弃用关键字

config-stmt = config-keyword sep config-arg-str stmtend

config stmt=config关键字sep config arg str stmtend

   config-arg-str      = < a string that matches the rule >
                         < config-arg >
        
   config-arg-str      = < a string that matches the rule >
                         < config-arg >
        
   config-arg          = true-keyword / false-keyword
        
   config-arg          = true-keyword / false-keyword
        

mandatory-stmt = mandatory-keyword sep mandatory-arg-str stmtend

mandatory stmt=强制关键字sep mandatory arg str stmtend

   mandatory-arg-str   = < a string that matches the rule >
                         < mandatory-arg >
        
   mandatory-arg-str   = < a string that matches the rule >
                         < mandatory-arg >
        
   mandatory-arg       = true-keyword / false-keyword
        
   mandatory-arg       = true-keyword / false-keyword
        
   presence-stmt       = presence-keyword sep string stmtend
        
   presence-stmt       = presence-keyword sep string stmtend
        

ordered-by-stmt = ordered-by-keyword sep ordered-by-arg-str stmtend

按stmt排序=按关键字sep排序按arg str stmtend排序

   ordered-by-arg-str  = < a string that matches the rule >
                         < ordered-by-arg >
        
   ordered-by-arg-str  = < a string that matches the rule >
                         < ordered-by-arg >
        
   ordered-by-arg      = user-keyword / system-keyword
        
   ordered-by-arg      = user-keyword / system-keyword
        
   must-stmt           = must-keyword sep string optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [error-message-stmt]
                              [error-app-tag-stmt]
                              [description-stmt]
                              [reference-stmt]
                           "}") stmtsep
        
   must-stmt           = must-keyword sep string optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [error-message-stmt]
                              [error-app-tag-stmt]
                              [description-stmt]
                              [reference-stmt]
                           "}") stmtsep
        
   error-message-stmt  = error-message-keyword sep string stmtend
        
   error-message-stmt  = error-message-keyword sep string stmtend
        
   error-app-tag-stmt  = error-app-tag-keyword sep string stmtend
        
   error-app-tag-stmt  = error-app-tag-keyword sep string stmtend
        

min-elements-stmt = min-elements-keyword sep min-value-arg-str stmtend

最小元素stmt=min元素关键字sep最小值arg str stmtend

   min-value-arg-str   = < a string that matches the rule >
                         < min-value-arg >
        
   min-value-arg-str   = < a string that matches the rule >
                         < min-value-arg >
        
   min-value-arg       = non-negative-integer-value
        
   min-value-arg       = non-negative-integer-value
        

max-elements-stmt = max-elements-keyword sep max-value-arg-str stmtend

max elements stmt=max elements关键字sep max value arg str stmtend

   max-value-arg-str   = < a string that matches the rule >
                         < max-value-arg >
        
   max-value-arg-str   = < a string that matches the rule >
                         < max-value-arg >
        

max-value-arg = unbounded-keyword / positive-integer-value

最大值arg=无界关键字/正整数值

value-stmt = value-keyword sep integer-value-str stmtend

value stmt=value关键字sep整数值str stmtend

   integer-value-str   = < a string that matches the rule >
                         < integer-value >
        
   integer-value-str   = < a string that matches the rule >
                         < integer-value >
        
   grouping-stmt       = grouping-keyword sep identifier-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                              *(typedef-stmt / grouping-stmt)
                              *data-def-stmt
                              *action-stmt
                              *notification-stmt
                          "}") stmtsep
        
   grouping-stmt       = grouping-keyword sep identifier-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                              *(typedef-stmt / grouping-stmt)
                              *data-def-stmt
                              *action-stmt
                              *notification-stmt
                          "}") stmtsep
        
   container-stmt      = container-keyword sep identifier-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [when-stmt]
                              *if-feature-stmt
                              *must-stmt
                              [presence-stmt]
                              [config-stmt]
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                              *(typedef-stmt / grouping-stmt)
                              *data-def-stmt
                              *action-stmt
                              *notification-stmt
                          "}") stmtsep
        
   container-stmt      = container-keyword sep identifier-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [when-stmt]
                              *if-feature-stmt
                              *must-stmt
                              [presence-stmt]
                              [config-stmt]
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                              *(typedef-stmt / grouping-stmt)
                              *data-def-stmt
                              *action-stmt
                              *notification-stmt
                          "}") stmtsep
        
   leaf-stmt           = leaf-keyword sep identifier-arg-str optsep
                         "{" stmtsep
                             ;; these stmts can appear in any order
                             [when-stmt]
                             *if-feature-stmt
                             type-stmt
                             [units-stmt]
                             *must-stmt
                             [default-stmt]
                             [config-stmt]
                             [mandatory-stmt]
                             [status-stmt]
                             [description-stmt]
                             [reference-stmt]
                          "}" stmtsep
        
   leaf-stmt           = leaf-keyword sep identifier-arg-str optsep
                         "{" stmtsep
                             ;; these stmts can appear in any order
                             [when-stmt]
                             *if-feature-stmt
                             type-stmt
                             [units-stmt]
                             *must-stmt
                             [default-stmt]
                             [config-stmt]
                             [mandatory-stmt]
                             [status-stmt]
                             [description-stmt]
                             [reference-stmt]
                          "}" stmtsep
        
   leaf-list-stmt      = leaf-list-keyword sep identifier-arg-str optsep
                         "{" stmtsep
                             ;; these stmts can appear in any order
                             [when-stmt]
                             *if-feature-stmt
                             type-stmt stmtsep
                             [units-stmt]
                             *must-stmt
                             *default-stmt
                             [config-stmt]
                             [min-elements-stmt]
                             [max-elements-stmt]
                             [ordered-by-stmt]
                             [status-stmt]
                             [description-stmt]
                             [reference-stmt]
                          "}" stmtsep
        
   leaf-list-stmt      = leaf-list-keyword sep identifier-arg-str optsep
                         "{" stmtsep
                             ;; these stmts can appear in any order
                             [when-stmt]
                             *if-feature-stmt
                             type-stmt stmtsep
                             [units-stmt]
                             *must-stmt
                             *default-stmt
                             [config-stmt]
                             [min-elements-stmt]
                             [max-elements-stmt]
                             [ordered-by-stmt]
                             [status-stmt]
                             [description-stmt]
                             [reference-stmt]
                          "}" stmtsep
        
   list-stmt           = list-keyword sep identifier-arg-str optsep
                         "{" stmtsep
                             ;; these stmts can appear in any order
                             [when-stmt]
                             *if-feature-stmt
                             *must-stmt
                             [key-stmt]
                             *unique-stmt
                             [config-stmt]
                             [min-elements-stmt]
                             [max-elements-stmt]
                             [ordered-by-stmt]
                             [status-stmt]
                             [description-stmt]
                             [reference-stmt]
                             *(typedef-stmt / grouping-stmt)
                             1*data-def-stmt
                             *action-stmt
                             *notification-stmt
                          "}" stmtsep
        
   list-stmt           = list-keyword sep identifier-arg-str optsep
                         "{" stmtsep
                             ;; these stmts can appear in any order
                             [when-stmt]
                             *if-feature-stmt
                             *must-stmt
                             [key-stmt]
                             *unique-stmt
                             [config-stmt]
                             [min-elements-stmt]
                             [max-elements-stmt]
                             [ordered-by-stmt]
                             [status-stmt]
                             [description-stmt]
                             [reference-stmt]
                             *(typedef-stmt / grouping-stmt)
                             1*data-def-stmt
                             *action-stmt
                             *notification-stmt
                          "}" stmtsep
        
   key-stmt            = key-keyword sep key-arg-str stmtend
        
   key-stmt            = key-keyword sep key-arg-str stmtend
        
   key-arg-str         = < a string that matches the rule >
                         < key-arg >
        
   key-arg-str         = < a string that matches the rule >
                         < key-arg >
        

key-arg = node-identifier *(sep node-identifier)

key arg=节点标识符*(sep节点标识符)

unique-stmt = unique-keyword sep unique-arg-str stmtend

unique stmt=unique关键字sep unique arg str stmtend

   unique-arg-str      = < a string that matches the rule >
                         < unique-arg >
        
   unique-arg-str      = < a string that matches the rule >
                         < unique-arg >
        

unique-arg = descendant-schema-nodeid *(sep descendant-schema-nodeid)

唯一arg=子代架构nodeid*(sep子代架构nodeid)

   choice-stmt         = choice-keyword sep identifier-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [when-stmt]
                              *if-feature-stmt
                              [default-stmt]
                              [config-stmt]
                              [mandatory-stmt]
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                              *(short-case-stmt / case-stmt)
                          "}") stmtsep
        
   choice-stmt         = choice-keyword sep identifier-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [when-stmt]
                              *if-feature-stmt
                              [default-stmt]
                              [config-stmt]
                              [mandatory-stmt]
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                              *(short-case-stmt / case-stmt)
                          "}") stmtsep
        

short-case-stmt = choice-stmt / container-stmt / leaf-stmt / leaf-list-stmt / list-stmt / anydata-stmt / anyxml-stmt

short-case stmt=选择stmt/container stmt/leaf stmt/leaf list stmt/list stmt/anydata stmt/anyxml stmt

   case-stmt           = case-keyword sep identifier-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [when-stmt]
                              *if-feature-stmt
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                              *data-def-stmt
                          "}") stmtsep
        
   case-stmt           = case-keyword sep identifier-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [when-stmt]
                              *if-feature-stmt
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                              *data-def-stmt
                          "}") stmtsep
        
   anydata-stmt        = anydata-keyword sep identifier-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [when-stmt]
                              *if-feature-stmt
                              *must-stmt
                              [config-stmt]
                              [mandatory-stmt]
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                           "}") stmtsep
        
   anydata-stmt        = anydata-keyword sep identifier-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [when-stmt]
                              *if-feature-stmt
                              *must-stmt
                              [config-stmt]
                              [mandatory-stmt]
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                           "}") stmtsep
        
   anyxml-stmt         = anyxml-keyword sep identifier-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [when-stmt]
                              *if-feature-stmt
                              *must-stmt
                              [config-stmt]
                              [mandatory-stmt]
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                           "}") stmtsep
        
   anyxml-stmt         = anyxml-keyword sep identifier-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [when-stmt]
                              *if-feature-stmt
                              *must-stmt
                              [config-stmt]
                              [mandatory-stmt]
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                           "}") stmtsep
        
   uses-stmt           = uses-keyword sep identifier-ref-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [when-stmt]
                              *if-feature-stmt
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                              *refine-stmt
                              *uses-augment-stmt
                          "}") stmtsep
        
   uses-stmt           = uses-keyword sep identifier-ref-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [when-stmt]
                              *if-feature-stmt
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                              *refine-stmt
                              *uses-augment-stmt
                          "}") stmtsep
        
   refine-stmt         = refine-keyword sep refine-arg-str optsep
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              *if-feature-stmt
                              *must-stmt
                              [presence-stmt]
                              *default-stmt
                              [config-stmt]
                              [mandatory-stmt]
                              [min-elements-stmt]
                              [max-elements-stmt]
                              [description-stmt]
                              [reference-stmt]
                            "}" stmtsep
        
   refine-stmt         = refine-keyword sep refine-arg-str optsep
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              *if-feature-stmt
                              *must-stmt
                              [presence-stmt]
                              *default-stmt
                              [config-stmt]
                              [mandatory-stmt]
                              [min-elements-stmt]
                              [max-elements-stmt]
                              [description-stmt]
                              [reference-stmt]
                            "}" stmtsep
        
   refine-arg-str      = < a string that matches the rule >
                         < refine-arg >
        
   refine-arg-str      = < a string that matches the rule >
                         < refine-arg >
        
   refine-arg          = descendant-schema-nodeid
        
   refine-arg          = descendant-schema-nodeid
        
   uses-augment-stmt   = augment-keyword sep uses-augment-arg-str optsep
                         "{" stmtsep
                             ;; these stmts can appear in any order
                             [when-stmt]
                             *if-feature-stmt
                             [status-stmt]
                             [description-stmt]
                             [reference-stmt]
                             1*(data-def-stmt / case-stmt /
                                action-stmt / notification-stmt)
                          "}" stmtsep
        
   uses-augment-stmt   = augment-keyword sep uses-augment-arg-str optsep
                         "{" stmtsep
                             ;; these stmts can appear in any order
                             [when-stmt]
                             *if-feature-stmt
                             [status-stmt]
                             [description-stmt]
                             [reference-stmt]
                             1*(data-def-stmt / case-stmt /
                                action-stmt / notification-stmt)
                          "}" stmtsep
        
   uses-augment-arg-str = < a string that matches the rule >
                          < uses-augment-arg >
        
   uses-augment-arg-str = < a string that matches the rule >
                          < uses-augment-arg >
        
   uses-augment-arg    = descendant-schema-nodeid
        
   uses-augment-arg    = descendant-schema-nodeid
        
   augment-stmt        = augment-keyword sep augment-arg-str optsep
                         "{" stmtsep
                             ;; these stmts can appear in any order
                             [when-stmt]
                             *if-feature-stmt
                             [status-stmt]
                             [description-stmt]
                             [reference-stmt]
                             1*(data-def-stmt / case-stmt /
                                action-stmt / notification-stmt)
                          "}" stmtsep
        
   augment-stmt        = augment-keyword sep augment-arg-str optsep
                         "{" stmtsep
                             ;; these stmts can appear in any order
                             [when-stmt]
                             *if-feature-stmt
                             [status-stmt]
                             [description-stmt]
                             [reference-stmt]
                             1*(data-def-stmt / case-stmt /
                                action-stmt / notification-stmt)
                          "}" stmtsep
        
   augment-arg-str     = < a string that matches the rule >
                         < augment-arg >
        
   augment-arg-str     = < a string that matches the rule >
                         < augment-arg >
        
   augment-arg         = absolute-schema-nodeid
        
   augment-arg         = absolute-schema-nodeid
        

when-stmt = when-keyword sep string optsep (";" / "{" stmtsep ;; these stmts can appear in any order [description-stmt] [reference-stmt] "}") stmtsep

当stmt=when关键字sep string optsep(“;”/“{”stmtsep;;这些stmt可以以任何顺序出现[description stmt][reference stmt]“}”)stmtsep

   rpc-stmt            = rpc-keyword sep identifier-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              *if-feature-stmt
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                              *(typedef-stmt / grouping-stmt)
                              [input-stmt]
                              [output-stmt]
                          "}") stmtsep
        
   rpc-stmt            = rpc-keyword sep identifier-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              *if-feature-stmt
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                              *(typedef-stmt / grouping-stmt)
                              [input-stmt]
                              [output-stmt]
                          "}") stmtsep
        
   action-stmt         = action-keyword sep identifier-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              *if-feature-stmt
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                              *(typedef-stmt / grouping-stmt)
                              [input-stmt]
                              [output-stmt]
                          "}") stmtsep
        
   action-stmt         = action-keyword sep identifier-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              *if-feature-stmt
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                              *(typedef-stmt / grouping-stmt)
                              [input-stmt]
                              [output-stmt]
                          "}") stmtsep
        
   input-stmt          = input-keyword optsep
                         "{" stmtsep
                             ;; these stmts can appear in any order
                             *must-stmt
                             *(typedef-stmt / grouping-stmt)
                             1*data-def-stmt
                         "}" stmtsep
        
   input-stmt          = input-keyword optsep
                         "{" stmtsep
                             ;; these stmts can appear in any order
                             *must-stmt
                             *(typedef-stmt / grouping-stmt)
                             1*data-def-stmt
                         "}" stmtsep
        
   output-stmt         = output-keyword optsep
                         "{" stmtsep
                             ;; these stmts can appear in any order
                             *must-stmt
                             *(typedef-stmt / grouping-stmt)
                             1*data-def-stmt
                         "}" stmtsep
        
   output-stmt         = output-keyword optsep
                         "{" stmtsep
                             ;; these stmts can appear in any order
                             *must-stmt
                             *(typedef-stmt / grouping-stmt)
                             1*data-def-stmt
                         "}" stmtsep
        
   notification-stmt   = notification-keyword sep
                         identifier-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              *if-feature-stmt
                              *must-stmt
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                              *(typedef-stmt / grouping-stmt)
                              *data-def-stmt
                          "}") stmtsep
        
   notification-stmt   = notification-keyword sep
                         identifier-arg-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              *if-feature-stmt
                              *must-stmt
                              [status-stmt]
                              [description-stmt]
                              [reference-stmt]
                              *(typedef-stmt / grouping-stmt)
                              *data-def-stmt
                          "}") stmtsep
        

deviation-stmt = deviation-keyword sep deviation-arg-str optsep "{" stmtsep ;; these stmts can appear in any order [description-stmt] [reference-stmt] (deviate-not-supported-stmt / 1*(deviate-add-stmt / deviate-replace-stmt / deviate-delete-stmt)) "}" stmtsep

偏差stmt=偏差关键字sep DEVISION arg str optsep“{”STMTSP;;这些stmt可以以任何顺序出现[说明stmt][参考stmt](不支持偏差stmt/1*(偏差添加stmt/偏差替换stmt/偏差删除stmt))“}”STMTSP

   deviation-arg-str   = < a string that matches the rule >
                         < deviation-arg >
        
   deviation-arg-str   = < a string that matches the rule >
                         < deviation-arg >
        
   deviation-arg       = absolute-schema-nodeid
        
   deviation-arg       = absolute-schema-nodeid
        

deviate-not-supported-stmt = deviate-keyword sep not-supported-keyword-str stmtend

偏离不支持的stmt=偏离关键字sep不支持的关键字str stmtend

   deviate-add-stmt    = deviate-keyword sep add-keyword-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [units-stmt]
                              *must-stmt
                              *unique-stmt
                              *default-stmt
                              [config-stmt]
                              [mandatory-stmt]
                              [min-elements-stmt]
                              [max-elements-stmt]
                          "}") stmtsep
        
   deviate-add-stmt    = deviate-keyword sep add-keyword-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [units-stmt]
                              *must-stmt
                              *unique-stmt
                              *default-stmt
                              [config-stmt]
                              [mandatory-stmt]
                              [min-elements-stmt]
                              [max-elements-stmt]
                          "}") stmtsep
        

deviate-delete-stmt = deviate-keyword sep delete-keyword-str optsep (";" / "{" stmtsep ;; these stmts can appear in any order [units-stmt] *must-stmt *unique-stmt *default-stmt "}") stmtsep

偏离删除stmt=偏离关键字sep delete关键字str optsep(“;”/“{”stmtsep;;这些stmt可以以任何顺序出现[单位stmt]*必须stmt*唯一stmt*默认stmt“}”)stmtsep

   deviate-replace-stmt = deviate-keyword sep replace-keyword-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [type-stmt]
                              [units-stmt]
                              [default-stmt]
                              [config-stmt]
                              [mandatory-stmt]
                              [min-elements-stmt]
                              [max-elements-stmt]
                          "}") stmtsep
        
   deviate-replace-stmt = deviate-keyword sep replace-keyword-str optsep
                         (";" /
                          "{" stmtsep
                              ;; these stmts can appear in any order
                              [type-stmt]
                              [units-stmt]
                              [default-stmt]
                              [config-stmt]
                              [mandatory-stmt]
                              [min-elements-stmt]
                              [max-elements-stmt]
                          "}") stmtsep
        
   not-supported-keyword-str = < a string that matches the rule >
                               < not-supported-keyword >
        
   not-supported-keyword-str = < a string that matches the rule >
                               < not-supported-keyword >
        
   add-keyword-str     = < a string that matches the rule >
                         < add-keyword >
        
   add-keyword-str     = < a string that matches the rule >
                         < add-keyword >
        
   delete-keyword-str  = < a string that matches the rule >
                         < delete-keyword >
        
   delete-keyword-str  = < a string that matches the rule >
                         < delete-keyword >
        
   replace-keyword-str = < a string that matches the rule >
                         < replace-keyword >
        
   replace-keyword-str = < a string that matches the rule >
                         < replace-keyword >
        
   ;; represents the usage of an extension
   unknown-statement   = prefix ":" identifier [sep string] optsep
                         (";" /
                          "{" optsep
                              *((yang-stmt / unknown-statement) optsep)
                           "}") stmtsep
        
   ;; represents the usage of an extension
   unknown-statement   = prefix ":" identifier [sep string] optsep
                         (";" /
                          "{" optsep
                              *((yang-stmt / unknown-statement) optsep)
                           "}") stmtsep
        

yang-stmt = action-stmt / anydata-stmt / anyxml-stmt / argument-stmt / augment-stmt / base-stmt / belongs-to-stmt / bit-stmt / case-stmt / choice-stmt / config-stmt / contact-stmt / container-stmt / default-stmt / description-stmt / deviate-add-stmt /

yang stmt=action stmt/anydata stmt/anyxml stmt/argument stmt/augment stmt/base stmt/属于stmt/bit stmt/case stmt/choice stmt/config stmt/contact stmt/container stmt/default stmt/description stmt/develope add stmt/

deviate-delete-stmt / deviate-not-supported-stmt / deviate-replace-stmt / deviation-stmt / enum-stmt / error-app-tag-stmt / error-message-stmt / extension-stmt / feature-stmt / fraction-digits-stmt / grouping-stmt / identity-stmt / if-feature-stmt / import-stmt / include-stmt / input-stmt / key-stmt / leaf-list-stmt / leaf-stmt / length-stmt / list-stmt / mandatory-stmt / max-elements-stmt / min-elements-stmt / modifier-stmt / module-stmt / must-stmt / namespace-stmt / notification-stmt / ordered-by-stmt / organization-stmt / output-stmt / path-stmt / pattern-stmt / position-stmt / prefix-stmt / presence-stmt / range-stmt / reference-stmt / refine-stmt / require-instance-stmt / revision-date-stmt / revision-stmt / rpc-stmt / status-stmt / submodule-stmt / typedef-stmt / type-stmt /

偏差删除stmt/不支持偏差stmt/偏差替换stmt/偏差stmt/枚举stmt/错误应用标记stmt/错误消息stmt/扩展stmt/功能stmt/分数位数stmt/分组stmt/标识stmt/如果功能stmt/导入stmt/包括stmt/输入stmt/键stmt/叶列表stmt/叶stmt/长度stmt/列出stmt/强制stmt/max elements stmt/min elements stmt/修改器stmt/模块stmt/必须stmt/命名空间stmt/通知stmt/按stmt/组织stmt/输出stmt/路径stmt/模式stmt/位置stmt/前缀stmt/存在stmt/范围stmt/引用stmt/优化stmt/需要实例stmt/修订日期stmt/修订stmt/rpc stmt/状态stmt/子模块stmt/typedef stmt/type stmt/

unique-stmt / units-stmt / uses-augment-stmt / uses-stmt / value-stmt / when-stmt / yang-version-stmt / yin-element-stmt

唯一stmt/单位stmt/使用增强stmt/使用stmt/值stmt/当stmt/阳版本stmt/阴元素stmt

;; Ranges

;; 范围

   range-arg-str       = < a string that matches the rule >
                         < range-arg >
        
   range-arg-str       = < a string that matches the rule >
                         < range-arg >
        

range-arg = range-part *(optsep "|" optsep range-part)

范围参数=范围部分*(optsep“|”optsep范围部分)

range-part = range-boundary [optsep ".." optsep range-boundary]

范围部分=范围边界[optsep”。“optsep范围边界]

   range-boundary      = min-keyword / max-keyword /
                         integer-value / decimal-value
        
   range-boundary      = min-keyword / max-keyword /
                         integer-value / decimal-value
        

;; Lengths

;; 长度

   length-arg-str      = < a string that matches the rule >
                         < length-arg >
        
   length-arg-str      = < a string that matches the rule >
                         < length-arg >
        

length-arg = length-part *(optsep "|" optsep length-part)

长度arg=长度部分*(optsep“|”optsep长度部分)

length-part = length-boundary [optsep ".." optsep length-boundary]

长度部分=长度边界[optsep”。“optsep长度边界]

length-boundary = min-keyword / max-keyword / non-negative-integer-value

长度边界=最小关键字/最大关键字/非负整数值

;; Date

;; 日期

   date-arg-str        = < a string that matches the rule >
                         < date-arg >
        
   date-arg-str        = < a string that matches the rule >
                         < date-arg >
        

date-arg = 4DIGIT "-" 2DIGIT "-" 2DIGIT

日期arg=4DIGIT“-”2DIGIT“-”2DIGIT

;; Schema Node Identifiers

;; 模式节点标识符

schema-nodeid = absolute-schema-nodeid / descendant-schema-nodeid

schema nodeid=绝对模式nodeid/后代模式nodeid

   absolute-schema-nodeid = 1*("/" node-identifier)
        
   absolute-schema-nodeid = 1*("/" node-identifier)
        

descendant-schema-nodeid = node-identifier [absolute-schema-nodeid]

子代架构nodeid=节点标识符[绝对架构nodeid]

   node-identifier     = [prefix ":"] identifier
        
   node-identifier     = [prefix ":"] identifier
        

;; Instance Identifiers

;; 实例标识符

   instance-identifier = 1*("/" (node-identifier
                                 [1*key-predicate /
                                  leaf-list-predicate /
                                  pos]))
        
   instance-identifier = 1*("/" (node-identifier
                                 [1*key-predicate /
                                  leaf-list-predicate /
                                  pos]))
        
   key-predicate       = "[" *WSP key-predicate-expr *WSP "]"
        
   key-predicate       = "[" *WSP key-predicate-expr *WSP "]"
        
   key-predicate-expr  = node-identifier *WSP "=" *WSP quoted-string
        
   key-predicate-expr  = node-identifier *WSP "=" *WSP quoted-string
        
   leaf-list-predicate = "[" *WSP leaf-list-predicate-expr *WSP "]"
        
   leaf-list-predicate = "[" *WSP leaf-list-predicate-expr *WSP "]"
        
   leaf-list-predicate-expr = "." *WSP "=" *WSP quoted-string
        
   leaf-list-predicate-expr = "." *WSP "=" *WSP quoted-string
        
   pos                 = "[" *WSP positive-integer-value *WSP "]"
        
   pos                 = "[" *WSP positive-integer-value *WSP "]"
        
   quoted-string       = (DQUOTE string DQUOTE) / (SQUOTE string SQUOTE)
        
   quoted-string       = (DQUOTE string DQUOTE) / (SQUOTE string SQUOTE)
        

;; leafref path

;; 叶参考路径

   path-arg-str        = < a string that matches the rule >
                         < path-arg >
        
   path-arg-str        = < a string that matches the rule >
                         < path-arg >
        
   path-arg            = absolute-path / relative-path
        
   path-arg            = absolute-path / relative-path
        
   absolute-path       = 1*("/" (node-identifier *path-predicate))
        
   absolute-path       = 1*("/" (node-identifier *path-predicate))
        
   relative-path       = 1*("../") descendant-path
        
   relative-path       = 1*("../") descendant-path
        

descendant-path = node-identifier [*path-predicate absolute-path]

子体路径=节点标识符[*路径谓词绝对路径]

   path-predicate      = "[" *WSP path-equality-expr *WSP "]"
        
   path-predicate      = "[" *WSP path-equality-expr *WSP "]"
        
   path-equality-expr  = node-identifier *WSP "=" *WSP path-key-expr
        
   path-equality-expr  = node-identifier *WSP "=" *WSP path-key-expr
        
   path-key-expr       = current-function-invocation *WSP "/" *WSP
                         rel-path-keyexpr
        
   path-key-expr       = current-function-invocation *WSP "/" *WSP
                         rel-path-keyexpr
        
   rel-path-keyexpr    = 1*(".." *WSP "/" *WSP)
                         *(node-identifier *WSP "/" *WSP)
                         node-identifier
        
   rel-path-keyexpr    = 1*(".." *WSP "/" *WSP)
                         *(node-identifier *WSP "/" *WSP)
                         node-identifier
        
   ;;; Keywords, using the syntax for case-sensitive strings (RFC 7405)
        
   ;;; Keywords, using the syntax for case-sensitive strings (RFC 7405)
        
   ;; statement keywords
   action-keyword           = %s"action"
   anydata-keyword          = %s"anydata"
   anyxml-keyword           = %s"anyxml"
   argument-keyword         = %s"argument"
   augment-keyword          = %s"augment"
   base-keyword             = %s"base"
   belongs-to-keyword       = %s"belongs-to"
   bit-keyword              = %s"bit"
   case-keyword             = %s"case"
   choice-keyword           = %s"choice"
   config-keyword           = %s"config"
   contact-keyword          = %s"contact"
   container-keyword        = %s"container"
   default-keyword          = %s"default"
   description-keyword      = %s"description"
   deviate-keyword          = %s"deviate"
   deviation-keyword        = %s"deviation"
   enum-keyword             = %s"enum"
   error-app-tag-keyword    = %s"error-app-tag"
   error-message-keyword    = %s"error-message"
   extension-keyword        = %s"extension"
   feature-keyword          = %s"feature"
   fraction-digits-keyword  = %s"fraction-digits"
   grouping-keyword         = %s"grouping"
   identity-keyword         = %s"identity"
   if-feature-keyword       = %s"if-feature"
   import-keyword           = %s"import"
   include-keyword          = %s"include"
   input-keyword            = %s"input"
   key-keyword              = %s"key"
   leaf-keyword             = %s"leaf"
   leaf-list-keyword        = %s"leaf-list"
   length-keyword           = %s"length"
   list-keyword             = %s"list"
   mandatory-keyword        = %s"mandatory"
   max-elements-keyword     = %s"max-elements"
   min-elements-keyword     = %s"min-elements"
   modifier-keyword         = %s"modifier"
   module-keyword           = %s"module"
   must-keyword             = %s"must"
   namespace-keyword        = %s"namespace"
        
   ;; statement keywords
   action-keyword           = %s"action"
   anydata-keyword          = %s"anydata"
   anyxml-keyword           = %s"anyxml"
   argument-keyword         = %s"argument"
   augment-keyword          = %s"augment"
   base-keyword             = %s"base"
   belongs-to-keyword       = %s"belongs-to"
   bit-keyword              = %s"bit"
   case-keyword             = %s"case"
   choice-keyword           = %s"choice"
   config-keyword           = %s"config"
   contact-keyword          = %s"contact"
   container-keyword        = %s"container"
   default-keyword          = %s"default"
   description-keyword      = %s"description"
   deviate-keyword          = %s"deviate"
   deviation-keyword        = %s"deviation"
   enum-keyword             = %s"enum"
   error-app-tag-keyword    = %s"error-app-tag"
   error-message-keyword    = %s"error-message"
   extension-keyword        = %s"extension"
   feature-keyword          = %s"feature"
   fraction-digits-keyword  = %s"fraction-digits"
   grouping-keyword         = %s"grouping"
   identity-keyword         = %s"identity"
   if-feature-keyword       = %s"if-feature"
   import-keyword           = %s"import"
   include-keyword          = %s"include"
   input-keyword            = %s"input"
   key-keyword              = %s"key"
   leaf-keyword             = %s"leaf"
   leaf-list-keyword        = %s"leaf-list"
   length-keyword           = %s"length"
   list-keyword             = %s"list"
   mandatory-keyword        = %s"mandatory"
   max-elements-keyword     = %s"max-elements"
   min-elements-keyword     = %s"min-elements"
   modifier-keyword         = %s"modifier"
   module-keyword           = %s"module"
   must-keyword             = %s"must"
   namespace-keyword        = %s"namespace"
        
   notification-keyword     = %s"notification"
   ordered-by-keyword       = %s"ordered-by"
   organization-keyword     = %s"organization"
   output-keyword           = %s"output"
   path-keyword             = %s"path"
   pattern-keyword          = %s"pattern"
   position-keyword         = %s"position"
   prefix-keyword           = %s"prefix"
   presence-keyword         = %s"presence"
   range-keyword            = %s"range"
   reference-keyword        = %s"reference"
   refine-keyword           = %s"refine"
   require-instance-keyword = %s"require-instance"
   revision-keyword         = %s"revision"
   revision-date-keyword    = %s"revision-date"
   rpc-keyword              = %s"rpc"
   status-keyword           = %s"status"
   submodule-keyword        = %s"submodule"
   type-keyword             = %s"type"
   typedef-keyword          = %s"typedef"
   unique-keyword           = %s"unique"
   units-keyword            = %s"units"
   uses-keyword             = %s"uses"
   value-keyword            = %s"value"
   when-keyword             = %s"when"
   yang-version-keyword     = %s"yang-version"
   yin-element-keyword      = %s"yin-element"
        
   notification-keyword     = %s"notification"
   ordered-by-keyword       = %s"ordered-by"
   organization-keyword     = %s"organization"
   output-keyword           = %s"output"
   path-keyword             = %s"path"
   pattern-keyword          = %s"pattern"
   position-keyword         = %s"position"
   prefix-keyword           = %s"prefix"
   presence-keyword         = %s"presence"
   range-keyword            = %s"range"
   reference-keyword        = %s"reference"
   refine-keyword           = %s"refine"
   require-instance-keyword = %s"require-instance"
   revision-keyword         = %s"revision"
   revision-date-keyword    = %s"revision-date"
   rpc-keyword              = %s"rpc"
   status-keyword           = %s"status"
   submodule-keyword        = %s"submodule"
   type-keyword             = %s"type"
   typedef-keyword          = %s"typedef"
   unique-keyword           = %s"unique"
   units-keyword            = %s"units"
   uses-keyword             = %s"uses"
   value-keyword            = %s"value"
   when-keyword             = %s"when"
   yang-version-keyword     = %s"yang-version"
   yin-element-keyword      = %s"yin-element"
        

;; other keywords

;; 其他关键字

   add-keyword              = %s"add"
   current-keyword          = %s"current"
   delete-keyword           = %s"delete"
   deprecated-keyword       = %s"deprecated"
   false-keyword            = %s"false"
   invert-match-keyword     = %s"invert-match"
   max-keyword              = %s"max"
   min-keyword              = %s"min"
   not-supported-keyword    = %s"not-supported"
   obsolete-keyword         = %s"obsolete"
   replace-keyword          = %s"replace"
   system-keyword           = %s"system"
   true-keyword             = %s"true"
   unbounded-keyword        = %s"unbounded"
   user-keyword             = %s"user"
        
   add-keyword              = %s"add"
   current-keyword          = %s"current"
   delete-keyword           = %s"delete"
   deprecated-keyword       = %s"deprecated"
   false-keyword            = %s"false"
   invert-match-keyword     = %s"invert-match"
   max-keyword              = %s"max"
   min-keyword              = %s"min"
   not-supported-keyword    = %s"not-supported"
   obsolete-keyword         = %s"obsolete"
   replace-keyword          = %s"replace"
   system-keyword           = %s"system"
   true-keyword             = %s"true"
   unbounded-keyword        = %s"unbounded"
   user-keyword             = %s"user"
        
   and-keyword              = %s"and"
   or-keyword               = %s"or"
   not-keyword              = %s"not"
        
   and-keyword              = %s"and"
   or-keyword               = %s"or"
   not-keyword              = %s"not"
        
   current-function-invocation = current-keyword *WSP "(" *WSP ")"
        
   current-function-invocation = current-keyword *WSP "(" *WSP ")"
        
   ;;; Basic Rules
        
   ;;; Basic Rules
        
   prefix-arg-str      = < a string that matches the rule >
                         < prefix-arg >
        
   prefix-arg-str      = < a string that matches the rule >
                         < prefix-arg >
        
   prefix-arg          = prefix
        
   prefix-arg          = prefix
        
   prefix              = identifier
        
   prefix              = identifier
        
   identifier-arg-str  = < a string that matches the rule >
                         < identifier-arg >
        
   identifier-arg-str  = < a string that matches the rule >
                         < identifier-arg >
        
   identifier-arg      = identifier
        
   identifier-arg      = identifier
        
   identifier          = (ALPHA / "_")
                         *(ALPHA / DIGIT / "_" / "-" / ".")
        
   identifier          = (ALPHA / "_")
                         *(ALPHA / DIGIT / "_" / "-" / ".")
        
   identifier-ref-arg-str = < a string that matches the rule >
                            < identifier-ref-arg >
        
   identifier-ref-arg-str = < a string that matches the rule >
                            < identifier-ref-arg >
        
   identifier-ref-arg  = identifier-ref
        
   identifier-ref-arg  = identifier-ref
        
   identifier-ref      = [prefix ":"] identifier
        
   identifier-ref      = [prefix ":"] identifier
        
   string              = < an unquoted string, as returned by >
                         < the scanner, that matches the rule >
                         < yang-string >
        
   string              = < an unquoted string, as returned by >
                         < the scanner, that matches the rule >
                         < yang-string >
        
   yang-string         = *yang-char
        
   yang-string         = *yang-char
        
   ;; any Unicode or ISO/IEC 10646 character, including tab, carriage
   ;; return, and line feed but excluding the other C0 control
   ;; characters, the surrogate blocks, and the noncharacters
   yang-char = %x09 / %x0A / %x0D / %x20-D7FF /
                               ; exclude surrogate blocks %xD800-DFFF
              %xE000-FDCF /    ; exclude noncharacters %xFDD0-FDEF
              %xFDF0-FFFD /    ; exclude noncharacters %xFFFE-FFFF
              %x10000-1FFFD /  ; exclude noncharacters %x1FFFE-1FFFF
              %x20000-2FFFD /  ; exclude noncharacters %x2FFFE-2FFFF
              %x30000-3FFFD /  ; exclude noncharacters %x3FFFE-3FFFF
              %x40000-4FFFD /  ; exclude noncharacters %x4FFFE-4FFFF
              %x50000-5FFFD /  ; exclude noncharacters %x5FFFE-5FFFF
              %x60000-6FFFD /  ; exclude noncharacters %x6FFFE-6FFFF
              %x70000-7FFFD /  ; exclude noncharacters %x7FFFE-7FFFF
              %x80000-8FFFD /  ; exclude noncharacters %x8FFFE-8FFFF
              %x90000-9FFFD /  ; exclude noncharacters %x9FFFE-9FFFF
              %xA0000-AFFFD /  ; exclude noncharacters %xAFFFE-AFFFF
              %xB0000-BFFFD /  ; exclude noncharacters %xBFFFE-BFFFF
              %xC0000-CFFFD /  ; exclude noncharacters %xCFFFE-CFFFF
              %xD0000-DFFFD /  ; exclude noncharacters %xDFFFE-DFFFF
              %xE0000-EFFFD /  ; exclude noncharacters %xEFFFE-EFFFF
              %xF0000-FFFFD /  ; exclude noncharacters %xFFFFE-FFFFF
              %x100000-10FFFD  ; exclude noncharacters %x10FFFE-10FFFF
        
   ;; any Unicode or ISO/IEC 10646 character, including tab, carriage
   ;; return, and line feed but excluding the other C0 control
   ;; characters, the surrogate blocks, and the noncharacters
   yang-char = %x09 / %x0A / %x0D / %x20-D7FF /
                               ; exclude surrogate blocks %xD800-DFFF
              %xE000-FDCF /    ; exclude noncharacters %xFDD0-FDEF
              %xFDF0-FFFD /    ; exclude noncharacters %xFFFE-FFFF
              %x10000-1FFFD /  ; exclude noncharacters %x1FFFE-1FFFF
              %x20000-2FFFD /  ; exclude noncharacters %x2FFFE-2FFFF
              %x30000-3FFFD /  ; exclude noncharacters %x3FFFE-3FFFF
              %x40000-4FFFD /  ; exclude noncharacters %x4FFFE-4FFFF
              %x50000-5FFFD /  ; exclude noncharacters %x5FFFE-5FFFF
              %x60000-6FFFD /  ; exclude noncharacters %x6FFFE-6FFFF
              %x70000-7FFFD /  ; exclude noncharacters %x7FFFE-7FFFF
              %x80000-8FFFD /  ; exclude noncharacters %x8FFFE-8FFFF
              %x90000-9FFFD /  ; exclude noncharacters %x9FFFE-9FFFF
              %xA0000-AFFFD /  ; exclude noncharacters %xAFFFE-AFFFF
              %xB0000-BFFFD /  ; exclude noncharacters %xBFFFE-BFFFF
              %xC0000-CFFFD /  ; exclude noncharacters %xCFFFE-CFFFF
              %xD0000-DFFFD /  ; exclude noncharacters %xDFFFE-DFFFF
              %xE0000-EFFFD /  ; exclude noncharacters %xEFFFE-EFFFF
              %xF0000-FFFFD /  ; exclude noncharacters %xFFFFE-FFFFF
              %x100000-10FFFD  ; exclude noncharacters %x10FFFE-10FFFF
        
   integer-value       = ("-" non-negative-integer-value) /
                          non-negative-integer-value
        
   integer-value       = ("-" non-negative-integer-value) /
                          non-negative-integer-value
        

non-negative-integer-value = "0" / positive-integer-value

非负整数值=“0”/正整数值

   positive-integer-value = (non-zero-digit *DIGIT)
        
   positive-integer-value = (non-zero-digit *DIGIT)
        
   zero-integer-value  = 1*DIGIT
        
   zero-integer-value  = 1*DIGIT
        
   stmtend             = optsep (";" / "{" stmtsep "}") stmtsep
        
   stmtend             = optsep (";" / "{" stmtsep "}") stmtsep
        
   sep                 = 1*(WSP / line-break)
                         ; unconditional separator
        
   sep                 = 1*(WSP / line-break)
                         ; unconditional separator
        
   optsep              = *(WSP / line-break)
        
   optsep              = *(WSP / line-break)
        
   stmtsep             = *(WSP / line-break / unknown-statement)
        
   stmtsep             = *(WSP / line-break / unknown-statement)
        
   line-break          = CRLF / LF
        
   line-break          = CRLF / LF
        
   non-zero-digit      = %x31-39
        
   non-zero-digit      = %x31-39
        

decimal-value = integer-value ("." zero-integer-value)

十进制值=整数值(“.”零整数值)

   SQUOTE              = %x27
                         ; single quote
        
   SQUOTE              = %x27
                         ; single quote
        
   ;;; core rules from RFC 5234
        
   ;;; core rules from RFC 5234
        
   ALPHA               = %x41-5A / %x61-7A
                         ; A-Z / a-z
        
   ALPHA               = %x41-5A / %x61-7A
                         ; A-Z / a-z
        
   CR                  = %x0D
                         ; carriage return
        
   CR                  = %x0D
                         ; carriage return
        

CRLF = CR LF ; Internet standard newline

CRLF=CRLF;互联网标准新线

   DIGIT               = %x30-39
                         ; 0-9
        
   DIGIT               = %x30-39
                         ; 0-9
        
   DQUOTE              = %x22
                         ; double quote
        
   DQUOTE              = %x22
                         ; double quote
        
   HTAB                = %x09
                         ; horizontal tab
        
   HTAB                = %x09
                         ; horizontal tab
        
   LF                  = %x0A
                         ; line feed
        
   LF                  = %x0A
                         ; line feed
        
   SP                  = %x20
                         ; space
        
   SP                  = %x20
                         ; space
        

WSP = SP / HTAB ; whitespace

WSP=SP/HTAB;空白

<CODE ENDS>

<代码结束>

15. NETCONF Error Responses for YANG-Related Errors
15. 与YANG相关错误的NETCONF错误响应

A number of NETCONF error responses are defined for error cases related to the data model handling. If the relevant YANG statement has an "error-app-tag" substatement, that overrides the default value specified below.

为与数据模型处理相关的错误案例定义了许多NETCONF错误响应。如果相关语句具有“error-app-tag”子语句,则会覆盖下面指定的默认值。

15.1. Error Message for Data That Violates a "unique" Statement
15.1. 违反“unique”语句的数据的错误消息

If a NETCONF operation would result in configuration data where a "unique" constraint is invalidated, the following error MUST be returned:

如果NETCONF操作将导致配置数据中的“唯一”约束无效,则必须返回以下错误:

error-tag: operation-failed error-app-tag: data-not-unique error-info: <non-unique>: Contains an instance identifier that points to a leaf that invalidates the "unique" constraint. This element is present once for each non-unique leaf.

错误标记:操作失败错误应用标记:数据不唯一错误信息:<non-unique>:包含一个实例标识符,该标识符指向使“unique”约束无效的叶。对于每个非唯一叶,此元素存在一次。

The <non-unique> element is in the YANG namespace ("urn:ietf:params:xml:ns:yang:1").

<non-unique>元素位于YANG名称空间(“urn:ietf:params:xml:ns:YANG:1”)中。

15.2. Error Message for Data That Violates a "max-elements" Statement
15.2. 违反“max elements”语句的数据的错误消息

If a NETCONF operation would result in configuration data where a list or a leaf-list would have too many entries, the following error MUST be returned:

如果NETCONF操作将导致配置数据中的列表或叶列表包含过多条目,则必须返回以下错误:

error-tag: operation-failed error-app-tag: too-many-elements

错误标记:操作失败错误应用标记:元素太多

This error is returned once, with the error-path identifying the list node, even if there is more than one extra child present.

此错误返回一次,错误路径标识列表节点,即使存在多个子节点。

15.3. Error Message for Data That Violates a "min-elements" Statement
15.3. 违反“min elements”语句的数据的错误消息

If a NETCONF operation would result in configuration data where a list or a leaf-list would have too few entries, the following error MUST be returned:

如果NETCONF操作将导致配置数据中列表或叶列表的条目太少,则必须返回以下错误:

error-tag: operation-failed error-app-tag: too-few-elements

错误标记:操作失败错误应用标记:元素太少

This error is returned once, with the error-path identifying the list node, even if there is more than one child missing.

此错误返回一次,错误路径标识列表节点,即使缺少多个子节点也是如此。

15.4. Error Message for Data That Violates a "must" Statement
15.4. 违反“必须”语句的数据的错误消息

If a NETCONF operation would result in configuration data where the restrictions imposed by a "must" statement are violated, the following error MUST be returned, unless a specific "error-app-tag" substatement is present for the "must" statement.

如果NETCONF操作将导致配置数据违反“必须”语句施加的限制,则必须返回以下错误,除非“必须”语句存在特定的“错误应用程序标记”子语句。

error-tag: operation-failed error-app-tag: must-violation

错误标记:操作失败错误应用标记:必须违反

15.5. Error Message for Data That Violates a "require-instance" Statement

15.5. 违反“require instance”语句的数据的错误消息

If a NETCONF operation would result in configuration data where a leaf of type "instance-identifier" or "leafref" marked with require-instance "true" refers to an instance that does not exist, the following error MUST be returned:

如果NETCONF操作将导致配置数据中带有require instance“true”标记的“instance identifier”或“leafref”类型的叶引用不存在的实例,则必须返回以下错误:

error-tag: data-missing error-app-tag: instance-required error-path: Path to the instance-identifier or leafref leaf.

错误标记:数据丢失错误应用程序标记:实例所需错误路径:实例标识符或leafref叶的路径。

15.6. Error Message for Data That Violates a Mandatory "choice" Statement

15.6. 违反强制“choice”语句的数据的错误消息

If a NETCONF operation would result in configuration data where no nodes exists in a mandatory choice, the following error MUST be returned:

如果NETCONF操作将导致配置数据中不存在强制选项中的节点,则必须返回以下错误:

error-tag: data-missing error-app-tag: missing-choice error-path: Path to the element with the missing choice. error-info: <missing-choice>: Contains the name of the missing mandatory choice.

错误标记:数据丢失错误应用程序标记:缺少选项错误路径:缺少选项的元素的路径。错误信息:<missing choice>:包含缺少的强制选项的名称。

The <missing-choice> element is in the YANG namespace ("urn:ietf:params:xml:ns:yang:1").

<missing choice>元素位于YANG名称空间(“urn:ietf:params:xml:ns:YANG:1”)中。

15.7. Error Message for the "insert" Operation
15.7. “插入”操作的错误消息

If the "insert" and "key" or "value" attributes are used in an <edit-config> for a list or leaf-list node and the "key" or "value" refers to an instance that does not exist, the following error MUST be returned:

如果在列表或叶列表节点的<edit config>中使用了“insert”和“key”或“value”属性,并且“key”或“value”引用了不存在的实例,则必须返回以下错误:

error-tag: bad-attribute error-app-tag: missing-instance

错误标记:错误属性错误应用标记:缺少实例

16. IANA Considerations
16. IANA考虑

This document registers one capability identifier URN from the "Network Configuration Protocol (NETCONF) Capability URNs" registry:

本文档从“网络配置协议(NETCONF)能力URN”注册表中注册一个能力标识符URN:

     Index           Capability Identifier
     -------------   ---------------------------------------------------
     :yang-library   urn:ietf:params:netconf:capability:yang-library:1.0
        
     Index           Capability Identifier
     -------------   ---------------------------------------------------
     :yang-library   urn:ietf:params:netconf:capability:yang-library:1.0
        
17. Security Considerations
17. 安全考虑

This document defines a language with which to write and read descriptions of management information. The language itself has no security impact on the Internet.

本文档定义了一种用于编写和读取管理信息描述的语言。这种语言本身对互联网没有安全影响。

The same considerations are relevant as those for the base NETCONF protocol (see Section 9 in [RFC6241]).

与基本NETCONF协议相关的注意事项相同(参见[RFC6241]中的第9节)。

Data modeled in YANG might contain sensitive information. RPCs or notifications defined in YANG might transfer sensitive information.

在YANG中建模的数据可能包含敏感信息。中定义的RPC或通知可能会传输敏感信息。

Security issues are related to the usage of data modeled in YANG. Such issues shall be dealt with in documents describing the data models and documents about the interfaces used to manipulate the data, e.g., the NETCONF documents.

安全问题与YANG中建模的数据的使用有关。此类问题应在描述数据模型的文件和用于操作数据的接口的文件中处理,例如NETCONF文件。

Data modeled in YANG is dependent upon:

在YANG中建模的数据取决于:

o the security of the transmission infrastructure used to send sensitive information.

o 用于发送敏感信息的传输基础设施的安全性。

o the security of applications that store or release such sensitive information.

o 存储或发布此类敏感信息的应用程序的安全性。

o adequate authentication and access control mechanisms to restrict the usage of sensitive data.

o 充分的身份验证和访问控制机制,以限制敏感数据的使用。

YANG parsers need to be robust with respect to malformed documents. Reading malformed documents from unknown or untrusted sources could result in an attacker gaining the privileges of the user running the YANG parser. In an extreme situation, the entire machine could be compromised.

YANG解析器需要对格式错误的文档具有健壮性。从未知或不受信任的来源读取格式错误的文档可能会导致攻击者获得运行YANG解析器的用户的权限。在极端情况下,整个机器可能受到威胁。

18. References
18. 工具书类
18.1. Normative References
18.1. 规范性引用文件

[ISO.10646] International Organization for Standardization, "Information Technology - Universal Multiple-Octet Coded Character Set (UCS)", ISO Standard 10646:2014, 2014.

[ISO.10646]国际标准化组织,“信息技术-通用多八位编码字符集(UCS)”,ISO标准10646:2014,2014。

[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997, <http://www.rfc-editor.org/info/rfc2119>.

[RFC2119]Bradner,S.,“RFC中用于表示需求水平的关键词”,BCP 14,RFC 2119,DOI 10.17487/RFC2119,1997年3月<http://www.rfc-editor.org/info/rfc2119>.

[RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November 2003, <http://www.rfc-editor.org/info/rfc3629>.

[RFC3629]Yergeau,F.,“UTF-8,ISO 10646的转换格式”,STD 63,RFC 3629,DOI 10.17487/RFC3629,2003年11月<http://www.rfc-editor.org/info/rfc3629>.

[RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform Resource Identifier (URI): Generic Syntax", STD 66, RFC 3986, DOI 10.17487/RFC3986, January 2005, <http://www.rfc-editor.org/info/rfc3986>.

[RFC3986]Berners Lee,T.,Fielding,R.,和L.Masinter,“统一资源标识符(URI):通用语法”,STD 66,RFC 3986,DOI 10.17487/RFC3986,2005年1月<http://www.rfc-editor.org/info/rfc3986>.

[RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data Encodings", RFC 4648, DOI 10.17487/RFC4648, October 2006, <http://www.rfc-editor.org/info/rfc4648>.

[RFC4648]Josefsson,S.,“Base16、Base32和Base64数据编码”,RFC 4648,DOI 10.17487/RFC4648,2006年10月<http://www.rfc-editor.org/info/rfc4648>.

[RFC5234] Crocker, D., Ed., and P. Overell, "Augmented BNF for Syntax Specifications: ABNF", STD 68, RFC 5234, DOI 10.17487/RFC5234, January 2008, <http://www.rfc-editor.org/info/rfc5234>.

[RFC5234]Crocker,D.,Ed.,和P.Overell,“语法规范的扩充BNF:ABNF”,STD 68,RFC 5234,DOI 10.17487/RFC5234,2008年1月<http://www.rfc-editor.org/info/rfc5234>.

[RFC5277] Chisholm, S. and H. Trevino, "NETCONF Event Notifications", RFC 5277, DOI 10.17487/RFC5277, July 2008, <http://www.rfc-editor.org/info/rfc5277>.

[RFC5277]Chisholm,S.和H.Trevino,“NETCONF事件通知”,RFC 5277,DOI 10.17487/RFC5277,2008年7月<http://www.rfc-editor.org/info/rfc5277>.

[RFC6241] Enns, R., Ed., Bjorklund, M., Ed., Schoenwaelder, J., Ed., and A. Bierman, Ed., "Network Configuration Protocol (NETCONF)", RFC 6241, DOI 10.17487/RFC6241, June 2011, <http://www.rfc-editor.org/info/rfc6241>.

[RFC6241]Enns,R.,Ed.,Bjorklund,M.,Ed.,Schoenwaeld,J.,Ed.,和A.Bierman,Ed.,“网络配置协议(NETCONF)”,RFC 6241,DOI 10.17487/RFC6241,2011年6月<http://www.rfc-editor.org/info/rfc6241>.

[RFC7405] Kyzivat, P., "Case-Sensitive String Support in ABNF", RFC 7405, DOI 10.17487/RFC7405, December 2014, <http://www.rfc-editor.org/info/rfc7405>.

[RFC7405]Kyzivat,P.,“ABNF中的区分大小写字符串支持”,RFC 7405,DOI 10.17487/RFC7405,2014年12月<http://www.rfc-editor.org/info/rfc7405>.

[RFC7895] Bierman, A., Bjorklund, M., and K. Watsen, "YANG Module Library", RFC 7895, DOI 10.17487/RFC7895, June 2016, <http://www.rfc-editor.org/info/rfc7895>.

[RFC7895]Bierman,A.,Bjorklund,M.,和K.Watsen,“阳模块库”,RFC 7895,DOI 10.17487/RFC78952016年6月<http://www.rfc-editor.org/info/rfc7895>.

[XML] Bray, T., Paoli, J., Sperberg-McQueen, C., Maler, E., and F. Yergeau, "Extensible Markup Language (XML) 1.0 (Fifth Edition)", W3C Recommendation REC-xml-20081126, November 2008, <https://www.w3.org/TR/2008/REC-xml-20081126/>.

[XML]Bray,T.,Paoli,J.,Sperberg McQueen,C.,Maler,E.,和F.Yergeau,“可扩展标记语言(XML)1.0(第五版)”,W3C建议REC-XML-20081126,2008年11月<https://www.w3.org/TR/2008/REC-xml-20081126/>.

[XML-NAMES] Bray, T., Hollander, D., Layman, A., Tobin, R., and H. Thompson, "Namespaces in XML 1.0 (Third Edition)", World Wide Web Consortium Recommendation REC-xml-names-20091208, December 2009, <http://www.w3.org/TR/2009/REC-xml-names-20091208>.

[XML-NAMES]Bray,T.,Hollander,D.,Layman,A.,Tobin,R.,和H.Thompson,“XML 1.0中的名称空间(第三版)”,万维网联盟建议REC-XML-NAMES-20091208,2009年12月<http://www.w3.org/TR/2009/REC-xml-names-20091208>.

[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-TYPES] 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-TYPES]Biron,P.和A.Malhotra,“XML模式第2部分:数据类型第二版”,万维网联盟建议REC-xmlschema-2-20041028,2004年10月<http://www.w3.org/TR/2004/REC-xmlschema-2-20041028>.

18.2. Informative References
18.2. 资料性引用

[CoMI] van der Stok, P. and A. Bierman, "CoAP Management Interface", Work in Progress, draft-vanderstok-core-comi-09, March 2016.

[CoMI]van der Stok,P.和A.Bierman,“CoAP管理界面”,在建工程,草稿-vanderstok-core-CoMI-092016年3月。

[IEEE754-2008] IEEE, "IEEE Standard for Floating-Point Arithmetic", IEEE 754-2008, DOI 10.1109/IEEESTD.2008.4610935, 2008, <http://standards.ieee.org/findstds/ standard/754-2008.html>.

[IEEE754-2008]IEEE,“IEEE浮点运算标准”,IEEE 754-2008,DOI 10.1109/IEEESTD.2008.46109352008<http://standards.ieee.org/findstds/ 标准/754-2008.html>。

[RESTCONF] Bierman, A., Bjorklund, M., and K. Watsen, "RESTCONF Protocol", Work in Progress, draft-ietf-netconf-restconf-16, August 2016.

[RESTCONF]Bierman,A.,Bjorklund,M.,和K.Watsen,“RESTCONF协议”,正在进行的工作,草稿-ietf-netconf-RESTCONF-162016年8月。

[RFC2578] McCloghrie, K., Ed., Perkins, D., Ed., and J. Schoenwaelder, Ed., "Structure of Management Information Version 2 (SMIv2)", STD 58, RFC 2578, DOI 10.17487/RFC2578, April 1999, <http://www.rfc-editor.org/info/rfc2578>.

[RFC2578]McCloghrie,K.,Ed.,Perkins,D.,Ed.,和J.Schoenwaeld,Ed.“管理信息的结构版本2(SMIv2)”,STD 58,RFC 2578,DOI 10.17487/RFC2578,1999年4月<http://www.rfc-editor.org/info/rfc2578>.

[RFC2579] McCloghrie, K., Ed., Perkins, D., Ed., and J. Schoenwaelder, Ed., "Textual Conventions for SMIv2", STD 58, RFC 2579, DOI 10.17487/RFC2579, April 1999, <http://www.rfc-editor.org/info/rfc2579>.

[RFC2579]McCloghrie,K.,Ed.,Perkins,D.,Ed.,和J.Schoenwaeld,Ed.“SMIv2的文本约定”,STD 58,RFC 2579,DOI 10.17487/RFC2579,1999年4月<http://www.rfc-editor.org/info/rfc2579>.

[RFC3780] Strauss, F. and J. Schoenwaelder, "SMIng - Next Generation Structure of Management Information", RFC 3780, DOI 10.17487/RFC3780, May 2004, <http://www.rfc-editor.org/info/rfc3780>.

[RFC3780]Strauss,F.和J.Schoenwaeld,“SMIng-下一代管理信息结构”,RFC 3780,DOI 10.17487/RFC3780,2004年5月<http://www.rfc-editor.org/info/rfc3780>.

[RFC4844] Daigle, L., Ed., and Internet Architecture Board, "The RFC Series and RFC Editor", RFC 4844, DOI 10.17487/RFC4844, July 2007, <http://www.rfc-editor.org/info/rfc4844>.

[RFC4844]Daigle,L.,Ed.,和互联网架构委员会,“RFC系列和RFC编辑器”,RFC 4844,DOI 10.17487/RFC4844,2007年7月<http://www.rfc-editor.org/info/rfc4844>.

[RFC6020] Bjorklund, M., Ed., "YANG - A Data Modeling Language for the Network Configuration Protocol (NETCONF)", RFC 6020, DOI 10.17487/RFC6020, October 2010, <http://www.rfc-editor.org/info/rfc6020>.

[RFC6020]Bjorklund,M.,Ed.“YANG-网络配置协议的数据建模语言(NETCONF)”,RFC 6020,DOI 10.17487/RFC6020,2010年10月<http://www.rfc-editor.org/info/rfc6020>.

[RFC6643] Schoenwaelder, J., "Translation of Structure of Management Information Version 2 (SMIv2) MIB Modules to YANG Modules", RFC 6643, DOI 10.17487/RFC6643, July 2012, <http://www.rfc-editor.org/info/rfc6643>.

[RFC6643]Schoenwaeld,J.,“管理信息版本2(SMIv2)MIB模块结构到YANG模块的翻译”,RFC 6643,DOI 10.17487/RFC6643,2012年7月<http://www.rfc-editor.org/info/rfc6643>.

[RFC6991] Schoenwaelder, J., Ed., "Common YANG Data Types", RFC 6991, DOI 10.17487/RFC6991, July 2013, <http://www.rfc-editor.org/info/rfc6991>.

[RFC6991]Schoenwaeld,J.,Ed.,“常见杨数据类型”,RFC 6991,DOI 10.17487/RFC69911913年7月<http://www.rfc-editor.org/info/rfc6991>.

[RFC7951] Lhotka, L., "JSON Encoding of Data Modeled with YANG", RFC 7951, DOI 10.17487/RFC7951, August 2016, <http://www.rfc-editor.org/info/rfc7951>.

[RFC7951]Lhotka,L.,“用YANG建模的数据的JSON编码”,RFC 7951,DOI 10.17487/RFC7951,2016年8月<http://www.rfc-editor.org/info/rfc7951>.

[XPATH2.0] Berglund, A., Boag, S., Chamberlin, D., Fernandez, M., Kay, M., Robie, J., and J. Simeon, "XML Path Language (XPath) 2.0 (Second Edition)", World Wide Web Consortium Recommendation REC-xpath20-20101214, December 2010, <http://www.w3.org/TR/2010/REC-xpath20-20101214>.

[XPATH2.0]Berglund,A.,Boag,S.,Chamberlin,D.,Fernandez,M.,Kay,M.,Robie,J.,和J.Simeon,“XML路径语言(XPath)2.0(第二版)”,万维网联盟建议REC-xpath20-20101214,2010年12月<http://www.w3.org/TR/2010/REC-xpath20-20101214>.

[XSLT] Clark, J., "XSL Transformations (XSLT) Version 1.0", World Wide Web Consortium Recommendation REC-xslt-19991116, November 1999, <http://www.w3.org/TR/1999/REC-xslt-19991116>.

[XSLT]Clark,J.,“XSL转换(XSLT)1.0版”,万维网联盟建议REC-XSLT-19991116,1999年11月<http://www.w3.org/TR/1999/REC-xslt-19991116>.

[YANG-Guidelines] Bierman, A., "Guidelines for Authors and Reviewers of YANG Data Model Documents", Work in Progress, draft-ietf-netmod-rfc6087bis-07, July 2016.

[YANG指南]Bierman,A.,“YANG数据模型文件的作者和评审者指南”,正在进行的工作,草稿-ietf-netmod-rfc6087bis-07,2016年7月。

Acknowledgements

致谢

The editor wishes to thank the following individuals, who all provided helpful comments on various draft versions of this document: Mehmet Ersue, Washam Fan, Joel Halpern, Per Hedeland, Leif Johansson, Ladislav Lhotka, Lionel Morand, Gerhard Muenz, Peyman Owladi, Tom Petch, Randy Presuhn, David Reid, Jernej Tuljak, Kent Watsen, Bert Wijnen, Robert Wilton, and Dale Worley.

编辑希望感谢以下个人,他们都对本文件的各种草案版本提供了有益的意见:梅米特·厄苏、瓦萨姆·范、乔尔·哈尔佩恩、佩尔·海德兰、莱夫·约翰逊、拉迪斯拉夫·洛特卡、莱昂内尔·莫兰德、格哈德·穆恩斯、佩曼·奥拉迪、汤姆·佩奇、兰迪·普雷森、大卫·里德、杰尼·图尔雅克、肯特·沃特森、伯特·维恩、,罗伯特·威尔顿和戴尔·沃利。

Contributors

贡献者

The following people all contributed significantly to the initial YANG document:

以下人员都对最初的YANG文件做出了重大贡献:

- Andy Bierman (YumaWorks) - Balazs Lengyel (Ericsson) - David Partain (Ericsson) - Juergen Schoenwaelder (Jacobs University Bremen) - Phil Shafer (Juniper Networks)

- 安迪·比尔曼(尤马works)-巴拉兹·伦杰尔(爱立信)-大卫·帕坦(爱立信)-尤尔根·舍恩瓦埃尔德(不来梅雅各布大学)-菲尔·沙弗(朱尼珀网络公司)

Author's Address

作者地址

Martin Bjorklund (editor) Tail-f Systems

Martin Bjorklund(编辑)Tail-f系统

   Email: mbj@tail-f.com
        
   Email: mbj@tail-f.com