cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

150
Views
1
Helpful
2
Replies
khgrant
Cisco Employee

Variables in XPATH query supported in templates?

Hi experts,

I am currently trying to reduce java-provided variable for a service.

Each static route needs precessing in Java to get the correct network mask.

So Java is calling the appropriate XML template. I thought I could use a variable to steer the XPATH to the correct list entry for which the java calculation just took place, but NCS is not resolving the Variable.

                    <ip-route-interface-forwarding-list when="{$NEXTHOP}">

                       <prefix>{StatischeRoute/IPv4Route[$I]/IP-Netzadresse}</prefix>

                       <mask>{$IP-Maskenlaenge}</mask>

                       <interface>{$INTERFACE}</interface>

                       <forwarding-address>{$NEXTHOPADRESSE}</forwarding-address>

                       <metric>{$METRIK}</metric>

< /ip-route-interface-forwarding-list>

admin@ncs% set services CoCo AuftragAnschluss T-4118169-ORD Anschluss KundenRouter c0 StatischeRoute IPv4Route 0.0.0.0 0 FastEthernet4 NextHopAdresse 87.137.118.241 Adressraumkennzeichen Default Metrik 1 Betriebsstatus Planned Redistribute false

dmin@ncs% set services CoCo AuftragAnschluss T-4118169-ORD Anschluss KundenRouter c0 StatischeRoute IPv4Route 212.184.11.248 29 Null0 Adressraumkennzeichen PAT Metrik 250 Betriebsstatus Planned Redistribute false

21-Apr-2015::17:47:23.871 maapi_xpath_eval() evaluating: StatischeRoute/IPv4Route[$I]/IP-Netzadresse

et_next(/ncs:services/CoCo/AuftragAnschluss{T-4118169-ORD}/Anschluss/KundenRouter{c0}/StatischeRoute/IPv4Route) = {0.0.0.0 0 FastEthernet4}

et_next(/ncs:services/CoCo/AuftragAnschluss{T-4118169-ORD}/Anschluss/KundenRouter{c0}/StatischeRoute/IPv4Route{0.0.0.0 0 FastEthernet4}) = {212.184.11.248 29 Null0}

et_next(/ncs:services/CoCo/AuftragAnschluss{T-4118169-ORD}/Anschluss/KundenRouter{c0}/StatischeRoute/IPv4Route{212.184.11.248 29 Null0}) = false

1-Apr-2015::17:47:23.871 maapi_xpath_eval() done

admin@ncs% commit dry-run outformat native

device c0 {

  ip route 0.0.0.0 0.0.0.0 FastEthernet4 87.137.118.241 1

  ip route 0.0.0.0 255.255.255.248 Null0 250

}

“I” is incrementing from 1 to x. Using …IPv4Route[1]… i.e. gives an appropriate result.

Is there anything I missed ?

2 REPLIES 2
khgrant
Cisco Employee

It is hard to tell what is going wrong here without the code which assigns the value to the variable.

This is my guess:

You use the method putQuoted to assign the value to the variable, $I would then be ’17’ , if you use put to assign the value the value of $I would be 17

khgrant
Cisco Employee

I now tried both ways with the same result.

        String I = String.valueOf(Index);

       System.out.println(I);

       Vars.putQuoted("I", I);

“Index” is an integer I get as part of the method call.

The print shows me "I" is incrementing.

I now tried .putQouted and .put , but the XPATH query remains "IPv4Route[$I]” , where is not substituted.

Create
Recognize Your Peers
Content for Community-Ad