if (ptr.matches("^[\\w]+$")) {
ptr = "element(" + ptr + ")";
}
XPointer xptr = new XPointer(ptr);
Vector<XdmNode> nodes = xptr.selectNodes(runtime, doc);
if (nodes.size() == 1) {
doc = nodes.get(0);
} else if (nodes.size() != 0) {
throw new XProcException(node, "XPointer matches more than one node!?");