This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
It doesn't matter whether the prefix is the same or different. What does matter is the namespace URI applied to the prefixes in the two places; that should be the same.
In the XML document I can see the namespace URI which is applied to the "ns" prefix. But I don't see the code where you apply a namespace URI to the "tns" prefix in your XPath expression. Perhaps you didn't apply any? If you are asking about a javax.xml.xpath.XPath object (you didn't mention that) then the setNamespaceContext method is how you do that.