Examples of using current() & deref() in XPath oimt 2019. KL. 003. 00_XPath-current-deref ONF OIMT & OTCC 2019. 09 -13 San Jose Joint Meeting CICT-Fiber. Home Kam LAM
XPath in YANG 1. 1 – RFC 7950 • XPath – XML Path Language • YANG relies on XPath 1. 0 as a notation for specifying inter-node references and dependencies • In RFC 7950 – YANG 1. 1 • 6. 4 XPath Evaluations: XPath Context, examples • 10 XPath Functions: • 10. 1 Node Sets • 10. 1. 1 current() • node-set current() • The current() function takes no input parameters and returns a node set with the initial context node as its only member.
XPath in YANG 1. 1 – RFC 7950 • In RFC 7950 – YANG 1. 1 • 6. 4 XPath Evaluations: XPath Context, examples • 10 XPath Functions: • 10. 1 Node Sets • • 10. 1. 1 current() 10. 3 YANG Types leafref & instanceidentifier • 10. 3. 1 deref() • node-set deref(node-set nodes) • The deref() function follows the reference defined by the first node in document order in the argument "nodes" and returns the nodes it refers to
XPath in YANG 1. 1 – RFC 7950 • Use of deref() and current() in XPath • deref() is needed when you need to follow a leafref to the leaf it is pointing to • current() is needed to get the current element • Beniot Example (via Scott) • There authors and books. A book has an author. You want to make sure the author has an account-id. • So the current() returns author. To get to the account-id, you need to follow the leafref to /authors/author/name, then backup a level in the tree and then down to account-id. Just like navigating paths in unix.