【问题标题】:usage of current vs ../ in yang xpath expressions在 yang xpath 表达式中使用 current vs ../
【发布时间】:2017-01-20 15:44:41
【问题描述】:

在下面的 sn-p 中使用 .. 和 current() 是否正确? 意思是,有时 current() 和 ../ 是等价的?

container c {
   leaf f1 {
       type string;
   }

   leaf f2 {
      type string;
      when "../f1 = 'abc'";
   }

   leaf f3 {
      type string;
      when "current()/../f1 = 'abc'";
   }
}

【问题讨论】:

    标签: ietf-netmod-yang


    【解决方案1】:

    您在示例中使用current() 的方式是正确的,但是是多余的。 current() 返回初始上下文节点,并且由于所有表达式都从其上下文中的初始上下文节点开始,因此显式声明这一点毫无意义。

    这并不意味着current() 等价于表达式开头的../。后者可以扩展为parent::node()/child::node(),返回初始上下文节点的父节点的所有子节点。返回的节点集将包含初始上下文节点及其所有兄弟节点。这不是current() 返回的 - 充其量是相似的。

    等同于.,或者写成self::node()。如果表达式以. 开头,它可能会返回与current() 相同的节点,但这完全取决于使用. 的上下文。

    【讨论】:

      猜你喜欢
      • 2019-04-10
      • 1970-01-01
      • 1970-01-01
      • 2020-11-21
      • 2016-01-06
      • 1970-01-01
      • 1970-01-01
      • 2010-09-29
      • 2014-09-05
      相关资源
      最近更新 更多