/** * {@inheritDoc} * * @see org.modeshape.graph.property.NamespaceRegistry#unregister(java.lang.String) */ public boolean unregister( String namespaceUri ) { // We cannot unregister an alias, so we only need to try unregistering with the delegate registry ... return delegate.unregister(namespaceUri); }
/** * {@inheritDoc} * * @see org.modeshape.graph.property.NamespaceRegistry#unregister(java.lang.String) */ public boolean unregister( String namespaceUri ) { CheckArg.isNotNull(namespaceUri, "namespaceUri"); Lock lock = this.registryLock.writeLock(); try { lock.lock(); return delegate.unregister(namespaceUri); } finally { lock.unlock(); } }
/** * {@inheritDoc} * * @see org.xml.sax.helpers.DefaultHandler#endPrefixMapping(java.lang.String) */ @Override public void endPrefixMapping( String prefix ) { assert prefix != null; // Get the current URI for this prefix ... String uri = namespaceRegistry.getNamespaceForPrefix(prefix); assert uri != null; // Get the previous prefix from the stack ... LinkedList<String> prefixStack = this.prefixStackByUri.get(uri); assert prefixStack != null; assert !prefixStack.isEmpty(); String existingPrefix = prefixStack.removeFirst(); assert prefix.equals(existingPrefix); // If there are no previous prefixes, then remove the mapping ... if (prefixStack.isEmpty()) { namespaceRegistry.unregister(uri); prefixStackByUri.remove(uri); } else { String previous = prefixStack.getFirst(); namespaceRegistry.register(previous, uri); } }
@Test public void shouldParseXmlDocumentWithNamespacesThatAreNotYetInRegistry() throws IOException, SAXException { NamespaceRegistry reg = context.getNamespaceRegistry(); reg.unregister(JcrLexicon.Namespace.URI); reg.unregister(NT_NAMESPACE_URI);