Declare a mapping of a prefix to namespace URI at the given element depth.
@param prefix a String with the prefix for a qualified name
@param uri a String with the uri to which the prefix is to map
@param elemDepth the depth of current declaration
420827
public boolean pushNamespace(String prefix, String uri, int elemDepth)
    {
        // Prefixes "xml" and "xmlns" cannot be redefined
        if (prefix.startsWith(XML_PREFIX))
        {
            return false;
        }

        Stack stack;
        // Get the stack that contains URIs for the specified prefix
        if ((stack = (Stack) m_namespaces.get(prefix)) == null)
        {
            m_namespaces.put(prefix, stack = new Stack());
        }

        if (!stack.empty())
        {
            MappingRecord mr = (MappingRecord)stack.peek();
            if (uri.equals(mr.m_uri) || elemDepth == mr.m_declarationDepth) {
                // If the same prefix/uri mapping is already on the stack
                // don't push this one.
                // Or if we have a mapping at the same depth
                // don't replace by pushing this one.
                return false;
            }
        }
        MappingRecord map = new MappingRecord(prefix,uri,elemDepth);
        stack.push(map);
        m_nodeStack.push(map);
        return true;
    }
138139
public void setPrefix(String prefix)
  {
    _prefix = prefix;
    
    if (prefix != null)
      _pathPrefix = prefix.replace('.', '/');
  }
517516
public String lookupNamespace(final String prefix) {
        Object namespace = namespaceMap.get(prefix);
        if (namespace != null) {
            return namespace.toString();
        }
        return this.namespaceTagHints.isEmpty() ? prefix : this.namespaceTagHints.get(prefix);
    }
117120
public void registerMapping(String prefix, String namespaceURI)
   {
      prefix2Ns.put(prefix, namespaceURI);
      ns2Prefix.put(namespaceURI, prefix);
   }
815331
@Override
    public String getNamespaceURI(String prefix){
        if(prefix==null)
            throw new IllegalArgumentException("prefix is null");

        return get(prefix);
    }
660960
public void xmlns(Map<String, String> definition) {
        Assert.notNull(namespaceHandlerResolver, "You cannot define a Spring namespace without a [namespaceHandlerResolver] set");
        if (definition.isEmpty()) {
            return;
        }

        for (Map.Entry<String, String> entry : definition.entrySet()) {
            String namespace = entry.getKey();
            String uri = entry.getValue() == null ? null : entry.getValue();

            Assert.notNull(uri, "Namespace definition cannot supply a null URI");

            final NamespaceHandler namespaceHandler = namespaceHandlerResolver.resolve(uri);
            if (namespaceHandler == null) {
                throw new BeanDefinitionParsingException(
                      new Problem("No namespace handler found for URI: " + uri,
                            new Location(readerContext.getResource())));
            }
            namespaceHandlers.put(namespace, namespaceHandler);
            namespaces.put(namespace, uri);
        }
    }
584116
public XMLDocument endElements(String uri, String name) throws SAXException{
        QName qname = findEndElement();
        while(true){
            endElement(qname);
            if(qname.getNamespaceURI().equals(uri) && qname.getLocalPart().equals(name))
                break;
        }
        return this;
    }
467874
public T namespace(String prefix, String namespaceUri) {
        getXpathVariableExtractor().getNamespaces().put(prefix, namespaceUri);
        xmlMessageValidationContext.getNamespaces().put(prefix, namespaceUri);
        return self;
    }
10461
private String getElementURI() {
        String uri = null;
        // At this point in processing we have received all the
        // namespace mappings
        // As we still don't know the elements namespace,
        // we now figure it out.

        String prefix = getPrefixPart(m_elemContext.m_elementName);

        if (prefix == null) {
            // no prefix so lookup the URI of the default namespace
            uri = m_prefixMap.lookupNamespace("");
        } else {
            uri = m_prefixMap.lookupNamespace(prefix);
        }
        if (uri == null) {
            // We didn't find the namespace for the
            // prefix ... ouch, that shouldn't happen.
            // This is a hack, we really don't know
            // the namespace
            uri = EMPTYSTRING;
        }

        return uri;
    }
974176
public void setNamespace(String prefix, String uri) {

    this.prefix2namespace.put(prefix, uri);
    this.namespace2prefix.put(uri, prefix);
  }
762465
public void setDefaultNamespaceURI(String namespaceURI) {
    if (namespaceURI == null)
      throw new IllegalArgumentException("Cannot set default prefix to null namespace URI");

    bindings.put(XMLConstants.DEFAULT_NS_PREFIX, namespaceURI);
  }
200928
public void addNamespace(String prefix, String namespaceURI) {
        if (prefix == null || namespaceURI == null) {
            throw new IllegalArgumentException("null arguments not allowed.");
        }
        if (namespaceURI.equals(XMLConstants.XML_NS_URI)) {
            throw new IllegalArgumentException("Adding a new namespace for " +
                XMLConstants.XML_NS_URI + "not allowed.");
        } else if (namespaceURI.equals(XMLConstants.XMLNS_ATTRIBUTE_NS_URI)) {
            throw new IllegalArgumentException("Adding a new namespace for " +
                XMLConstants.XMLNS_ATTRIBUTE_NS_URI + "not allowed.");
        }
        prefix2ns.put(prefix, namespaceURI);
    }
318371
def start_namespace(self, prefix, uri):
        
        self._g.startPrefixMapping(prefix, uri)
        self._ns[prefix] = uri
786582
protected Attribute resolveNamespaceDecl(int index, boolean internURI)
    {
        Attribute ns = mNamespaces[index];
        String full = mNamespaceBuilder.getAllValues();
        String uri;

        if (mNsCount == 0) {
            uri = full;
        } else {
            ++index;
            if (index < mNsCount) { // not last
                int endOffset = mNamespaces[index].mValueStartOffset;
                uri = ns.getValue(full, endOffset);
            } else { // is last
                uri = ns.getValue(full);
            }
        }
        if (internURI && uri.length() > 0) {
            uri = sInternCache.intern(uri);
        }
        ns.mNamespaceURI = uri;
        return ns;
    }
741046
protected static boolean isAdditionalNamespace(String namespaceURI) {
		assert (namespaceURI != null);
		if (namespaceURI.equals(Constants.XML_NULL_NS_URI)
				|| namespaceURI.equals(Constants.XML_NS_URI)
				|| namespaceURI.equals(Constants.XML_SCHEMA_INSTANCE_NS_URI)
				|| namespaceURI.equals(Constants.XML_SCHEMA_NS_URI)) {
			return false;
		} else {
			return true;
		}
	}
1240573
public void writeNamespace(final String prefix, final String uri) {
        if (!openStartElement) {
            throw new IllegalStateException("Current state does not allow Namespace writing");
        }
        final QName qName = elementStack.getFirst(); // peek
        for (final NamespaceMapping p: qName.mappings) {
            if (p.prefix.equals(prefix) && p.uri.equals(uri)) {
                return;
            } else if (p.prefix.equals(prefix)) {
                throw new IllegalArgumentException("Prefix " + prefix + " already bound to " + uri);
            }
        }
        qName.mappings.add(new NamespaceMapping(prefix, uri, true));
    }
875725
def _resolve_prefix(celt, prefix):
    '''
    '''
    namespace = None
    while _is_element(celt):
        if prefix:
            namespaceURI = _find_xmlns_prefix(celt, prefix)
        else:
            namespaceURI = _find_default_namespace(celt)
        if namespaceURI: break
        celt = celt.parentNode
    else:
        if prefix:  
            raise EvaluateException, 'cant resolve xmlns:%s' %prefix
    return namespaceURI