@Override
    public void startPrefixMapping( String prefix,
                                    String uri ) throws SAXException {
        try {
            if (isUriRegistered(uri) && !StringUtil.isBlank(prefix)) {
                // It is already registered, but re-register it locally using the supplied prefix ...
                session.setNamespacePrefix(prefix, uri);
            } else {
                // The namespace is not already registered so we have to register it with the ws namespace registry.
                // This should also make the prefix available to the current session
                NamespaceRegistry namespaceRegistry = (NamespaceRegistry)session.getWorkspace().getNamespaceRegistry();
                if (StringUtil.isBlank(prefix)) {
                    prefix = namespaceRegistry.registerNamespace(uri);
                } else {
                    namespaceRegistry.registerNamespace(prefix, uri);
                }
            }
        } catch (RepositoryException e) {
            throw new SAXException(e);
        }

        // Add the prefix to the stack ...
        LinkedList<String> prefixStack = this.prefixStackByUri.get(uri);
        if (prefixStack == null) {
            prefixStack = new LinkedList<String>();
            this.prefixStackByUri.put(uri, prefixStack);
        }
        prefixStack.addFirst(prefix);
    }
@ Override public void startPrefixMapping ( String prefix , String uri ) throws SAXException { try { if ( isUriRegistered ( uri ) && ! StringUtil . isBlank ( prefix ) ) { session . setNamespacePrefix ( prefix , uri ) ; } else { NamespaceRegistry namespaceRegistry = ( NamespaceRegistry ) session . getWorkspace ( ) . getNamespaceRegistry ( ) ; if ( StringUtil . isBlank ( prefix ) ) { prefix = namespaceRegistry . registerNamespace ( uri ) ; } else { namespaceRegistry . registerNamespace ( prefix , uri ) ; } } } catch ( RepositoryException e ) { throw new SAXException ( e ) ; } LinkedList < String > prefixStack = this . prefixStackByUri . get ( uri ) ; if ( prefixStack == null ) { prefixStack = new LinkedList < String > ( ) ; this . prefixStackByUri . put ( uri , prefixStack ) ; } prefixStack . addFirst ( prefix ) ; }
<p>
This method ensures that the namespace is registered with the {@link NamespaceRegistry registry}, using the supplied prefix
to register the namespace if required. Note that because this class does not really use the namespace prefixes to create
names, no attempt is made to match the XML namespace prefixes.
</p>

@see org.xml.sax.helpers.DefaultHandler#startPrefixMapping(String, String)