usage of current vs ../ in yang xpath expressions

前端 未结 1 1252
予麋鹿
予麋鹿 2021-01-24 01:59

is the usage of .. and current() in the following snippet correct ? Meaning, there are times when current() and ../ are equivalent ?

container c {
   leaf f1 {
          


        
1条回答
  •  孤独总比滥情好
    2021-01-24 02:22

    The way you use current() in your example is correct, but redundant. current() returns the initial context node and since all expressions start with the initial context node in their contexts in makes no sense to explicitly state this.

    This does not mean that current() is equivalent to ../ at the beginning of an expression. The latter may be expanded into parent::node()/child::node(), which returns all children of the parent of the initial context node. The returning node set will contain the initial context node, along with all its siblings. This is not what current() returns - it is at best similar.

    What would be equivalent is . or, written alternatively, self::node(). If an expression starts with ., it may return the same node as current(), but this is entirely dependent on the context where . is used.

    0 讨论(0)
提交回复
热议问题