简体   繁体   English

为什么带有名称类型的叶节点在杨模型中不起作用?

[英]Why leaf node with name type does not work in yang model?

I have this simple yang model 我有这个简单的阳模型

leaf type {
    type string;
    description "some description";
}

This is not working. 这不起作用。 Can someone please explain if string 'type' is invalid for leaf name in yang? 有人可以解释一下,如果字符串'type'对杨的叶子名称无效吗?

A leaf statement argument must be an identifier and there is no restriction that prohibits usage of YANG keywords where an identifier is expected (all built-in keywords are also identifiers). leaf语句参数必须是标识符,并且没有限制禁止使用期望标识符的YANG关键字(所有内置关键字也是标识符)。 Both leaf type {...} and leaf leaf {...} are valid YANG statements. leaf type {...}leaf leaf {...}都是有效的YANG语句。

The "leaf" statement is used to define a leaf node in the schema tree. “leaf”语句用于在模式树中定义叶节点。 It takes one argument, which is an identifier, followed by a block of substatements that holds detailed leaf information. 它需要一个参数,它是一个标识符,后跟一个包含详细叶信息的子语句块。

RFC7950, Section 7.6 RFC7950,第7.6节

Here's what the specification says about identifiers: 以下是规范中关于标识符的内容:

Identifiers are used to identify different kinds of YANG items by name. 标识符用于按名称标识不同类型的YANG项目。 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. 每个标识符以大写或小写ASCII字母或下划线字符开头,后跟零个或多个ASCII字母,数字,下划线字符,连字符和点。 Implementations MUST support identifiers up to 64 characters in length and MAY support longer identifiers. 实现必须支持最长64个字符的标识符,并且可以支持更长的标识符。 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. 标识符语法由第14节中的规则“identifier”正式定义。标识符可以指定为带引号或不带引号的字符串。

RFC7950, Section 6.2 RFC7950,第6.2节

The grammar rule mentioned above: 上面提到的语法规则:

identifier          = (ALPHA / "_")
                     *(ALPHA / DIGIT / "_" / "-" / ".")

Here's what it says about the namespace of leaf statements (a namespace imposes a unique name requirement within its scope, with the purpose of preventing name clashes): 以下是关于leaf语句命名空间的说法(命名空间在其范围内强加了一个唯一的名称要求,目的是防止名称冲突):

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. o父节点内或模块顶层或其子模块中定义的所有叶子,叶子列表,列表,容器,选项,rpcs,操作,通知,anydatas和anyxmls(直接或通过“使用”语句)共享相同的标识符命名空间 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. 在这种情况下,命名空间的范围限定为不是大小写或选择节点的最近的祖先节点。

RFC7950, Section 6.2.1 RFC7950,第6.2.1节

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM