PDA

View Full Version : [OPEN] [UNKNOWN][3.??] Xpath handling by Domquery has a bug



networknoob
2 Sep 2009, 1:19 AM
When I have xpath mentioned within Domquery ,it works fine as long as xpath doesnt have special keyword...for example 'all'.
Here is example
xpath= /configuration/protocols/igmp-snopping/vlan:(name:has nodeValue(vname))/interfaces;
Ext.Domquery(xpath,candidateconfig);

Now if vname is all, it should pick up xml data under vlan all only. However it picks up data for all vlans that configured.

Condor
2 Sep 2009, 1:27 AM
DomQuery only supports a subset of the XPath syntax. I'm not an XPath expert, but I think your XPath selector isn't valid (and it's certainly not supported by Ext).

Are you looking for:

xpath= '/configuration/protocols/igmp-snopping/vlan[name=vname]/interfaces';

networknoob
2 Sep 2009, 1:33 AM
@Condor : I dint bother about syntax while posting...here is the exact line

X6 = "configuration/protocols/igmp-snooping/vlan:has(name:nodeValue(" + vname + "))/interface/name";
editInterfacesid = Ext.DomQuery.select(X6,candidateConfigforVlan);

networknoob
2 Sep 2009, 1:35 AM
the problem is this works fine as long as vlan name a or b or c or x. It picks up everything from other vlans also if vlan name is all.

Condor
2 Sep 2009, 1:49 AM
Can you post an extract from the XML?

ps. This checks if the vlan node has a child element (at any level) with value 'all'. Could it be that you actually want:

/configuration/protocols/igmp-snooping/vlan:has(/name:nodeValue(" + vname + "))/interface/name

networknoob
2 Sep 2009, 2:25 AM
<configuration >
<protocols>
<igmp-snooping>
<vlan>
<name>all</name>
<robust-count>5</robust-count>
</vlan>
<vlan>
<name>v2</name>
<interface>
<name>all</name>
</interface>
<interface>
<name>ge-0/0/0.0</name>
</interface>
</vlan>
</igmp-snooping>
</protocols>
</configuration>

Condor
2 Sep 2009, 2:43 AM
Exactly as I suspected: vlan:has(name:nodeValue(all)) will match both vlan elements, because both contain a name element with value 'all' (one as a direct vlan child and one as an vlan/interface child).

Have you tried my suggested selector (with the added slash) ?

networknoob
2 Sep 2009, 2:45 AM
Will do it right away! Give me some time!
Thanks anyway!

networknoob
2 Sep 2009, 3:09 AM
looks like it is working perfectly !!

Thanks.

Will do testing .will report back if there is any issue.

networknoob
2 Sep 2009, 5:04 AM
I hope this is last question from side ...Do You expect this / to create any problem anywhere else? I mean I was thinking of applying it all over!

Condor
2 Sep 2009, 5:06 AM
It just means that the element needs to be a direct child of the parent element.

So, if that is correct for all your selectors I would recommend it (because it is also faster).

networknoob
2 Sep 2009, 5:09 AM
ok thanks