我知道Yang模型中的"when“语句使用XPATH表达式作为参数。
为了像下面这样对类型/值数据容器建模,组合多个表达式的正确YANG XPATH语法是什么?
container c1 {
leaf attrib-type {
type uint32;
}
leaf attrib-val-int {
when "../attrib-type = 1 or ../attrib-type = 2"
type uint32;
}
leaf attrib-val-string {
when "../attrib-type = 5 or ../attrib-type = 6"
type string;
}
}发布于 2016-01-08 14:49:15
您使用的XPath语法是正确的。您唯一缺少的就是when语句后面的分号。
有关在YANG中使用的XPath语法的完整参考,请查看XPath 1.0规范。
6.4。XPath评估
YANG依赖于XML Path Language (XPath) 1.0 [XPATH]作为一种符号来指定许多节点间引用和依赖关系。
发布于 2015-11-27 16:18:31
在XPath中,第一个条件可以写成:
when "../attrib-type[.=1 or .=2]"或者,如果需要显式返回boolean类型:
when "boolean(../attrib-type[.=1 or .=2])"https://stackoverflow.com/questions/30496110
复制相似问题