[xml] relative xpath matches nodes anywhere in tree



So apparently when libxml2 evaluates an XPath expression that is
relative it searches everywhere in the tree, as if the expression
started with "//". For instance

~/tmp$ cat test.xml
<?xml version="1.0"?>
<x>
        <y>Test</y>
</x>
~/tmp$ xmllint --xpath y test.xml
<y>Test</y>

My understanding of XPath says that "y" matches all the child elements
of the context node named y. Since the context is the root, this
should match no elements. What's going on here?

PS this came up because of an XMLStarlet bug report:
http://sourceforge.net/tracker/index.php?func=detail&aid=3527850&group_id=66612&atid=515106



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