public final int isPrefixValid(String prefix, String nsURI,
                                   boolean isElement)
        throws XMLStreamException
    {
        // Hmmm.... caller shouldn't really pass null.
        if (nsURI == null) {
            nsURI = "";
        }

        /* First thing is to see if specified prefix is bound to a namespace;
         * and if so, verify it matches with data passed in:
         */

        // Checking default namespace?
        if (prefix == null || prefix.length() == 0) {
            if (isElement) {
                // It's fine for elements only if the URI actually matches:
                if (nsURI == mDefaultNsURI || nsURI.equals(mDefaultNsURI)) {
                    return PREFIX_OK;
                }
            } else {
                /* Attributes never use the default namespace: "no prefix"
                 * can only mean "no namespace"
                 */
                if (nsURI.length() == 0) {
                    return PREFIX_OK;
                }
            }
            return PREFIX_MISBOUND;
        }

        /* Need to handle 'xml' prefix and its associated
         *   URI; they are always declared by default
         */
        if (prefix.equals(sXmlNsPrefix)) {
            // Should we thoroughly verify its namespace matches...?
            // 01-Apr-2005, TSa: Yes, let's always check this
            if (!nsURI.equals(sXmlNsURI)) {
                throwOutputError("Namespace prefix '"+sXmlNsPrefix
                                 +"' can not be bound to non-default namespace ('"+nsURI+"'); has to be the default '"
                                 +sXmlNsURI+"'");
            }
            return PREFIX_OK;
        }

        // Nope checking some other namespace
        String act;

        if (mNsMapping != null) {
            act = mNsMapping.findUriByPrefix(prefix);
        } else {
            act = null;
        }

        if (act == null && mRootNsContext != null) {
            act = mRootNsContext.getNamespaceURI(prefix);
        }
 
        // Not (yet) bound...
        if (act == null) {
            return PREFIX_UNBOUND;
        }

        return (act == nsURI || act.equals(nsURI)) ?
            PREFIX_OK : PREFIX_MISBOUND;
    }
public final int isPrefixValid ( String prefix , String nsURI , boolean isElement ) throws XMLStreamException { if ( nsURI == null ) { nsURI = "" ; } if ( prefix == null || prefix . length ( ) == 0 ) { if ( isElement ) { if ( nsURI == mDefaultNsURI || nsURI . equals ( mDefaultNsURI ) ) { return PREFIX_OK ; } } else { if ( nsURI . length ( ) == 0 ) { return PREFIX_OK ; } } return PREFIX_MISBOUND ; } if ( prefix . equals ( sXmlNsPrefix ) ) { if ( ! nsURI . equals ( sXmlNsURI ) ) { throwOutputError ( "Namespace prefix '" + sXmlNsPrefix + "' can not be bound to non-default namespace ('" + nsURI + "'); has to be the default '" + sXmlNsURI + "'" ) ; } return PREFIX_OK ; } String act ; if ( mNsMapping != null ) { act = mNsMapping . findUriByPrefix ( prefix ) ; } else { act = null ; } if ( act == null && mRootNsContext != null ) { act = mRootNsContext . getNamespaceURI ( prefix ) ; } if ( act == null ) { return PREFIX_UNBOUND ; } return ( act == nsURI || act . equals ( nsURI ) ) ? PREFIX_OK : PREFIX_MISBOUND ; }
Method that verifies that passed-in prefix indeed maps to the specified
namespace URI; and depending on how it goes returns a status for
caller.

@param isElement If true, rules for the default NS are those of elements
(ie. empty prefix can map to non-default namespace); if false,
rules are those of attributes (only non-default prefix can map to
a non-default namespace).

@return PREFIX_OK, if passed-in prefix matches matched-in namespace URI
in current scope; PREFIX_UNBOUND if it's not bound to anything,
and PREFIX_MISBOUND if it's bound to another URI.

@throws XMLStreamException True if default (no) prefix is allowed to
match a non-default URI (elements); false if not (attributes)