Example usage for org.dom4j Namespace getName

List of usage examples for org.dom4j Namespace getName

Introduction

In this page you can find the example usage for org.dom4j Namespace getName.

Prototype

public String getName() 

Source Link

Usage

From source file:org.orbeon.oxf.xml.dom4j.NonLazyUserDataElement.java

License:Open Source License

/**
 * If parent != null checks with ancestors and removes any redundant namespace declarations.
 *///from   ww w  . ja v  a  2  s  .c om
public void setParent(final org.dom4j.Element prnt) {
    super.setParent(prnt);
    done: if (prnt != null) {
        final org.dom4j.Namespace myNs = getNamespace();
        if (myNs != org.dom4j.Namespace.NO_NAMESPACE) {
            final String myPfx = myNs.getPrefix();
            final org.dom4j.Namespace prntNs = prnt.getNamespaceForPrefix(myPfx);
            if (myPfx.equals(prntNs)) {
                final String myNm = myNs.getName();
                final org.dom4j.QName newNm = new org.dom4j.QName(myNm);
                setQName(newNm);
            }
        }
        if (content == null)
            break done;
        for (final java.util.Iterator itr = content.iterator(); itr.hasNext();) {
            final org.dom4j.Node chld = (org.dom4j.Node) itr.next();
            if (chld.getNodeType() != org.dom4j.Node.NAMESPACE_NODE)
                continue;

            final org.dom4j.Namespace ns = (org.dom4j.Namespace) chld;
            final String pfx = ns.getPrefix();

            final org.dom4j.Namespace prntNs = prnt.getNamespaceForPrefix(pfx);
            if (ns.equals(prntNs))
                itr.remove();
        }
    }
}