This is not Saxon-specific but rather a fundamental part of how namespaces work. In your examples 1 and 2 the RESPONSE
element is not in a namespace but in case 3 it (and all its descendants) are in the http://www.abc.com/
namespace. With the javax.xml.xpath
API you need to define a NamespaceContext
if you want to be able to match nodes in a specific namespace, or since you're in XPath 2.0 you can use the *:localName
notation to match all nodes with a given local name regardless of their namespace.
/*:RESPONSE/*:HEADER/*:HITS