Here you can find the source of resolveNamespacePrefix(String prefix, Element element)
public static String resolveNamespacePrefix(String prefix, Element element)
//package com.java2s; /**//from ww w . j a v a2 s .co m * This file belongs to the BPELUnit utility and Eclipse plugin set. See enclosed * license file for more information. */ import org.w3c.dom.Element; public class Main { public static String resolveNamespacePrefix(String prefix, Element element) { String namespace = null; if ("".equals(prefix)) { namespace = element.getAttribute("xmlns"); } else { namespace = element.getAttribute("xmlns:" + prefix); } if (namespace != null && !"".equals(namespace)) { return namespace; } if (element.getParentNode() instanceof Element) { return resolveNamespacePrefix(prefix, (Element) element.getParentNode()); } else { throw new RuntimeException("Cannot resolve prefix " + prefix); } } }