Element parent = new Element("Test", "http://www.example.org");
Element child = new Element("child", "http://www.example.org");
parent.appendChild(child);
Element test = new Element("test");
test.addAttribute(new Attribute("pre:test", "http://www.example.org", "value"));
Element testChild = new Element("testchild");
test.appendChild(testChild);
XPathContext context = XPathContext.makeNamespaceContext(testChild);
Nodes result = parent.query("child::pre:child", context);
assertEquals(1, result.size());