// Look for an existing namespace node that uses the same URI ...
NodeKey key = keyForNamespaceUri(newUri);
CachedNode existingNode = system.getNode(key);
if (existingNode != null) {
// Get the prefix for the existing namespace node ...
Segment segment = existingNode.getSegment(system);
String existingPrefix = prefixFor(segment);
if (GENERATED_NAMESPACE_NODE_NAME.equals(segment.getName()) || !existingPrefix.equals(newPrefix)) {
// The prefix but was not used elsewhere, so we know we can just change it ...
namespaces.renameChild(system, key, names.create(newPrefix));
removedPrefixes.add(existingPrefix);
}
} else if (newUri.length() > 0) {