简体   繁体   English

yang中的叶子名称和类型名称可以相同

[英]leaf name and type name can be same in yang

Below example is correct yang statement or not?下面的例子是正确的 yang 陈述与否? it is valid by pyang but JNC is unable to process它对 pyang 有效,但 JNC 无法处理

grouping TLId {
leaf age {
type Age;
mandatory true;
}
}

typedef Age {
type string {
pattern '[0-9][0-9]';
}
}

Please suggest请建议

Your YANG snippet is valid.您的 YANG 片段是有效的。

Typedefs are assigned to a different namespace compared to schema node identifiers - there can never be a name conflict between a leaf identifier and a typedef identifier, as decribed in Section 6.2.1 of RFC7950 :与模式节点标识符相比,typedef 被分配到不同的命名空间 - 叶标识符和 typedef 标识符之间永远不会发生名称冲突,如RFC7950 的第 6.2.1 节所述

Each identifier is valid in a namespace that depends on the type of the YANG item being defined.每个标识符在取决于所定义的 YANG 项的类型的命名空间中都是有效的。 All identifiers defined in a namespace MUST be unique.命名空间中定义的所有标识符必须是唯一的。

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. o 在父节点或模块顶层或其子模块中定义的所有派生类型名称共享相同的类型标识符命名空间。 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.这意味着任何后代节点都可以使用该 typedef,并且它不能定义具有相同名称的 typedef。

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 在父节点或模块或其子模块的顶层定义(直接或通过“uses”语句)定义的所有叶子、叶子列表、列表、容器、选择、RPC、操作、通知、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.在这种情况下,命名空间的范围是最近的祖先节点,而不是案例或选择节点。

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

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