Querying in the following...

<div xmlns="http://www.w3.org/1999/xhtml" id="test">
    <span id="A">
        <span id="B"></span>
    </span>
    <span id="C">
        <span id="D"></span>
    </span>
</div>

Query "ancestor::xhtml:span" from span#B
Result: span#A
Expected: span#A
SUCCESS

Query ".|ancestor::xhtml:span" from span#B
Result: span#A span#B
Expected: span#A span#B
SUCCESS

Query "ancestor::xhtml:span|." from span#B
Result: span#A span#B
Expected: span#A span#B
SUCCESS

Query "ancestor::xhtml:*[local-name()='span']" from span#B
Result: span#A
Expected: span#A
SUCCESS

Query ".|ancestor::xhtml:*[local-name()='span']" from span#B
Result: span#A span#B
Expected: span#A span#B
SUCCESS

Query "ancestor::xhtml:*[local-name()='span']|." from span#B
Result: span#A span#B
Expected: span#A span#B
SUCCESS

Query "(ancestor::xhtml:*[local-name()='span'])|." from span#B
Result: span#A span#B
Expected: span#A span#B
SUCCESS

Query "following::xhtml:*[local-name()='span']" from span#B
Result: span#C span#D
Expected: span#C span#D
SUCCESS

Query ".|following::xhtml:*[local-name()='span']" from span#B
Result: span#B span#C span#D
Expected: span#B span#C span#D
SUCCESS

Query "following::xhtml:*[local-name()='span']|." from span#B
Result: span#B span#C span#D
Expected: span#B span#C span#D
SUCCESS