URI uri = resource.getURI();
String full = uri.toString();
String partial = getPartialUri(full);
String ns = uris.get(partial);
if (ns == null) {
throw new NamespaceException("Partial uri: " + partial + " is not mapped to a namespace.");
}
return full.replaceFirst(partial, ns + ":");
}