cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
116
Views
0
Helpful
1
Replies
jian_zhang
Beginner

Expression meaning in NSO template xml

Hi

 When I was learning nano service, I found this expression in the nso example.

 string(*[local-name()=$IFNAME])  

 I do not understand the meaning of ' *[local-name()=$IFNAME] '. 

What is the meanings of the expression '*[ ....]' and the function ' local-name() '.

 

xml template file:

nso-5.5.5.2.3/examples.ncs/getting-started/developing-with-ncs/20-nano-services/packages/link/templates/link-template.xml

<devices xmlns="http://tail-f.com/ns/ncs">

    <?foreach {endpoints}?>

      <?foreach {a-device|b-device}?>

        <?set IFNAME={substring(local-name(), 1, 1)}-interface?>

        <device>

          <name>{.}</name>

          <config>

            <sys xmlns="http://example.com/router">

              <interfaces>

                <interface tags="merge">

                  <name>{string(*[local-name()=$IFNAME])}</name>

                  <?set-context-node {..}?>

                  <unit>

                    <name>{unit}</name>

                    <vlan-id>{vlan-id}</vlan-id>

                  </unit>

                </interface>

              </interfaces>

            </sys>

          </config>

        </device>

      <?end?>

    <?end?>

  </devices>

</config-template>



1 REPLY 1
vleijon
Cisco Employee

This is a fun one. So local-name() is an xpath function that gives the name of the node without any namespace prefixes. So what the expression does is that it select all nodes in the context * and then filter them using a predicates ([]) so that it selects a local node that has a name matching $IFNAME. It is a way of picking the right element in the service model based on another part of the model.