XPath has many ways to reference and compare data nodes


The dot '.' is shorthand for an AbbreviatedStep, and selects  the  context node


[12] AbbreviatedStep ::= '.'  | '..'

The context node changes as the expression is parsed.

For example, a new step or predicate starts a new context node


These 2 XPath expressions select the same set of nodes


   /if:interfaces/if:interface[if:name='eth0']


   /if:interfaces/if:interface/if:name[.='eth0']


The context node changes as the context set changes in each step.


1) root context set selects child node if:interfaces

2) if:interfaces context set selects child node if:interface

etc.


The current() function selects the initial context node and never changes value.

In YANG, this will be the node that contains the must or when statement.



   leaf my-itf {

      type string;

      must " /if:interfaces/if:interface[if:name=current()]";

   }


This must expression enforces the same constraint as a leafref,

which is that there must exist an interface with the same name as the value of the 'my-itf' leaf.



   leaf my-itf {

      type if:interface-ref;

   }