Re: [xml] Possible bug in xmlGetNodePath



Ahmed schrieb am 26.11.2012 um 13:26 (-0500):

I have notice that xmlGetNodePath doesn't return the right path if the
same namespace has different prefixes in the document.

For example for calling xmlGetNodePath on any of the following nodes
in this document will return "/root/l_0:l1"

/************** Document with multiple prefixes for the same namespace
****************/
<root xmlns:a="http://a.b/c";>
  <l_0:l1 xmlns:l_0="http://ns.org/ns/"; id="id_0"/>
  <l_1:l1 xmlns:l_1="http://ns.org/ns/"; id="id_1"/>
  <l_2:l1 xmlns:l_2="http://ns.org/ns/"; id="id_2"/>
  <l_3:l1 xmlns:l_3="http://ns.org/ns/"; id="id_3"/>
  <l_4:l1 xmlns:l_4="http://ns.org/ns/"; id="id_4"/>
  <l_5:l1 xmlns:l_5="http://ns.org/ns/"; id="id_5"/>
  <l_6:l1 xmlns:l_6="http://ns.org/ns/"; id="id_6"/>
  <l_7:l1 xmlns:l_7="http://ns.org/ns/"; id="id_7"/>
  <l_8:l1 xmlns:l_8="http://ns.org/ns/"; id="id_8"/>
  <l_9:l1 xmlns:l_9="http://ns.org/ns/"; id="id_9"/>
</root>
/************** End ****************/

xmlGetNodePath (ÂBuild a structure based Path for the given nodeÂ) is
not a DOM API function, but one specific to libxml2, so I'd say it's not
much of a problem â

However if I use the same prefix for all nodes, xmlGetNodePath will
return the correct xpath for each node (/root/ns:l1[1],
/root/ns:l1[2], etc...)

So now you know how *not* to use namespace prefixes. ;)

Michael



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]