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 ; }
Declare a mapping of a prefix to namespace URI at the given element depth .