SimpleNamespaceContext implements NamespaceContext { public void removeBinding(String prefix) { String namespaceUri = prefixToNamespaceUri.remove(prefix); if (namespaceUri != null) { Set<String> prefixes = getPrefixesInternal(namespaceUri); prefixes.remove(prefix); } }  @Override String getNamespaceURI(String prefix); @Override String getPrefix(String namespaceUri); @Override Iterator<String> getPrefixes(String namespaceUri); void setBindings(Map<String, String> bindings); void bindDefaultNamespaceUri(String namespaceUri); void bindNamespaceUri(String prefix, String namespaceUri); void clear(); Iterator<String> getBoundPrefixes(); void removeBinding(String prefix); boolean hasBinding(String prefix);  }
@Test public void testRemoveBinding() { context.clear(); String prefix1 = "prefix1"; String prefix2 = "prefix2"; String namespaceUri = "namespaceUri"; context.bindNamespaceUri(prefix1, namespaceUri); context.bindNamespaceUri(prefix2, namespaceUri); Iterator<String> iter = context.getPrefixes(namespaceUri); Assert.assertTrue("iterator is empty", iter.hasNext()); Assert.assertEquals(prefix1, iter.next()); Assert.assertTrue("iterator is empty", iter.hasNext()); Assert.assertEquals(prefix2, iter.next()); Assert.assertFalse("iterator not empty", iter.hasNext()); context.removeBinding(prefix1); iter = context.getPrefixes(namespaceUri); Assert.assertTrue("iterator is empty", iter.hasNext()); Assert.assertEquals(prefix2, iter.next()); Assert.assertFalse("iterator not empty", iter.hasNext()); context.removeBinding(prefix2); iter = context.getPrefixes(namespaceUri); Assert.assertFalse("iterator not empty", iter.hasNext()); }