xmllint whereis shell command truncates long element names
Given this document with long element names, xmllint whereis shell command truncates found path for elements with a namespace prefix.
The bug also reproduces on lxml python package which also relies on libxml2
.
local-name()
returns string of the same length for all elements.
<root xmlns:ns="http://example.com/ns">
<anon-wrap xmlns="http://example.com/anon-dflt">
<t1>
<b01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678z01234567890123456789012345678x>1</b01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678z01234567890123456789012345678x>
</t1>
<t2>
<b01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678z01234567890123456789012345678x>2</b01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678z01234567890123456789012345678x>
</t2>
</anon-wrap>
<ns:a01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678z01234567890123456789012345678x>ERROR: 0 elements found</ns:a01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678z01234567890123456789012345678x>
<ns:a01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678z01234567890123456789012345678x>duplicate error</ns:a01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678z01234567890123456789012345678x>
</root>
whereis
command will truncate the found path
/ > setrootns
/ > du
/
root
anon-wrap
t1
b01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678z01234567890123456789012345678x
t2
b01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678z01234567890123456789012345678x
ns:a01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678z01234567890123456789012345678x
ns:a01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678z01234567890123456789012345678x
/ > whereis //ns:a01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678z01234567890123456789012345678x
/root/ns:a0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123[1]
/root/ns:a0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123[2]
The bug was indirectly found while working with python lxml
package. The method tree.getpath(element)
truncates the path in the same exact way as xmllint
does.
See a complete report here
https://github.com/mluis7/pyxml2xpath/issues/19
Edited by Luis M C