NodeImpl next = parent;
while (true) {
if (next.getNodeKind()==Type.DOCUMENT) {
// prefixCode==0 represents the empty namespace prefix ""
if (prefixCode==0) return NamespaceConstant.NULL_CODE;
throw new NamespaceException(getNamePool().getPrefixFromNamespaceCode(prefixCode<<16));
} else if (next instanceof ElementWithAttributes) {
return ((ElementWithAttributes)next).getURICodeForPrefixCode(prefixCode);
} else {
next = (NodeImpl)next.getParentNode();
}