07-27-2018 09:31 AM
https://community.cisco.com/t5/nso-developer-hub-discussions/xpath-position/td-p/3513828
For context please first review the issue described in the link above. We left this issue at a point where it was determined that moving to 4.6+ was the only possible solution which supports new capabilities in the template such as setting variable values and several new loop constructs. I have upgraded one of our lab nodes to 4.6.1.3, and where I am still stuck is - within the foreach loop segment - how to increment the value of the counter. In the 4.6.1.3 development guide, the section on pg.261, only demonstrates the ability to increment a counter when using a for loop construct, but does not show any indication of how this may done in a foreach context, where the value of the counter is preserved across each pass, incremented and subsequently applied in the template.
07-27-2018 12:18 PM
Solution that I came up with eventually - Hope this will help others as well - Snippet from my template; mpls-path-hops is a list in my yang.....
<? set i = 0 ?>
<? foreach {mpls-path-hops} ?>
<?set i={$i+100}?>
<hop>
<hop-number>{$i}</hop-number>
<ip-address>{hop-id}</ip-address>
<mode>{hop-id-state}</mode>
</hop>
<?end?>
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide