drools-eclipse/org.guvnor.eclipse.webdav/src/interface/org/eclipse/webdav/dom/ElementEditor.java
public static String resolve(String prefix, Element element) {
        Assert.isNotNull(element);

        /* The prefix xml is by definition bound to the namespace name
         * <code>XML_NS_NAME</code>.
         */
        if (XML_NS_PREFIX.equals(prefix)) {
            return XML_NS_NAME;
        }

        /* Search from given element up parent chain to root (document)
         * looking for a XML namespace declaration (represented as
         * an element attribute with a name beginning in
         * XML_PREFIX ("xmlns")).
         */
        Node current = element;
        do {
            NamedNodeMap attrs = current.getAttributes();
            int n = attrs.getLength();
            for (int i = 0; i < n; i++) {
                Attr attr = (Attr) attrs.item(i);
                String name = attr.getName();
                if (name.startsWith(XML_PREFIX)) {
                    if (name.length() == XML_PREFIX.length()) {
                        // no prefix e.g., xmlns="foo:"
                        if (prefix == null) {
                            String nsName = attr.getValue();
                            if (nsName.equals("")) { //$NON-NLS-1$
                                return null;
                            }
                            return nsName;
                        }
                    } else {
                        if (prefix != null && name.equals(XML_PREFIX + ":" + prefix)) { //$NON-NLS-1$
                            return attr.getValue();
                        }
                    }
                }
            }
            do {
                current = current.getParentNode();
            } while (current != null && current.getNodeType() != Node.ELEMENT_NODE);
        } while (current != null);
        return null;
    }
public static String resolve(String prefix, Element element) {
        Assert.isNotNull(element);

        /* The prefix xml is by definition bound to the namespace name
         * <code>XML_NS_NAME</code>.
         */
        if (XML_NS_PREFIX.equals(prefix)) {
            return XML_NS_NAME;
        }

        /* Search from given element up parent chain to root (document)
         * looking for a XML namespace declaration (represented as
         * an element attribute with a name beginning in
         * XML_PREFIX ("xmlns")).
         */
        Node current = element;
        do {
            NamedNodeMap attrs = current.getAttributes();
            int n = attrs.getLength();
            for (int i = 0; i < n; i++) {
                Attr attr = (Attr) attrs.item(i);
                String name = attr.getName();
                if (name.startsWith(XML_PREFIX)) {
                    if (name.length() == XML_PREFIX.length()) {
                        // no prefix e.g., xmlns="foo:"
                        if (prefix == null) {
                            String nsName = attr.getValue();
                            if (nsName.equals("")) { //$NON-NLS-1$
                                return null;
                            }
                            return nsName;
                        }
                    } else {
                        if (prefix != null && name.equals(XML_PREFIX + ":" + prefix)) { //$NON-NLS-1$
                            return attr.getValue();
                        }
                    }
                }
            }
            do {
                current = current.getParentNode();
            } while (current != null && current.getNodeType() != Node.ELEMENT_NODE);
        } while (current != null);
        return null;
    }
public static String resolve ( String prefix , Element element ) { Assert . isNotNull ( element ) ; /* The prefix xml is by definition bound to the namespace name
         * <code>XML_NS_NAME</code>.
         */ if ( XML_NS_PREFIX . equals ( prefix ) ) { return XML_NS_NAME ; } /* Search from given element up parent chain to root (document)
         * looking for a XML namespace declaration (represented as
         * an element attribute with a name beginning in
         * XML_PREFIX ("xmlns")).
         */ Node current = element ; do { NamedNodeMap attrs = current . getAttributes ( ) ; int n = attrs . getLength ( ) ; for ( int i = 0 ; i < n ; i ++ ) { Attr attr = ( Attr ) attrs . item ( i ) ; String name = attr . getName ( ) ; if ( name . startsWith ( XML_PREFIX ) ) { if ( name . length ( ) == XML_PREFIX . length ( ) ) { // no prefix e.g., xmlns="foo:" if ( prefix == null ) { String nsName = attr . getValue ( ) ; if ( nsName . equals ( "" ) ) { //$NON-NLS-1$ return null ; } return nsName ; } } else { if ( prefix != null && name . equals ( XML_PREFIX + ":" + prefix ) ) { //$NON-NLS-1$ return attr . getValue ( ) ; } } } } do { current = current . getParentNode ( ) ; } while ( current != null && current . getNodeType ( ) != Node . ELEMENT_NODE ) ; } while ( current != null ) ; return null ; }
Resolves the given namespace prefix in the namespace of the given
element. If the given prefix is <code>null</code>, the default
namespace is resolved. Returns the URL of the namespace, or
<code>null</code> if the prefix could not be resolved.

@param prefix  the namespace prefix to be resolved, or
<code>null<code> for the default namespace
@param element the element supplying the namespace
@return        the URL of the namespace, or <code>null</code> if the
prefix could not be resolved
Resolves the given namespace prefix in the namespace of the given element . If the given prefix is <code > null< / code > the default namespace is resolved . Returns the URL of the namespace or <code > null< / code > if the prefix could not be resolved .